mirror of
https://github.com/darkmoonight/Rain.git
synced 2025-06-28 12:09:57 +00:00
Add new form create_card_weather
This commit is contained in:
parent
33ceb30885
commit
fc246ac5a2
6 changed files with 95 additions and 83 deletions
|
@ -4,6 +4,7 @@ import 'package:iconsax/iconsax.dart';
|
|||
import 'package:rain/app/api/api.dart';
|
||||
import 'package:rain/app/api/city.dart';
|
||||
import 'package:rain/app/controller/controller.dart';
|
||||
import 'package:rain/app/widgets/button.dart';
|
||||
import 'package:rain/app/widgets/text_form.dart';
|
||||
import 'package:rain/main.dart';
|
||||
|
||||
|
@ -61,50 +62,13 @@ class _CreateWeatherCardState extends State<CreateWeatherCard> {
|
|||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(10, 10, 10, 0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
},
|
||||
icon: const Icon(
|
||||
Iconsax.close_square,
|
||||
size: 18,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'create'.tr,
|
||||
style: context.textTheme.titleLarge?.copyWith(
|
||||
fontSize: 20,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () async {
|
||||
if (formKey.currentState!.validate()) {
|
||||
textTrim(_controllerLat);
|
||||
textTrim(_controllerLon);
|
||||
textTrim(_controllerCity);
|
||||
textTrim(_controllerDistrict);
|
||||
setState(() => isLoading = true);
|
||||
await weatherController.addCardWeather(
|
||||
double.parse(_controllerLat.text),
|
||||
double.parse(_controllerLon.text),
|
||||
_controllerCity.text,
|
||||
_controllerDistrict.text,
|
||||
);
|
||||
setState(() => isLoading = false);
|
||||
Get.back();
|
||||
}
|
||||
},
|
||||
icon: const Icon(
|
||||
Iconsax.tick_square,
|
||||
size: 18,
|
||||
),
|
||||
),
|
||||
],
|
||||
padding: const EdgeInsets.fromLTRB(10, 15, 10, 5),
|
||||
child: Text(
|
||||
'create'.tr,
|
||||
style: context.textTheme.titleLarge?.copyWith(
|
||||
fontSize: 20,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
RawAutocomplete<Result>(
|
||||
|
@ -120,8 +84,8 @@ class _CreateWeatherCardState extends State<CreateWeatherCard> {
|
|||
type: TextInputType.text,
|
||||
icon: const Icon(Iconsax.global_search),
|
||||
controller: _controller,
|
||||
margin:
|
||||
const EdgeInsets.only(left: 10, right: 10, top: 10),
|
||||
margin: const EdgeInsets.only(
|
||||
left: 10, right: 10, top: 10),
|
||||
focusNode: _focusNode,
|
||||
);
|
||||
},
|
||||
|
@ -132,7 +96,8 @@ class _CreateWeatherCardState extends State<CreateWeatherCard> {
|
|||
return WeatherAPI()
|
||||
.getCity(textEditingValue.text, locale);
|
||||
},
|
||||
onSelected: (Result selection) => fillController(selection),
|
||||
onSelected: (Result selection) =>
|
||||
fillController(selection),
|
||||
displayStringForOption: (Result option) =>
|
||||
'${option.name}, ${option.admin1}',
|
||||
optionsViewBuilder: (BuildContext context,
|
||||
|
@ -150,7 +115,8 @@ class _CreateWeatherCardState extends State<CreateWeatherCard> {
|
|||
shrinkWrap: true,
|
||||
itemCount: options.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final Result option = options.elementAt(index);
|
||||
final Result option =
|
||||
options.elementAt(index);
|
||||
return InkWell(
|
||||
onTap: () => onSelected(option),
|
||||
child: ListTile(
|
||||
|
@ -173,7 +139,9 @@ class _CreateWeatherCardState extends State<CreateWeatherCard> {
|
|||
labelText: 'lat'.tr,
|
||||
type: TextInputType.number,
|
||||
icon: const Icon(Iconsax.location),
|
||||
margin: const EdgeInsets.only(left: 10, right: 10, top: 10),
|
||||
onChanged: (value) => setState(() {}),
|
||||
margin:
|
||||
const EdgeInsets.only(left: 10, right: 10, top: 10),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'validateValue'.tr;
|
||||
|
@ -194,7 +162,9 @@ class _CreateWeatherCardState extends State<CreateWeatherCard> {
|
|||
labelText: 'lon'.tr,
|
||||
type: TextInputType.number,
|
||||
icon: const Icon(Iconsax.location),
|
||||
margin: const EdgeInsets.only(left: 10, right: 10, top: 10),
|
||||
onChanged: (value) => setState(() {}),
|
||||
margin:
|
||||
const EdgeInsets.only(left: 10, right: 10, top: 10),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'validateValue'.tr;
|
||||
|
@ -215,7 +185,9 @@ class _CreateWeatherCardState extends State<CreateWeatherCard> {
|
|||
labelText: 'city'.tr,
|
||||
type: TextInputType.name,
|
||||
icon: const Icon(Icons.location_city_rounded),
|
||||
margin: const EdgeInsets.only(left: 10, right: 10, top: 10),
|
||||
onChanged: (value) => setState(() {}),
|
||||
margin:
|
||||
const EdgeInsets.only(left: 10, right: 10, top: 10),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'validateName'.tr;
|
||||
|
@ -229,7 +201,9 @@ class _CreateWeatherCardState extends State<CreateWeatherCard> {
|
|||
labelText: 'district'.tr,
|
||||
type: TextInputType.streetAddress,
|
||||
icon: const Icon(Iconsax.global),
|
||||
margin: const EdgeInsets.only(left: 10, right: 10, top: 10),
|
||||
onChanged: (value) => setState(() {}),
|
||||
margin:
|
||||
const EdgeInsets.only(left: 10, right: 10, top: 10),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'validateName'.tr;
|
||||
|
@ -237,7 +211,36 @@ class _CreateWeatherCardState extends State<CreateWeatherCard> {
|
|||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 10, vertical: 10),
|
||||
child: Visibility(
|
||||
visible: _controllerLon.text.isNotEmpty &&
|
||||
_controllerLat.text.isNotEmpty &&
|
||||
_controllerCity.text.isNotEmpty &&
|
||||
_controllerDistrict.text.isNotEmpty,
|
||||
child: MyTextButton(
|
||||
buttonName: 'done'.tr,
|
||||
onPressed: () async {
|
||||
if (formKey.currentState!.validate()) {
|
||||
textTrim(_controllerLat);
|
||||
textTrim(_controllerLon);
|
||||
textTrim(_controllerCity);
|
||||
textTrim(_controllerDistrict);
|
||||
setState(() => isLoading = true);
|
||||
await weatherController.addCardWeather(
|
||||
double.parse(_controllerLat.text),
|
||||
double.parse(_controllerLon.text),
|
||||
_controllerCity.text,
|
||||
_controllerDistrict.text,
|
||||
);
|
||||
setState(() => isLoading = false);
|
||||
Get.back();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
@ -8,7 +8,7 @@ class MyTextButton extends StatelessWidget {
|
|||
required this.onPressed,
|
||||
});
|
||||
final String buttonName;
|
||||
final VoidCallback onPressed;
|
||||
final VoidCallback? onPressed;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -16,6 +16,11 @@ class MyTextButton extends StatelessWidget {
|
|||
height: 50,
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
style: ButtonStyle(
|
||||
shadowColor: const WidgetStatePropertyAll(Colors.transparent),
|
||||
backgroundColor: WidgetStatePropertyAll(
|
||||
context.theme.colorScheme.secondaryContainer.withAlpha(80)),
|
||||
),
|
||||
onPressed: onPressed,
|
||||
child: Text(
|
||||
buttonName,
|
||||
|
|
50
pubspec.lock
50
pubspec.lock
|
@ -355,18 +355,18 @@ packages:
|
|||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_local_notifications
|
||||
sha256: "0a9068149f0225e81642b03562e99776106edbd967816ee68bc16310d457c60e"
|
||||
sha256: dd6676d8c2926537eccdf9f72128bbb2a9d0814689527b17f92c248ff192eaf3
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "17.2.1+1"
|
||||
version: "17.2.1+2"
|
||||
flutter_local_notifications_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_local_notifications_linux
|
||||
sha256: "33f741ef47b5f63cc7f78fe75eeeac7e19f171ff3c3df054d84c1e38bedb6a03"
|
||||
sha256: c49bd06165cad9beeb79090b18cd1eb0296f4bf4b23b84426e37dd7c027fc3af
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.0.0+1"
|
||||
version: "4.0.1"
|
||||
flutter_local_notifications_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -397,10 +397,10 @@ packages:
|
|||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_timezone
|
||||
sha256: f9c328f66d58cd2af8a0cbd2f84d0c211fda8b7332b5e458d9848bd9ec936120
|
||||
sha256: "0cb5498dedfaac615c779138194052f04524c31d958fab33d378f22b6cc14686"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
version: "2.1.0"
|
||||
flutter_web_plugins:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
|
@ -418,10 +418,10 @@ packages:
|
|||
dependency: "direct main"
|
||||
description:
|
||||
name: freezed_annotation
|
||||
sha256: f9f6597ac43cc262fa7d7f2e65259a6060c23a560525d1f2631be374540f2a9b
|
||||
sha256: c2e2d632dd9b8a2b7751117abcfc2b4888ecfe181bd9fca7170d9ef02e595fe2
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.3"
|
||||
version: "2.4.4"
|
||||
frontend_server_client:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -538,10 +538,10 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: graphs
|
||||
sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19
|
||||
sha256: "741bbf84165310a68ff28fe9e727332eef1407342fca52759cb21ad8177bb8d0"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.1"
|
||||
version: "2.3.2"
|
||||
home_widget:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -562,10 +562,10 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: http
|
||||
sha256: "761a297c042deedc1ffbb156d6e2af13886bb305c2a343a4d972504cd67dd938"
|
||||
sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.1"
|
||||
version: "1.2.2"
|
||||
http_multi_server:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -1063,18 +1063,18 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_android
|
||||
sha256: ceb2625f0c24ade6ef6778d1de0b2e44f2db71fded235eb52295247feba8c5cf
|
||||
sha256: "95d8027db36a0e52caf55680f91e33ea6aa12a3ce608c90b06f4e429a21067ac"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.3.3"
|
||||
version: "6.3.5"
|
||||
url_launcher_ios:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_ios
|
||||
sha256: "7068716403343f6ba4969b4173cbf3b84fc768042124bc2c011e5d782b24fe89"
|
||||
sha256: e43b677296fadce447e987a2f519dcf5f6d1e527dc35d01ffab4fff5b8a7063e
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.3.0"
|
||||
version: "6.3.1"
|
||||
url_launcher_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -1111,18 +1111,18 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_windows
|
||||
sha256: ecf9725510600aa2bb6d7ddabe16357691b6d2805f66216a97d1b881e21beff7
|
||||
sha256: "49c10f879746271804767cb45551ec5592cdab00ee105c06dddde1a98f73b185"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.1"
|
||||
version: "3.1.2"
|
||||
uuid:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: uuid
|
||||
sha256: "814e9e88f21a176ae1359149021870e87f7cddaf633ab678a5d2b0bff7fd1ba8"
|
||||
sha256: "83d37c7ad7aaf9aa8e275490669535c8080377cfa7a7004c24dfac53afffaa90"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.4.0"
|
||||
version: "4.4.2"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -1159,18 +1159,18 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: web_socket
|
||||
sha256: "24301d8c293ce6fe327ffe6f59d8fd8834735f0ec36e4fd383ec7ff8a64aa078"
|
||||
sha256: "3c12d96c0c9a4eec095246debcea7b86c0324f22df69893d538fcc6f1b8cce83"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.1.5"
|
||||
version: "0.1.6"
|
||||
web_socket_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: web_socket_channel
|
||||
sha256: a2d56211ee4d35d9b344d9d4ce60f362e4f5d1aafb988302906bd732bc731276
|
||||
sha256: "9f187088ed104edd8662ca07af4b124465893caf063ba29758f97af57e61da8f"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.0"
|
||||
version: "3.0.1"
|
||||
win32:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -1228,5 +1228,5 @@ packages:
|
|||
source: hosted
|
||||
version: "3.1.2"
|
||||
sdks:
|
||||
dart: ">=3.4.3 <4.0.0"
|
||||
dart: ">=3.4.4 <4.0.0"
|
||||
flutter: ">=3.22.0"
|
||||
|
|
|
@ -6,7 +6,7 @@ publish_to: "none"
|
|||
version: 1.3.4+37
|
||||
|
||||
environment:
|
||||
sdk: ">=3.4.3 <4.0.0"
|
||||
sdk: ">=3.4.4 <4.0.0"
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
|
@ -36,11 +36,11 @@ dependencies:
|
|||
path_provider: ^2.1.3
|
||||
# quick_settings: ^1.0.1
|
||||
json_annotation: ^4.9.0
|
||||
flutter_timezone: ^2.0.1
|
||||
flutter_timezone: ^2.1.0
|
||||
device_info_plus: ^10.1.0
|
||||
package_info_plus: ^8.0.0
|
||||
connectivity_plus: ^6.0.3
|
||||
freezed_annotation: ^2.4.3
|
||||
freezed_annotation: ^2.4.4
|
||||
isar_flutter_libs:
|
||||
version: ^3.1.7
|
||||
hosted: https://pub.isar-community.dev/
|
||||
|
@ -49,7 +49,7 @@ dependencies:
|
|||
# font_awesome_flutter: ^10.7.0
|
||||
flutter_hsvcolor_picker: ^1.5.1
|
||||
scrollable_positioned_list: ^0.3.8
|
||||
flutter_local_notifications: ^17.2.1+1
|
||||
flutter_local_notifications: ^17.2.1+2
|
||||
internet_connection_checker_plus: ^2.5.0
|
||||
|
||||
# Uncomment this for publishing FLOSS variant
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <connectivity_plus/connectivity_plus_windows_plugin.h>
|
||||
#include <dynamic_color/dynamic_color_plugin_c_api.h>
|
||||
#include <flutter_timezone/flutter_timezone_plugin_c_api.h>
|
||||
#include <geolocator_windows/geolocator_windows.h>
|
||||
#include <isar_flutter_libs/isar_flutter_libs_plugin.h>
|
||||
#include <url_launcher_windows/url_launcher_windows.h>
|
||||
|
@ -17,6 +18,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
|
|||
registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin"));
|
||||
DynamicColorPluginCApiRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("DynamicColorPluginCApi"));
|
||||
FlutterTimezonePluginCApiRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("FlutterTimezonePluginCApi"));
|
||||
GeolocatorWindowsRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("GeolocatorWindows"));
|
||||
IsarFlutterLibsPluginRegisterWithRegistrar(
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
connectivity_plus
|
||||
dynamic_color
|
||||
flutter_timezone
|
||||
geolocator_windows
|
||||
isar_flutter_libs
|
||||
url_launcher_windows
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue