diff --git a/packages/smooth_app/lib/pages/onboarding/welcome_page.dart b/packages/smooth_app/lib/pages/onboarding/welcome_page.dart index 102cf8788b5..3aafa112c3b 100644 --- a/packages/smooth_app/lib/pages/onboarding/welcome_page.dart +++ b/packages/smooth_app/lib/pages/onboarding/welcome_page.dart @@ -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'; @@ -83,7 +84,7 @@ class WelcomePage extends StatelessWidget { Padding( padding: const EdgeInsets.symmetric( vertical: MEDIUM_SPACE), - child: Ink( + child: Container( decoration: BoxDecoration( border: Border.fromBorderSide( BorderSide( @@ -91,32 +92,27 @@ class WelcomePage extends StatelessWidget { 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), ), ), ), diff --git a/packages/smooth_app/lib/pages/preferences/country_selector/country_selector.dart b/packages/smooth_app/lib/pages/preferences/country_selector/country_selector.dart index 2e4f4fc8efe..7f6c09cf39e 100644 --- a/packages/smooth_app/lib/pages/preferences/country_selector/country_selector.dart +++ b/packages/smooth_app/lib/pages/preferences/country_selector/country_selector.dart @@ -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; @@ -112,22 +110,22 @@ class _CountrySelectorButton extends StatelessWidget { final Country? country = (value as _CountrySelectorLoadedState).country; - return Row( - children: [ - 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: [ + 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) @@ -136,9 +134,9 @@ class _CountrySelectorButton extends StatelessWidget { ?.merge(textStyle), ), ), - ), - icon ?? const Icon(Icons.arrow_drop_down), - ], + icon ?? const Icon(Icons.arrow_drop_down), + ], + ), ); }, ), @@ -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, ), ), @@ -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); + } }); } } @@ -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, + ); + } } } @@ -461,7 +467,6 @@ class _CountrySelectorListState extends State<_CountrySelectorList> { return _CountrySelectorListItem( country: country, selected: selected, - isLastItem: index == countries.length - 1, filter: controller.text, ); }, @@ -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 @@ -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(