Skip to content

Commit 63136dc

Browse files
committed
Merge branch 'charts' into lenguaje
2 parents 9d42b62 + 2989041 commit 63136dc

12 files changed

+458
-97
lines changed

lib/api_requests/api_calls.dart

+23
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,26 @@ Future<SateliteInfo> fetchSateliteInfo(Satelites satelite) async {
2727
rethrow; // TODO: add a properly catch
2828
}
2929
}
30+
31+
Future<List<SateliteInfo>> fetchSateliteHistory(
32+
Satelites satelite, ChartRanges range) async {
33+
try {
34+
final res = await http.get(
35+
Uri.parse("${MorazanApi.apiBase}${satelite.name.capitalize()}/$range"));
36+
if (res.statusCode == 200) {
37+
var dataList = jsonDecode(res.body) as List<Map<String, dynamic>>;
38+
final sateliteInfo = dataList.map((data) => SateliteInfo.fromJson(data));
39+
return sateliteInfo.toList();
40+
} else {
41+
if (kDebugMode) {
42+
print("error en el fetch por ${res.statusCode}");
43+
}
44+
throw Exception(""); // TODO: add a properly exception
45+
}
46+
} catch (e) {
47+
if (kDebugMode) {
48+
print("error en el fetch por $e");
49+
}
50+
rethrow; // TODO: add a properly catch
51+
}
52+
}

lib/components/wind_widget.dart

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
import 'dart:math' as math;
23
import 'package:flutter/material.dart';
34
import 'package:material_symbols_icons/symbols.dart';
@@ -43,9 +44,11 @@ class Wind extends StatelessWidget {
4344
fontWeight: FontWeight.w900,
4445
fontSize: 10,
4546
),
46-
),TweenAnimationBuilder(
47-
tween: Tween<double>(begin: 0, end: _direction+0.0),
48-
duration: const Duration(milliseconds: 500), // Duración de la animación
47+
),
48+
TweenAnimationBuilder(
49+
tween: Tween<double>(begin: 0, end: _direction + 0.0),
50+
duration:
51+
const Duration(milliseconds: 500), // Duración de la animación
4952
builder: (context, double angle, child) {
5053
return Transform.rotate(
5154
angle: angle * math.pi / 180,

lib/pages/about/about_widget.dart

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import 'package:flutter/material.dart';
2+
3+
class AboutPage extends StatelessWidget {
4+
const AboutPage({super.key});
5+
6+
@override
7+
Widget build(BuildContext context) {
8+
return const Expanded(
9+
child: Center(
10+
child: Text(
11+
"Aplicacion del clima desarrollada por el Grupo 5 de practicas intermedias del 7mo semestre usando los sensores de CyT "),
12+
),
13+
);
14+
}
15+
}

lib/pages/base/about_widget.dart

-15
This file was deleted.

lib/pages/base/base_widget.dart

+54-51
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_bloc/flutter_bloc.dart';
3+
import 'package:material_symbols_icons/symbols.dart';
4+
import 'package:morazan/pages/charts/charts_widget.dart';
35
import 'package:morazan/util/app_theme.dart';
46
import 'package:morazan/pages/satelites/satelites_widget.dart';
57
import 'package:morazan/util/constants.dart';
68
import 'package:morazan/util/language.dart';
79
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';
911

1012
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
1113
import 'package:morazan/locale_bloc/locale_bloc.dart';
@@ -21,7 +23,7 @@ class _BaseWidgetState extends State<BaseWidget> {
2123
static const _satelites = Satelites.values;
2224
var _actualSatelite = _satelites[0];
2325
var _themeMode = ThemeMode.system;
24-
DateTime? _lastUpdate;
26+
var _actualPage = 0;
2527

2628
@override
2729
Widget build(BuildContext context) {
@@ -44,17 +46,16 @@ class _BaseWidgetState extends State<BaseWidget> {
4446
theme: AppTheme.lightTheme,
4547
darkTheme: AppTheme.darkTheme,
4648
themeMode: _themeMode,
47-
routes: {
48-
'/AboutPage': (context) => AboutPage(),
49-
},
5049
home: Scaffold(
5150
appBar: AppBar(
5251
title: Builder(builder: (context) {
5352
return Row(
5453
mainAxisAlignment: MainAxisAlignment.spaceBetween,
5554
children: [
5655
Text(
57-
" ${l10n.testMedium} ${_actualSatelite.name.capitalize()}"),
56+
"${l10n.testMedium} ${_actualSatelite.name.capitalize()}",
57+
style: const TextStyle(fontSize: 20),
58+
),
5859
BlocBuilder<LocaleBloc, LocaleState>(
5960
builder: (context, state) {
6061
return _buildLanguageSwitch(
@@ -64,13 +65,6 @@ class _BaseWidgetState extends State<BaseWidget> {
6465
);
6566
},
6667
),
67-
TextButton(
68-
onPressed: () {
69-
Navigator.pushNamed(context, "/AboutPage");
70-
},
71-
child:
72-
Icon(Icons.info, size: 20, color: colorScheme.onPrimary),
73-
),
7468
TextButton(
7569
onPressed: () {
7670
setState(() {
@@ -80,7 +74,7 @@ class _BaseWidgetState extends State<BaseWidget> {
8074
});
8175
},
8276
child:
83-
Icon(themeIcon, size: 20, color: colorScheme.onPrimary),
77+
Icon(themeIcon, size: 15, color: colorScheme.onPrimary),
8478
),
8579
],
8680
);
@@ -89,31 +83,48 @@ class _BaseWidgetState extends State<BaseWidget> {
8983
body: Padding(
9084
padding: const EdgeInsets.all(8.0),
9185
child: Column(
86+
crossAxisAlignment: CrossAxisAlignment.stretch,
9287
children: [
9388
DropdownButtonHideUnderline(
9489
child: DropdownButton(
9590
value: _actualSatelite,
9691
icon: Icon(Icons.expand_more,
9792
size: 24, color: colorScheme.outline),
98-
onChanged: (satelite) => setState(() {
99-
_actualSatelite = satelite!;
100-
}),
93+
onChanged: (satelite) =>
94+
setState(() => _actualSatelite = satelite!),
10195
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+
)
106102
.toList(),
107103
),
108104
),
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+
},
114111
],
115112
),
116113
),
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+
),
117128
),
118129
);
119130
}
@@ -123,6 +134,8 @@ class _BaseWidgetState extends State<BaseWidget> {
123134
ThemeData theme,
124135
LocaleState state,
125136
) {
137+
var colorScheme = Theme.of(context).colorScheme;
138+
126139
return Stack(
127140
children: [
128141
Align(
@@ -141,31 +154,21 @@ class _BaseWidgetState extends State<BaseWidget> {
141154
},
142155
child: RichText(
143156
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+
),
169172
]),
170173
),
171174
),

0 commit comments

Comments
 (0)