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
|
import 'package:flutter_ics_homescreen/export.dart';
class TemperatureUnitPage extends ConsumerWidget {
const TemperatureUnitPage({super.key});
static Page<void> page() =>
const MaterialPage<void>(child: TemperatureUnitPage());
@override
Widget build(BuildContext context, WidgetRef ref) {
final unit =
ref.watch(unitStateProvider.select((unit) => unit.temperatureUnit));
return Scaffold(
body: Column(
children: [
CommonTitle(
title: 'Temperature',
hasBackButton: true,
onPressed: () {
context.flow<AppState>().update((state) => AppState.units);
},
),
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 0, horizontal: 144),
child: ListView(
children: [
Container(
height: 130,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
stops: unit == TemperatureUnit.celsius
? [0, 0.01, 0.8]
: [0.1, 1],
colors: unit == TemperatureUnit.celsius
? <Color>[
Colors.white,
Colors.blue,
const Color.fromARGB(16, 41, 98, 255)
]
: <Color>[Colors.black, Colors.black12]),
),
child: ListTile(
minVerticalPadding: 0.0,
contentPadding: const EdgeInsets.symmetric(
horizontal: 16.0, vertical: 40.0),
leading: Text(
'Celsius',
style: Theme.of(context).textTheme.titleMedium,
),
//title: Text(widget.title),
//enabled: isSwitchOn,
trailing: unit == TemperatureUnit.celsius
? const Icon(Icons.done,
color: AGLDemoColors.periwinkleColor,
size: 48,
)
: null,
onTap: () {
ref
.read(unitStateProvider.notifier)
.setTemperatureUnit(TemperatureUnit.celsius);
}),
),
const SizedBox(
height: 5,
),
Container(
height: 130,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
stops: unit == TemperatureUnit.fahrenheit
? [0, 0.01, 0.8]
: [0.1, 1],
colors: unit == TemperatureUnit.fahrenheit
? <Color>[
Colors.white,
Colors.blue,
const Color.fromARGB(16, 41, 98, 255)
]
: <Color>[Colors.black, Colors.black12]),
),
child: ListTile(
minVerticalPadding: 0.0,
contentPadding: const EdgeInsets.symmetric(
horizontal: 16.0, vertical: 40.0),
leading: Text(
'Fahrenheit',
style: Theme.of(context).textTheme.titleMedium,
),
//title: Text(widget.title),
//enabled: isSwitchOn,
trailing: unit == TemperatureUnit.fahrenheit
? const Icon(Icons.done,
color: AGLDemoColors.periwinkleColor,
size: 38,
)
: null,
onTap: () {
ref
.read(unitStateProvider.notifier)
.setTemperatureUnit(TemperatureUnit.fahrenheit);
},
),
),
],
),
),
),
],
),
);
}
}
|