From 2aa58f3a50a6b5c800514902e697e2fc71f7e7f4 Mon Sep 17 00:00:00 2001 From: Shuktika Mahanty <53374048+Shuktika15@users.noreply.github.com> Date: Mon, 30 Oct 2023 23:09:10 +0530 Subject: [PATCH 1/2] Update weather_hourly.dart Dry refactored code --- lib/app/widgets/hourly/weather_hourly.dart | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/app/widgets/hourly/weather_hourly.dart b/lib/app/widgets/hourly/weather_hourly.dart index 8bd40d5..47e6a5f 100644 --- a/lib/app/widgets/hourly/weather_hourly.dart +++ b/lib/app/widgets/hourly/weather_hourly.dart @@ -31,19 +31,18 @@ class _WeatherHourlyState extends State { @override Widget build(BuildContext context) { final textTheme = context.textTheme; - + final time = widget.time; return Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Column( children: [ Text( - statusData.getTimeFormat(widget.time), + statusData.getTimeFormat(time), style: textTheme.labelLarge, ), Text( - DateFormat('E', locale.languageCode) - .format(DateTime.tryParse(widget.time)!), + DateFormat('E', locale.languageCode).format(DateTime.tryParse(time)!), style: textTheme.labelLarge?.copyWith( color: Colors.grey, ), @@ -53,7 +52,7 @@ class _WeatherHourlyState extends State { Image.asset( statusWeather.getImageToday( widget.weather, - widget.time, + time, widget.timeDay, widget.timeNight, ), From 09c9b22729dabc9d59f84f3a4c39ab3e8902e521 Mon Sep 17 00:00:00 2001 From: Shuktika Mahanty <53374048+Shuktika15@users.noreply.github.com> Date: Mon, 30 Oct 2023 23:10:17 +0530 Subject: [PATCH 2/2] Update create_card_weather.dart Refactored reusable textFieldElevation property --- .../cards/widgets/create_card_weather.dart | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/lib/app/modules/cards/widgets/create_card_weather.dart b/lib/app/modules/cards/widgets/create_card_weather.dart index f1fed39..92e0782 100644 --- a/lib/app/modules/cards/widgets/create_card_weather.dart +++ b/lib/app/modules/cards/widgets/create_card_weather.dart @@ -44,6 +44,7 @@ class _CreateWeatherCardState extends State { @override Widget build(BuildContext context) { + const kTextFieldElevation = 4.0; return Form( key: formKey, child: SingleChildScrollView( @@ -107,18 +108,15 @@ class _CreateWeatherCardState extends State { RawAutocomplete( focusNode: _focusNode, textEditingController: _controller, - fieldViewBuilder: (BuildContext context, - TextEditingController fieldTextEditingController, - FocusNode fieldFocusNode, - VoidCallback onFieldSubmitted) { + fieldViewBuilder: (BuildContext context, TextEditingController fieldTextEditingController, + FocusNode fieldFocusNode, VoidCallback onFieldSubmitted) { return MyTextForm( - elevation: 4, + elevation: kTextFieldElevation, labelText: 'search'.tr, 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, ); }, @@ -126,15 +124,12 @@ class _CreateWeatherCardState extends State { if (textEditingValue.text.isEmpty) { return const Iterable.empty(); } - return WeatherAPI() - .getCity(textEditingValue.text, locale); + return WeatherAPI().getCity(textEditingValue.text, locale); }, onSelected: (Result selection) => fillController(selection), - displayStringForOption: (Result option) => - '${option.name}, ${option.admin1}', - optionsViewBuilder: (BuildContext context, - AutocompleteOnSelected onSelected, - Iterable options) { + displayStringForOption: (Result option) => '${option.name}, ${option.admin1}', + optionsViewBuilder: + (BuildContext context, AutocompleteOnSelected onSelected, Iterable options) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 10), child: Align( @@ -165,7 +160,7 @@ class _CreateWeatherCardState extends State { }, ), MyTextForm( - elevation: 4, + elevation: kTextFieldElevation, controller: _controllerLat, labelText: 'lat'.tr, type: TextInputType.number, @@ -186,7 +181,7 @@ class _CreateWeatherCardState extends State { }, ), MyTextForm( - elevation: 4, + elevation: kTextFieldElevation, controller: _controllerLon, labelText: 'lon'.tr, type: TextInputType.number, @@ -207,7 +202,7 @@ class _CreateWeatherCardState extends State { }, ), MyTextForm( - elevation: 4, + elevation: kTextFieldElevation, controller: _controllerCity, labelText: 'city'.tr, type: TextInputType.name, @@ -221,7 +216,7 @@ class _CreateWeatherCardState extends State { }, ), MyTextForm( - elevation: 4, + elevation: kTextFieldElevation, controller: _controllerDistrict, labelText: 'district'.tr, type: TextInputType.streetAddress,