Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code quality improvements #147

Merged
merged 2 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 13 additions & 18 deletions lib/app/modules/cards/widgets/create_card_weather.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class _CreateWeatherCardState extends State<CreateWeatherCard> {

@override
Widget build(BuildContext context) {
const kTextFieldElevation = 4.0;
return Form(
key: formKey,
child: SingleChildScrollView(
Expand Down Expand Up @@ -107,34 +108,28 @@ class _CreateWeatherCardState extends State<CreateWeatherCard> {
RawAutocomplete<Result>(
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,
);
},
optionsBuilder: (TextEditingValue textEditingValue) {
if (textEditingValue.text.isEmpty) {
return const Iterable<Result>.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<Result> onSelected,
Iterable<Result> options) {
displayStringForOption: (Result option) => '${option.name}, ${option.admin1}',
optionsViewBuilder:
(BuildContext context, AutocompleteOnSelected<Result> onSelected, Iterable<Result> options) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Align(
Expand Down Expand Up @@ -165,7 +160,7 @@ class _CreateWeatherCardState extends State<CreateWeatherCard> {
},
),
MyTextForm(
elevation: 4,
elevation: kTextFieldElevation,
controller: _controllerLat,
labelText: 'lat'.tr,
type: TextInputType.number,
Expand All @@ -186,7 +181,7 @@ class _CreateWeatherCardState extends State<CreateWeatherCard> {
},
),
MyTextForm(
elevation: 4,
elevation: kTextFieldElevation,
controller: _controllerLon,
labelText: 'lon'.tr,
type: TextInputType.number,
Expand All @@ -207,7 +202,7 @@ class _CreateWeatherCardState extends State<CreateWeatherCard> {
},
),
MyTextForm(
elevation: 4,
elevation: kTextFieldElevation,
controller: _controllerCity,
labelText: 'city'.tr,
type: TextInputType.name,
Expand All @@ -221,7 +216,7 @@ class _CreateWeatherCardState extends State<CreateWeatherCard> {
},
),
MyTextForm(
elevation: 4,
elevation: kTextFieldElevation,
controller: _controllerDistrict,
labelText: 'district'.tr,
type: TextInputType.streetAddress,
Expand Down
9 changes: 4 additions & 5 deletions lib/app/widgets/hourly/weather_hourly.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,18 @@ class _WeatherHourlyState extends State<WeatherHourly> {
@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,
),
Expand All @@ -53,7 +52,7 @@ class _WeatherHourlyState extends State<WeatherHourly> {
Image.asset(
statusWeather.getImageToday(
widget.weather,
widget.time,
time,
widget.timeDay,
widget.timeNight,
),
Expand Down