From b114e4f6a26a9c9fb44cf0d8bb2791497159dc68 Mon Sep 17 00:00:00 2001 From: Kate Kuehl Date: Fri, 27 Oct 2023 18:54:19 -0500 Subject: [PATCH 1/2] Add base of deployment page --- lib/deployment_page.dart | 123 ++++++++++++++++++++++++ lib/l10n/app_en.arb | 17 +++- lib/l10n/app_es.arb | 17 +++- lib/view_station/view_station_page.dart | 29 ++++-- pubspec.yaml | 1 + 5 files changed, 179 insertions(+), 8 deletions(-) create mode 100644 lib/deployment_page.dart diff --git a/lib/deployment_page.dart b/lib/deployment_page.dart new file mode 100644 index 00000000..081a0810 --- /dev/null +++ b/lib/deployment_page.dart @@ -0,0 +1,123 @@ +import 'package:flutter/material.dart'; +import 'package:fk/map_widget.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:fk/constants.dart'; +import 'package:fk/app_state.dart'; +import 'package:action_slider/action_slider.dart'; + +class DeploymentPage extends StatefulWidget { + final StationModel station; + + DeploymentPage({super.key, required this.station}); + + @override + _MyDeploymentState createState() => _MyDeploymentState(); +} + +class _MyDeploymentState extends State { + String dropdownValue = 'Seconds'; + double sliderValue = 0; + String sliderLabel = 'Basic'; + TextEditingController nameController = TextEditingController(); + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Text('Deployment', + style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold)), + IconButton( + icon: const Icon(Icons.close), + onPressed: () => Navigator.pop(context), + ), + ], + ), + const SizedBox(height: 20), + Text(widget.station.config!.name, + style: + const TextStyle(fontSize: 18, fontWeight: FontWeight.bold)), + const SizedBox(height: 200, child: Map()), + const SizedBox(height: 10), + Text(AppLocalizations.of(context)!.nameYourLocation, + style: + const TextStyle(fontSize: 16, fontWeight: FontWeight.bold)), + TextField( + controller: nameController, + decoration: InputDecoration( + hintText: AppLocalizations.of(context)!.enterLocationHint), + ), + const SizedBox(height: 20), + Text(AppLocalizations.of(context)!.dataSchedule, + style: + const TextStyle(fontSize: 16, fontWeight: FontWeight.bold)), + const SizedBox(height: 10), + Text(AppLocalizations.of(context)!.frequencyWarning), + ActionSlider.dual(), + Slider( + value: sliderValue, + divisions: 1, + onChanged: (value) { + setState(() { + sliderValue = value; + sliderLabel = value == 0 + ? AppLocalizations.of(context)!.basicSlider + : AppLocalizations.of(context)!.scheduledSlider; + }); + }, + label: sliderLabel, + ), + sliderLabel == AppLocalizations.of(context)!.basicSlider + ? Row( + children: [ + Expanded( + child: TextField( + keyboardType: TextInputType.number, + decoration: InputDecoration( + labelText: + AppLocalizations.of(context)!.frequencyHint), + ), + ), + const SizedBox(width: 20), + DropdownButton( + value: dropdownValue, + onChanged: (String? newValue) { + setState(() { + dropdownValue = newValue!; + }); + }, + items: [ + AppLocalizations.of(context)!.seconds, + AppLocalizations.of(context)!.minutes, + AppLocalizations.of(context)!.hours, + AppLocalizations.of(context)!.days, + ].map>((String value) { + return DropdownMenuItem( + value: value, + child: Text(value), + ); + }).toList(), + ), + ], + ) + : Container(), // Placeholder for "Scheduled" UI + const SizedBox(height: 20), + ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: AppColors.primaryColor, + minimumSize: const Size(double.infinity, 40)), + onPressed: () { + // Add your continue button logic here + }, + child: Text(AppLocalizations.of(context)!.continueButton), + ), + ], + ), + ); + } +} diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 76b4ae38..348d8a96 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -124,5 +124,20 @@ "legalTitle": "Legal", "termsOfService": "Terms of Service", "privacyPolicy": "Privacy Policy", - "licenses": "Licenses" + "licenses": "Licenses", + + "fieldKitStation": "FieldKit Station", + "nameYourLocation": "Name your location", + "enterLocationHint": "Enter location name", + "frequencyWarning": "Frequent data capture drains the battery at a quicker rate", + "dataSchedule": "Data capture schedule", + + "continueButton": "Continue", + "basicSlider": "Basic", + "scheduledSlider": "Scheduled", + "frequencyHint": "Every", + "seconds": "Seconds", + "minutes": "Minutes", + "hours": "Hours", + "days": "Days" } diff --git a/lib/l10n/app_es.arb b/lib/l10n/app_es.arb index 0439a043..754587f0 100644 --- a/lib/l10n/app_es.arb +++ b/lib/l10n/app_es.arb @@ -113,5 +113,20 @@ "legalTitle": "Legal", "termsOfService": "Terms of Service", "privacyPolicy": "Privacy Policy", - "licenses": "Licenses" + "licenses": "Licenses", + + "fieldKitStation": "FieldKit Station", + "nameYourLocation": "Name your location", + "enterLocationHint": "Enter location name", + "frequencyWarning": "Frequent data capture drains the battery at a quicker rate", + "dataSchedule": "Data capture schedule", + + "continueButton": "Continue", + "basicSlider": "Basic", + "scheduledSlider": "Scheduled", + "frequencyHint": "Every", + "seconds": "Seconds", + "minutes": "Minutes", + "hours": "Hours", + "days": "Days" } diff --git a/lib/view_station/view_station_page.dart b/lib/view_station/view_station_page.dart index a79f9d1c..5ac1e442 100644 --- a/lib/view_station/view_station_page.dart +++ b/lib/view_station/view_station_page.dart @@ -9,6 +9,7 @@ import '../meta.dart'; import '../unknown_station_page.dart'; import 'configure_station.dart'; import 'sensor_widgets.dart'; +import '../deployment_page.dart'; class ViewStationRoute extends StatelessWidget { final String deviceId; @@ -48,11 +49,13 @@ class ViewStationPage extends StatelessWidget { Navigator.push( context, MaterialPageRoute( - builder: (context) => ConfigureStationRoute(deviceId: station.deviceId), + builder: (context) => + ConfigureStationRoute(deviceId: station.deviceId), ), ); }, - child: Text(AppLocalizations.of(context)!.configureButton, style: const TextStyle(color: Colors.white))) + child: Text(AppLocalizations.of(context)!.configureButton, + style: const TextStyle(color: Colors.white))) ], ), body: ListView(children: [ @@ -86,7 +89,8 @@ class HighLevelsDetails extends StatelessWidget { }).toList(); var circle = Container( - decoration: const BoxDecoration(color: Colors.black, shape: BoxShape.circle), + decoration: + const BoxDecoration(color: Colors.black, shape: BoxShape.circle), alignment: Alignment.center, child: const Text( "00:00:00", @@ -104,11 +108,14 @@ class HighLevelsDetails extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.start, children: [ ListTile( - leading: Image.asset("resources/images/battery/normal_40.png", cacheWidth: 16), + leading: Image.asset( + "resources/images/battery/normal_40.png", + cacheWidth: 16), title: Text(AppLocalizations.of(context)!.batteryLife), subtitle: Text("$battery%")), ListTile( - leading: Image.asset("resources/images/memory/icon.png", cacheWidth: 16), + leading: Image.asset("resources/images/memory/icon.png", + cacheWidth: 16), title: Text(AppLocalizations.of(context)!.memoryUsage), subtitle: Text("${bytesUsed}b of 512MB")), ], @@ -117,7 +124,17 @@ class HighLevelsDetails extends StatelessWidget { Container( padding: const EdgeInsets.all(10), width: double.infinity, - child: ElevatedButton(onPressed: () {}, child: Text(AppLocalizations.of(context)!.deployButton)), + child: ElevatedButton( + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => DeploymentPage(station: station), + ), + ); + }, + child: Text(AppLocalizations.of(context)!.deployButton), + ), ), Column(children: modules) ], diff --git a/pubspec.yaml b/pubspec.yaml index b83fa97a..4332cb7d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -76,6 +76,7 @@ dependencies: shared_preferences: ^2.2.1 flutter_map_location_marker: ^5.3.0 package_info_plus: ^4.2.0 + action_slider: ^0.7.0 dev_dependencies: flutter_test: -- GitLab From d170a31b4d3b0f86cdd640bd44a8a4cd78c4a370 Mon Sep 17 00:00:00 2001 From: Jacob Lewallen Date: Tue, 18 Jun 2024 09:40:17 -0700 Subject: [PATCH 2/2] Wire up "new" deployment page to route. --- lib/deploy/deploy_page.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/deploy/deploy_page.dart b/lib/deploy/deploy_page.dart index c9b13131..d5898b2b 100644 --- a/lib/deploy/deploy_page.dart +++ b/lib/deploy/deploy_page.dart @@ -1,6 +1,7 @@ import 'package:fk/app_state.dart'; import 'package:fk/common_widgets.dart'; import 'package:fk/deploy/configure_schedule_page.dart'; +import 'package:fk/deployment_page.dart'; import 'package:fk/diagnostics.dart'; import 'package:fk/gen/api.dart'; import 'package:fk/map_widget.dart'; @@ -135,7 +136,7 @@ class DeployStationRoute extends StatelessWidget { return const NoSuchStationPage(); } else { return StationProviders( - deviceId: deviceId, child: DeployStationPage(station: station)); + deviceId: deviceId, child: DeploymentPage(station: station)); } }, ); -- GitLab