Skip to content

Commit

Permalink
Small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
g123k committed Jul 20, 2024
1 parent ad78108 commit b0efd2e
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 61 deletions.
36 changes: 16 additions & 20 deletions packages/smooth_app/lib/pages/onboarding/welcome_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:smooth_app/helpers/app_helper.dart';
import 'package:smooth_app/pages/onboarding/next_button.dart';
import 'package:smooth_app/pages/onboarding/onboarding_flow_navigator.dart';
import 'package:smooth_app/pages/preferences/country_selector/country_selector.dart';
import 'package:smooth_app/resources/app_icons.dart' as icons;
import 'package:smooth_app/widgets/smooth_scaffold.dart';
import 'package:smooth_app/widgets/smooth_text.dart';

Expand Down Expand Up @@ -83,40 +84,35 @@ class WelcomePage extends StatelessWidget {
Padding(
padding: const EdgeInsets.symmetric(
vertical: MEDIUM_SPACE),
child: Ink(
child: Container(
decoration: BoxDecoration(
border: Border.fromBorderSide(
BorderSide(
color: theme.colorScheme.inversePrimary,
width: 1,
),
),
borderRadius: ROUNDED_BORDER_RADIUS,
borderRadius: ANGULAR_BORDER_RADIUS,
color: theme.colorScheme.onPrimary,
),
child: SizedBox(
width: double.infinity,
child: CountrySelector(
forceCurrencyChange: true,
padding: const EdgeInsets.symmetric(
horizontal: SMALL_SPACE,
),
inkWellBorderRadius: ROUNDED_BORDER_RADIUS,
icon: Container(
height: double.infinity,
decoration: BoxDecoration(
color: theme.primaryColor,
borderRadius: ROUNDED_BORDER_RADIUS,
child: Material(
type: MaterialType.transparency,
child: CountrySelector(
autoValidate: true,
forceCurrencyChange: true,
padding: const EdgeInsetsDirectional.only(
start: SMALL_SPACE,
end: LARGE_SPACE,
),
child: AspectRatio(
aspectRatio: 1.0,
child: Icon(
Icons.edit,
color: Colors.white.withOpacity(0.9),
),
inkWellBorderRadius: ANGULAR_BORDER_RADIUS,
icon: const icons.Arrow.right(
size: 15.0,
),
textStyle:
TextStyle(color: theme.primaryColor),
),
textStyle: TextStyle(color: theme.primaryColor),
),
),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'dart:io';

import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart' hide Listener;
Expand Down Expand Up @@ -112,22 +110,22 @@ class _CountrySelectorButton extends StatelessWidget {
final Country? country =
(value as _CountrySelectorLoadedState).country;

return Row(
children: <Widget>[
if (country != null)
SizedBox(
width: IconTheme.of(context).size! + LARGE_SPACE,
child: AutoSizeText(
EmojiHelper.getEmojiByCountryCode(country.countryCode)!,
textAlign: TextAlign.center,
style: TextStyle(fontSize: IconTheme.of(context).size),
),
)
else
const Icon(Icons.public),
Expanded(
child: Padding(
padding: innerPadding,
return Padding(
padding: innerPadding,
child: Row(
children: <Widget>[
if (country != null)
SizedBox(
width: IconTheme.of(context).size! + LARGE_SPACE,
child: AutoSizeText(
EmojiHelper.getEmojiByCountryCode(country.countryCode)!,
textAlign: TextAlign.center,
style: TextStyle(fontSize: IconTheme.of(context).size),
),
)
else
const Icon(Icons.public),
Expanded(
child: Text(
country?.name ?? AppLocalizations.of(context).loading,
style: Theme.of(context)
Expand All @@ -136,9 +134,9 @@ class _CountrySelectorButton extends StatelessWidget {
?.merge(textStyle),
),
),
),
icon ?? const Icon(Icons.arrow_drop_down),
],
icon ?? const Icon(Icons.arrow_drop_down),
],
),
);
},
),
Expand Down Expand Up @@ -231,11 +229,12 @@ class _CountrySelectorButton extends StatelessWidget {
)}',
),
negativeAction: SmoothActionButton(
onPressed: () => Navigator.of(context).pop(),
onPressed: () => Navigator.of(context, rootNavigator: true).pop(),
text: appLocalizations.no,
),
positiveAction: SmoothActionButton(
onPressed: () => Navigator.of(context).pop(true),
onPressed: () =>
Navigator.of(context, rootNavigator: true).pop(true),
text: appLocalizations.yes,
),
),
Expand Down Expand Up @@ -292,11 +291,15 @@ class _CountrySelectorScreen extends StatelessWidget {
_CountrySelectorState? oldValue,
_CountrySelectorState currentValue,
) {
if (oldValue is _CountrySelectorEditingState &&
if (provider.autoValidate &&
oldValue != null &&
currentValue is! _CountrySelectorEditingState &&
currentValue is _CountrySelectorLoadedState) {
WidgetsBinding.instance.addPostFrameCallback((_) {
Navigator.of(context).pop(currentValue.country);
final NavigatorState navigator = Navigator.of(context);
if (navigator.canPop()) {
navigator.pop(currentValue.country);
}
});
}
}
Expand Down Expand Up @@ -415,9 +418,12 @@ class _CountrySelectorBottomBar extends StatelessWidget {

/// Without autoValidate, we need to manually close the screen
countryProvider.saveSelectedCountry();
Navigator.of(context).pop(
(countryProvider.value as _CountrySelectorLoadedState).country,
);

if (countryProvider.value is _CountrySelectorEditingState) {
Navigator.of(context).pop(
(countryProvider.value as _CountrySelectorEditingState).selectedCountry,
);
}
}
}

Expand Down Expand Up @@ -461,7 +467,6 @@ class _CountrySelectorListState extends State<_CountrySelectorList> {
return _CountrySelectorListItem(
country: country,
selected: selected,
isLastItem: index == countries.length - 1,
filter: controller.text,
);
},
Expand Down Expand Up @@ -502,13 +507,11 @@ class _CountrySelectorListItem extends StatelessWidget {
const _CountrySelectorListItem({
required this.country,
required this.selected,
required this.isLastItem,
required this.filter,
});

final Country country;
final bool selected;
final bool isLastItem;
final String filter;

@override
Expand All @@ -525,16 +528,11 @@ class _CountrySelectorListItem extends StatelessWidget {
excludeSemantics: true,
child: AnimatedContainer(
duration: SmoothAnimationsDuration.short,
margin: Platform.isIOS && isLastItem
? const EdgeInsetsDirectional.only(
start: SMALL_SPACE,
end: SMALL_SPACE,
)
: const EdgeInsetsDirectional.only(
start: SMALL_SPACE,
end: SMALL_SPACE,
bottom: SMALL_SPACE,
),
margin: const EdgeInsetsDirectional.only(
start: SMALL_SPACE,
end: SMALL_SPACE,
bottom: SMALL_SPACE,
),
decoration: BoxDecoration(
borderRadius: ANGULAR_BORDER_RADIUS,
border: Border.all(
Expand Down

0 comments on commit b0efd2e

Please sign in to comment.