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

feat: Customized language picker UI for the onboarding #4826

Merged
merged 1 commit into from
Nov 21, 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
6 changes: 5 additions & 1 deletion packages/smooth_app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,11 @@
},
"country_chooser_label": "Please choose a country",
"@country_chooser_label": {
"description": "Label shown above a selector where the user can select their country (in the onboarding)"
"description": "Label shown above a selector where the user can select their country (in the preferences)"
},
"onboarding_country_chooser_label": "Please choose a country:",
"@onboarding_country_chooser_label": {
"description": "The label shown above a selector where the user can select their country (in the onboarding)"
},
"country_chooser_label_from_settings": "Your country",
"@country_chooser_label_from_settings": {
Expand Down
65 changes: 42 additions & 23 deletions packages/smooth_app/lib/pages/onboarding/country_selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ class CountrySelector extends StatefulWidget {
this.textStyle,
this.padding,
this.icon,
this.iconDecoration,
this.inkWellBorderRadius,
});

final TextStyle? textStyle;
final EdgeInsetsGeometry? padding;
final IconData? icon;
final BorderRadius? inkWellBorderRadius;
final Icon? icon;
final BoxDecoration? iconDecoration;

@override
State<CountrySelector> createState() => _CountrySelectorState();
Expand Down Expand Up @@ -76,8 +80,12 @@ class _CountrySelectorState extends State<CountrySelector> {
final Country selectedCountry = _getSelectedCountry(
userPreferences.userCountryCode,
);
final EdgeInsetsGeometry innerPadding = const EdgeInsets.symmetric(
vertical: SMALL_SPACE,
).add(widget.padding ?? EdgeInsets.zero);

return InkWell(
borderRadius: ANGULAR_BORDER_RADIUS,
borderRadius: widget.inkWellBorderRadius ?? ANGULAR_BORDER_RADIUS,
onTap: () async {
_reorderCountries(selectedCountry);
List<Country> filteredList = List<Country>.from(_countryList);
Expand Down Expand Up @@ -168,32 +176,43 @@ class _CountrySelectorState extends State<CountrySelector> {
);
}
},
child: Container(
child: DecoratedBox(
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(10)),
),
padding: const EdgeInsets.symmetric(
vertical: SMALL_SPACE,
).add(widget.padding ?? EdgeInsets.zero),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
const Icon(Icons.public),
Expanded(
flex: 1,
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: LARGE_SPACE),
child: Text(
selectedCountry.name,
style: widget.textStyle ??
Theme.of(context).textTheme.displaySmall,
child: IntrinsicHeight(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Padding(
padding: innerPadding,
child: const Icon(Icons.public),
),
Expanded(
flex: 1,
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: LARGE_SPACE),
child: Text(
selectedCountry.name,
style: Theme.of(context)
.textTheme
.displaySmall
?.merge(widget.textStyle),
),
),
),
Container(
height: double.infinity,
decoration: widget.iconDecoration ?? const BoxDecoration(),
child: AspectRatio(
aspectRatio: 1.0,
child: widget.icon ?? const Icon(Icons.arrow_drop_down),
),
),
),
Icon(widget.icon ?? Icons.arrow_drop_down),
],
],
),
),
),
);
Expand Down
36 changes: 26 additions & 10 deletions packages/smooth_app/lib/pages/onboarding/welcome_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ class WelcomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final AppLocalizations appLocalizations = AppLocalizations.of(context);
final TextStyle headlineStyle =
Theme.of(context).textTheme.displayMedium!.wellSpaced;
final TextStyle bodyTextStyle =
Theme.of(context).textTheme.bodyLarge!.wellSpaced;
final ThemeData theme = Theme.of(context);
final TextStyle headlineStyle = theme.textTheme.displayMedium!.wellSpaced;
final TextStyle bodyTextStyle = theme.textTheme.bodyLarge!.wellSpaced;
final Size screenSize = MediaQuery.of(context).size;

return SmoothScaffold(
Expand Down Expand Up @@ -74,24 +73,41 @@ class WelcomePage extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
appLocalizations.country_chooser_label,
appLocalizations.onboarding_country_chooser_label,
style: bodyTextStyle,
),
Padding(
padding:
const EdgeInsets.symmetric(vertical: MEDIUM_SPACE),
child: Ink(
decoration: BoxDecoration(
border: const Border.fromBorderSide(
border: Border.fromBorderSide(
BorderSide(
color: Colors.black,
color: theme.colorScheme.inversePrimary,
width: 1,
),
),
borderRadius: ANGULAR_BORDER_RADIUS,
color: Theme.of(context).cardColor,
borderRadius: ROUNDED_BORDER_RADIUS,
color: theme.colorScheme.onPrimary,
),
child: SizedBox(
width: double.infinity,
child: CountrySelector(
padding: const EdgeInsets.symmetric(
horizontal: SMALL_SPACE,
),
inkWellBorderRadius: ROUNDED_BORDER_RADIUS,
icon: Icon(
Icons.edit,
color: Colors.white.withOpacity(0.9),
),
iconDecoration: BoxDecoration(
color: theme.primaryColor,
borderRadius: ROUNDED_BORDER_RADIUS,
),
textStyle: TextStyle(color: theme.primaryColor),
),
),
child: const CountrySelector(),
),
),
Padding(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class UserPreferencesCountrySelector extends StatelessWidget {
),
child: CountrySelector(
textStyle: themeData.textTheme.bodyMedium,
icon: Icons.edit,
icon: const Icon(Icons.edit),
padding: const EdgeInsetsDirectional.only(
start: SMALL_SPACE,
),
Expand Down