1
1
import 'package:flutter/material.dart' ;
2
2
import 'package:flutter_bloc/flutter_bloc.dart' ;
3
+ import 'package:material_symbols_icons/symbols.dart' ;
4
+ import 'package:morazan/pages/charts/charts_widget.dart' ;
3
5
import 'package:morazan/util/app_theme.dart' ;
4
6
import 'package:morazan/pages/satelites/satelites_widget.dart' ;
5
7
import 'package:morazan/util/constants.dart' ;
6
8
import 'package:morazan/util/language.dart' ;
7
9
import 'package:string_capitalize/string_capitalize.dart' ;
8
- import 'package:morazan/pages/base /about_widget.dart' ;
10
+ import 'package:morazan/pages/about /about_widget.dart' ;
9
11
10
12
import 'package:flutter_gen/gen_l10n/app_localizations.dart' ;
11
13
import 'package:morazan/locale_bloc/locale_bloc.dart' ;
@@ -21,7 +23,7 @@ class _BaseWidgetState extends State<BaseWidget> {
21
23
static const _satelites = Satelites .values;
22
24
var _actualSatelite = _satelites[0 ];
23
25
var _themeMode = ThemeMode .system;
24
- DateTime ? _lastUpdate ;
26
+ var _actualPage = 0 ;
25
27
26
28
@override
27
29
Widget build (BuildContext context) {
@@ -44,17 +46,16 @@ class _BaseWidgetState extends State<BaseWidget> {
44
46
theme: AppTheme .lightTheme,
45
47
darkTheme: AppTheme .darkTheme,
46
48
themeMode: _themeMode,
47
- routes: {
48
- '/AboutPage' : (context) => AboutPage (),
49
- },
50
49
home: Scaffold (
51
50
appBar: AppBar (
52
51
title: Builder (builder: (context) {
53
52
return Row (
54
53
mainAxisAlignment: MainAxisAlignment .spaceBetween,
55
54
children: [
56
55
Text (
57
- " ${l10n .testMedium } ${_actualSatelite .name .capitalize ()}" ),
56
+ "${l10n .testMedium } ${_actualSatelite .name .capitalize ()}" ,
57
+ style: const TextStyle (fontSize: 20 ),
58
+ ),
58
59
BlocBuilder <LocaleBloc , LocaleState >(
59
60
builder: (context, state) {
60
61
return _buildLanguageSwitch (
@@ -64,13 +65,6 @@ class _BaseWidgetState extends State<BaseWidget> {
64
65
);
65
66
},
66
67
),
67
- TextButton (
68
- onPressed: () {
69
- Navigator .pushNamed (context, "/AboutPage" );
70
- },
71
- child:
72
- Icon (Icons .info, size: 20 , color: colorScheme.onPrimary),
73
- ),
74
68
TextButton (
75
69
onPressed: () {
76
70
setState (() {
@@ -80,7 +74,7 @@ class _BaseWidgetState extends State<BaseWidget> {
80
74
});
81
75
},
82
76
child:
83
- Icon (themeIcon, size: 20 , color: colorScheme.onPrimary),
77
+ Icon (themeIcon, size: 15 , color: colorScheme.onPrimary),
84
78
),
85
79
],
86
80
);
@@ -89,31 +83,48 @@ class _BaseWidgetState extends State<BaseWidget> {
89
83
body: Padding (
90
84
padding: const EdgeInsets .all (8.0 ),
91
85
child: Column (
86
+ crossAxisAlignment: CrossAxisAlignment .stretch,
92
87
children: [
93
88
DropdownButtonHideUnderline (
94
89
child: DropdownButton (
95
90
value: _actualSatelite,
96
91
icon: Icon (Icons .expand_more,
97
92
size: 24 , color: colorScheme.outline),
98
- onChanged: (satelite) => setState (() {
99
- _actualSatelite = satelite! ;
100
- }),
93
+ onChanged: (satelite) =>
94
+ setState (() => _actualSatelite = satelite! ),
101
95
items: _satelites
102
- .map ((satelite) => DropdownMenuItem (
103
- value: satelite,
104
- child: Text (satelite.name.capitalize ()),
105
- ))
96
+ .map (
97
+ (satelite) => DropdownMenuItem (
98
+ value: satelite,
99
+ child: Text (satelite.name.capitalize ()),
100
+ ),
101
+ )
106
102
.toList (),
107
103
),
108
104
),
109
- Text ("Ultima Actualizacion ${_lastUpdate ?? '...' }" ),
110
- SatelitesPage (
111
- satelite: _actualSatelite,
112
- setLastUpdate: (lu) => _lastUpdate = lu,
113
- ),
105
+ switch (_actualPage) {
106
+ 0 => SatelitesPage (satelite: _actualSatelite),
107
+ 1 => ChartsPage (satelite: _actualSatelite),
108
+ 2 => const AboutPage (),
109
+ _ => throw RangeError ("The selected page not exists... already" )
110
+ },
114
111
],
115
112
),
116
113
),
114
+ bottomNavigationBar: BottomNavigationBar (
115
+ type: BottomNavigationBarType .shifting,
116
+ currentIndex: _actualPage,
117
+ onTap: (index) => setState (() => _actualPage = index),
118
+ selectedItemColor: colorScheme.onPrimary,
119
+ showUnselectedLabels: false ,
120
+ items: const [
121
+ BottomNavigationBarItem (
122
+ icon: Icon (Icons .settings_input_antenna), label: "Satelite" ),
123
+ BottomNavigationBarItem (
124
+ icon: Icon (Symbols .bar_chart_4_bars), label: "Graficos" ),
125
+ BottomNavigationBarItem (icon: Icon (Icons .info), label: "Info" ),
126
+ ],
127
+ ),
117
128
),
118
129
);
119
130
}
@@ -123,6 +134,8 @@ class _BaseWidgetState extends State<BaseWidget> {
123
134
ThemeData theme,
124
135
LocaleState state,
125
136
) {
137
+ var colorScheme = Theme .of (context).colorScheme;
138
+
126
139
return Stack (
127
140
children: [
128
141
Align (
@@ -141,31 +154,21 @@ class _BaseWidgetState extends State<BaseWidget> {
141
154
},
142
155
child: RichText (
143
156
text: TextSpan (children: [
144
- TextSpan (
145
- text: "EN" ,
146
- style: TextStyle (
147
- fontSize: 18 ,
148
- color: state.selectedLanguage == Language .english
149
- ? Colors .blue
150
- : const Color .fromARGB (255 , 251 , 250 , 250 ),
151
- ),
152
- ),
153
- const TextSpan (
154
- text: " | " ,
155
- style: TextStyle (
156
- fontSize: 18 ,
157
- color: Colors .black,
158
- ),
159
- ),
160
- TextSpan (
161
- text: "ES" ,
162
- style: TextStyle (
163
- fontSize: 18 ,
164
- color: state.selectedLanguage == Language .spanish
165
- ? Colors .blue
166
- : const Color .fromARGB (255 , 245 , 245 , 245 ),
167
- ),
168
- ),
157
+ state.selectedLanguage == Language .english
158
+ ? TextSpan (
159
+ text: "en" ,
160
+ style: TextStyle (
161
+ fontSize: 15 ,
162
+ color: colorScheme.onPrimary,
163
+ ),
164
+ )
165
+ : TextSpan (
166
+ text: "es" ,
167
+ style: TextStyle (
168
+ fontSize: 15 ,
169
+ color: colorScheme.onPrimary,
170
+ ),
171
+ ),
169
172
]),
170
173
),
171
174
),
0 commit comments