onboarding_option_tile.dart
3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import 'package:doublefeel_flutter/core/theme/app_theme.dart';
import 'package:flutter/material.dart';
import '../models/onboarding_option_data.dart';
class OnboardingOptionTile extends StatelessWidget {
const OnboardingOptionTile({
super.key,
required this.data,
required this.selected,
required this.onTap,
});
final OnboardingOptionData data;
final bool selected;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
return AnimatedScale(
scale: selected ? 1.01 : 1,
duration: const Duration(milliseconds: 180),
curve: Curves.easeOut,
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: onTap,
child: AnimatedContainer(
duration: const Duration(milliseconds: 180),
curve: Curves.easeOut,
constraints: const BoxConstraints(minHeight: 72),
margin: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
border: Border.all(
color: selected ? context.colors.primary : Colors.transparent,
width: 1.5,
),
boxShadow: selected
? [
BoxShadow(
color: context.colors.primary.withValues(alpha: 0.2),
blurRadius: 6,
offset: const Offset(0, 5),
),
]
: null,
),
child: Row(
children: [
_OptionIcon(data: data),
const SizedBox(width: 16),
Expanded(
child: Text(
data.label,
style: TextStyle(
color: selected
? context.colors.primary
: context.colors.textPrimary,
fontSize: 14,
fontWeight: FontWeight.w500,
height: 1.25,
letterSpacing: 0,
),
),
),
const SizedBox(width: 12),
_SelectionMark(selected: selected),
],
),
),
),
);
}
}
class _OptionIcon extends StatelessWidget {
const _OptionIcon({required this.data});
final OnboardingOptionData data;
@override
Widget build(BuildContext context) {
return Container(
width: 48,
height: 48,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: Color(0xFFF0F0F6),
),
child: Icon(
data.icon,
color: data.iconColor,
size: 24,
),
);
}
}
class _SelectionMark extends StatelessWidget {
const _SelectionMark({required this.selected});
final bool selected;
@override
Widget build(BuildContext context) {
return AnimatedContainer(
width: 20,
height: 20,
duration: const Duration(milliseconds: 160),
curve: Curves.easeOut,
decoration: BoxDecoration(
color: selected ? context.colors.primary : Colors.white,
shape: BoxShape.circle,
border: Border.all(
color: selected ? context.colors.primary : const Color(0xFFC9CAD5),
),
),
child: selected
? const Icon(
Icons.check_rounded,
color: Colors.white,
size: 14,
)
: null,
);
}
}