-
Notifications
You must be signed in to change notification settings - Fork 0
/
navigation_menu.dart
175 lines (164 loc) · 5.58 KB
/
navigation_menu.dart
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
172
173
174
175
import 'package:dotted_border/dotted_border.dart';
import 'package:flutter/material.dart';
import 'model/medicaments.dart';
import 'screens/home_screen.dart';
import 'screens/stock_screen.dart';
import 'package:app/screens/control_center.dart';
import 'package:app/database/local_medicament_stock.dart';
class NavigationMenu extends StatefulWidget {
const NavigationMenu({super.key});
@override
NavigationMenuState createState() => NavigationMenuState();
}
class NavigationMenuState extends State<NavigationMenu> {
late Future<List<Medicament>> _medicamentList;
Future<List<Medicament>> getMedicaments() async {
return await MedicamentStock().getMedicaments();
}
void refreshStockList() {
setState(() {
_medicamentList = getMedicaments();
});
}
void _refreshHomeScreenOnReminderSaved() {
setState(() {});
}
int selectedIndex = 0;
List<Widget> get screens => [
HomeScreen(onReminderSaved: _refreshHomeScreenOnReminderSaved),
StockScreen(selectionMode: false, medicamentList: _medicamentList, onMedicamentListUpdated: refreshStockList,),
];
void onItemTapped(int index) {
setState(() {
selectedIndex = index;
if (selectedIndex == 1) refreshStockList();
});
}
@override
void initState() {
super.initState();
refreshStockList();
}
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
extendBodyBehindAppBar: true,
extendBody: true,
appBar: AppBar(
elevation: 0,
backgroundColor: Colors.transparent,
),
body: IndexedStack(
index: selectedIndex,
children: screens,
),
floatingActionButton: Stack(
children: [
Positioned(
bottom: kBottomNavigationBarHeight + 10,
left: (MediaQuery.of(context).size.width - 150) / 2,
child: MaterialButton(
onPressed: null,
elevation: 0,
highlightElevation: 0,
color: Colors.transparent,
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
child: Image.asset(
'assets/icons/pingu-transparent-shadow.png',
width: 120,
height: 120,
),
),
),
],
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
bottomNavigationBar: SizedBox(
height: 83,
child: Container(
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30),
topRight: Radius.circular(30),
),
boxShadow: [
BoxShadow(
color: Color.fromRGBO(0, 0, 0, 0.1),
blurRadius: 14,
offset: Offset(0, -1),
)
],
),
child: BottomAppBar(
elevation: 0,
color: Colors.transparent,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Padding(
padding: const EdgeInsets.only(bottom: 10),
child: IconButton(
icon: ColorFiltered(
colorFilter: ColorFilter.mode(
selectedIndex == 0 ? const Color.fromRGBO(185, 137, 102, 1) : const Color.fromRGBO(230, 217, 206, 1),
BlendMode.srcIn,
),
child: Image.asset(
'assets/icons/pills_icon_2.png',
width: 31,
height: 31,
),
),
onPressed: () => onItemTapped(0),
highlightColor: Colors.transparent,
),
),
Padding(
padding: const EdgeInsets.only(bottom: 10),
child: DottedBorder(
borderType: BorderType.RRect,
radius: const Radius.circular(15),
padding: const EdgeInsets.all(6),
color: const Color.fromRGBO(225, 95, 0, 1),
child: IconButton(
icon: const Icon(
Icons.add,
color: Color.fromRGBO(225, 95, 0, 1),
size: 24,
),
onPressed: () {
showControlCenter(context, _refreshHomeScreenOnReminderSaved, _medicamentList, refreshStockList);
},
),
),
),
Padding(
padding: const EdgeInsets.only(bottom: 10),
child: IconButton(
key: const Key('stock screen button'),
icon: ColorFiltered(
colorFilter: ColorFilter.mode(
selectedIndex == 1 ? const Color.fromRGBO(185, 137, 102, 1) : const Color.fromRGBO(230, 217, 206, 1),
BlendMode.srcIn,
),
child: Image.asset(
'assets/icons/box_icon.png',
width: 32,
height: 32,
),
),
onPressed: () => onItemTapped(1),
highlightColor: Colors.transparent,
),
),
],
),
),
),
),
);
}
}