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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
import 'package:flutter_ics_homescreen/core/utils/helpers.dart';
import 'package:flutter_ics_homescreen/export.dart';
class UnitsPage extends ConsumerWidget {
const UnitsPage({super.key});
static Page<void> page() => const MaterialPage<void>(child: UnitsPage());
@override
Widget build(BuildContext context, WidgetRef ref) {
final unit = ref.watch(unitStateProvider.select((unit) => unit));
return Scaffold(
//appBar: SettingsTopBar('Units'),
body: Column(
children: [
CommonTitle(
title: 'Units',
hasBackButton: true,
onPressed: () {
context.flow<AppState>().update((state) => AppState.settings);
},
),
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 0, horizontal: 144),
child: ListView(
children: [
UnitsTile(
icon: Icons.calendar_month_outlined,
title: 'Distance',
unitName: unit.distanceUnit == DistanceUnit.kilometers
? 'kilometers'
: 'miles',
hasSwich: false,
voidCallback: () async {
context
.flow<AppState>()
.update((next) => AppState.distanceUnit);
}),
UnitsTile(
icon: Icons.straighten,
title: 'Temperature',
unitName: unit.temperatureUnit == TemperatureUnit.celsius
? 'Celsius'
: 'Fahrenheit',
hasSwich: true,
voidCallback: () {
context
.flow<AppState>()
.update((next) => AppState.tempUnit);
}),
UnitsTile(
icon: Icons.straighten,
title: 'Pressure',
unitName: unit.pressureUnit == PressureUnit.kilopascals
? 'kilopascals'
: 'PSI',
hasSwich: true,
voidCallback: () {
context
.flow<AppState>()
.update((next) => AppState.pressureUnit);
}),
],
),
),
),
],
),
);
}
}
class UnitsTile extends ConsumerStatefulWidget {
final IconData? icon;
final String title;
final String unitName;
final bool hasSwich;
final VoidCallback voidCallback;
final String? image;
const UnitsTile({
Key? key,
this.icon,
required this.title,
required this.unitName,
required this.hasSwich,
required this.voidCallback,
this.image,
}) : super(key: key);
@override
UnitsTileState createState() => UnitsTileState();
}
class UnitsTileState extends ConsumerState<UnitsTile> {
@override
Widget build(BuildContext context) {
return Column(
children: [
Container(
margin: const EdgeInsets.symmetric(vertical: 8),
padding: const EdgeInsets.symmetric(vertical: 15),
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
stops: [0.3, 1],
colors: <Color>[Colors.black, Colors.black12]),
),
//color: Color(0xFF0D113F),
child: ListTile(
contentPadding:
const EdgeInsets.symmetric(vertical: 17, horizontal: 24),
leading: widget.icon != null
? Icon(
widget.icon,
color: AGLDemoColors.periwinkleColor,
size: 48,
)
: Padding(
padding: const EdgeInsets.only(right: 24),
child: SvgPicture.asset(
widget.image!,
width: 48,
height: 48,
),
),
title: Text(
widget.title,
style: TextStyle(
color: AGLDemoColors.periwinkleColor,
shadows: [
Helpers.dropShadowRegular,
],
fontSize: 40),
),
trailing: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(
widget.unitName,
style: TextStyle(
color: AGLDemoColors.periwinkleColor,
shadows: [
Helpers.dropShadowRegular,
],
fontSize: 40,
),
),
const SizedBox(
width: 24,
),
const Icon(
Icons.arrow_forward_ios,
color: AGLDemoColors.periwinkleColor,
size: 48,
),
],
),
onTap: widget.voidCallback,
),
),
const SizedBox(
height: 8,
)
],
);
}
}
|