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: Better support RTL languages #4310

Merged
merged 4 commits into from
Jul 16, 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
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class _ProductTitleCardTrailing extends StatelessWidget {

if (removable && !selectable) {
return Align(
alignment: Alignment.centerRight,
alignment: AlignmentDirectional.centerEnd,
child: ProductCardCloseButton(
onRemove: onRemove,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ class SmoothProductCardTemplate extends StatelessWidget {
height: screenSize.width * 0.20,
color: itemColor,
),
const Padding(padding: EdgeInsets.only(left: VERY_SMALL_SPACE)),
const Padding(
padding: EdgeInsetsDirectional.only(start: VERY_SMALL_SPACE)),
Expanded(
child: SizedBox(
height: screenSize.width * 0.2,
Expand All @@ -83,7 +84,8 @@ class SmoothProductCardTemplate extends StatelessWidget {
if (message == null) textWidget,
if (message != null)
Padding(
padding: const EdgeInsets.only(top: SMALL_SPACE),
padding: const EdgeInsetsDirectional.only(
top: SMALL_SPACE),
child: AutoSizeText(
message!,
maxLines: 3,
Expand All @@ -94,7 +96,8 @@ class SmoothProductCardTemplate extends StatelessWidget {
),
),
),
const Padding(padding: EdgeInsets.only(left: VERY_SMALL_SPACE)),
const Padding(
padding: EdgeInsetsDirectional.only(start: VERY_SMALL_SPACE)),
Padding(
padding: const EdgeInsets.all(VERY_SMALL_SPACE),
child: actionButton == null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,28 @@ class SmoothAlertDialog extends StatelessWidget {
final SmoothActionButton? negativeAction;
final Axis? actionsAxis;
final SmoothButtonsBarOrder? actionsOrder;
final EdgeInsets? contentPadding;
final EdgeInsetsDirectional? contentPadding;

static const EdgeInsets _smallContentPadding = EdgeInsets.only(
left: SMALL_SPACE,
static const EdgeInsetsDirectional _smallContentPadding =
EdgeInsetsDirectional.only(
start: SMALL_SPACE,
top: MEDIUM_SPACE,
right: SMALL_SPACE,
end: SMALL_SPACE,
bottom: SMALL_SPACE,
);

static const EdgeInsets _contentPadding = EdgeInsets.only(
left: 22.0,
static const EdgeInsetsDirectional _contentPadding =
EdgeInsetsDirectional.only(
start: 22.0,
top: VERY_LARGE_SPACE,
right: 22.0,
end: 22.0,
bottom: 22.0,
);

@override
Widget build(BuildContext context) {
final Widget content = _buildContent(context);
final EdgeInsets padding = contentPadding ??
final EdgeInsetsDirectional padding = contentPadding ??
(context.isSmallDevice() ? _smallContentPadding : _contentPadding);

return AlertDialog(
Expand All @@ -84,7 +86,7 @@ class SmoothAlertDialog extends StatelessWidget {
);
}

Padding _buildBottomBar(EdgeInsets padding) {
Padding _buildBottomBar(EdgeInsetsDirectional padding) {
return Padding(
padding: EdgeInsetsDirectional.only(
top: padding.bottom,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class KnowledgePanelWorldMapCard extends StatelessWidget {
AttributionWidget(
attributionBuilder: (BuildContext context) {
return Align(
alignment: Alignment.bottomRight,
alignment: AlignmentDirectional.bottomEnd,
child: ColoredBox(
color: const Color(0xCCFFFFFF),
child: GestureDetector(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ class ConsentAnalyticsPage extends StatelessWidget {
),
),
OnboardingBottomBar(
leftButton: _buildButton(
startButton: _buildButton(
context,
appLocalizations.refuse_button_label,
false,
const Color(0xFFA08D84),
Colors.white,
),
rightButton: _buildButton(
endButton: _buildButton(
context,
appLocalizations.authorize_button_label,
true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class _CountrySelectorState extends State<CountrySelector> {
builder: (BuildContext context,
void Function(VoidCallback fn) setState) {
return SmoothAlertDialog(
contentPadding: const EdgeInsets.symmetric(
contentPadding: const EdgeInsetsDirectional.symmetric(
horizontal: 0.0,
vertical: SMALL_SPACE,
),
Expand Down
4 changes: 2 additions & 2 deletions packages/smooth_app/lib/pages/onboarding/next_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class NextButton extends StatelessWidget {
OnboardingFlowNavigator(userPreferences);
final OnboardingPage previousPage = currentPage.getPrevPage();
return OnboardingBottomBar(
leftButton: previousPage.isOnboardingNotStarted()
startButton: previousPage.isOnboardingNotStarted()
? null
: OnboardingBottomIcon(
onPressed: () async => navigator.navigateToPage(
Expand All @@ -50,7 +50,7 @@ class NextButton extends StatelessWidget {
? const EdgeInsetsDirectional.only(end: 2.5)
: EdgeInsets.zero,
),
rightButton: OnboardingBottomButton(
endButton: OnboardingBottomButton(
onPressed: () async {
await OnboardingLoader(localDatabase)
.runAtNextTime(currentPage, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import 'package:smooth_app/generic_lib/design_constants.dart';
/// Bottom Bar during onboarding. Typical use case: previous/next buttons.
class OnboardingBottomBar extends StatelessWidget {
const OnboardingBottomBar({
required this.rightButton,
required this.endButton,
required this.backgroundColor,
this.leftButton,
this.startButton,
});

final Widget rightButton;
final Widget? leftButton;
final Widget endButton;
final Widget? startButton;

/// Color of the background where we put the buttons.
///
Expand All @@ -22,7 +22,7 @@ class OnboardingBottomBar extends StatelessWidget {
final Size screenSize = MediaQuery.of(context).size;
// Side padding is 8% of total width.
final double sidePadding = screenSize.width * .08;
final bool hasPrevious = leftButton != null;
final bool hasPrevious = startButton != null;
return Column(
children: <Widget>[
Container(
Expand All @@ -43,8 +43,8 @@ class OnboardingBottomBar extends StatelessWidget {
: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
if (leftButton != null) leftButton!,
rightButton,
if (startButton != null) startButton!,
endButton,
],
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ class _PermissionsPageState extends State<PermissionsPage> {
),
)),
OnboardingBottomBar(
leftButton: _IgnoreButton(
startButton: _IgnoreButton(
onPermissionIgnored: () => _moveToNextScreen(context),
),
rightButton: _AskPermissionButton(
endButton: _AskPermissionButton(
onPermissionIgnored: () => _moveToNextScreen(context),
),
backgroundColor: widget.backgroundColor,
Expand Down
6 changes: 3 additions & 3 deletions packages/smooth_app/lib/pages/personalized_ranking_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,10 @@ class _PersonalizedRankingPageState extends State<PersonalizedRankingPage>
Dismissible(
direction: DismissDirection.endToStart,
background: Container(
alignment: Alignment.centerRight,
margin: const EdgeInsets.symmetric(vertical: 14),
alignment: AlignmentDirectional.centerEnd,
margin: const EdgeInsets.symmetric(vertical: 14.0),
color: RED_COLOR,
padding: const EdgeInsetsDirectional.only(end: 30),
padding: const EdgeInsetsDirectional.only(end: 30.0),
child: const Icon(
Icons.delete,
color: Colors.white,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ class _ApplicationSettings extends StatelessWidget {
label: appLocalizations.settings_app_app,
),
Padding(
padding: const EdgeInsets.only(
left: LARGE_SPACE,
padding: const EdgeInsetsDirectional.only(
start: LARGE_SPACE,
top: MEDIUM_SPACE,
),
child: Row(
Expand All @@ -202,8 +202,8 @@ class _ApplicationSettings extends StatelessWidget {
),
),
Padding(
padding: const EdgeInsets.only(
right: LARGE_SPACE,
padding: const EdgeInsetsDirectional.only(
end: LARGE_SPACE,
bottom: MEDIUM_SPACE,
),
child: Row(
Expand Down Expand Up @@ -269,10 +269,10 @@ class _ApplicationSettings extends StatelessWidget {
style: themeData.textTheme.headlineMedium,
),
subtitle: Padding(
padding: const EdgeInsets.only(
padding: const EdgeInsetsDirectional.only(
top: SMALL_SPACE,
bottom: SMALL_SPACE,
left: SMALL_SPACE,
start: SMALL_SPACE,
),
child: CountrySelector(
textStyle: themeData.textTheme.bodyMedium,
Expand All @@ -287,10 +287,10 @@ class _ApplicationSettings extends StatelessWidget {
style: themeData.textTheme.headlineMedium,
),
subtitle: Padding(
padding: const EdgeInsets.only(
padding: const EdgeInsetsDirectional.only(
top: SMALL_SPACE,
bottom: SMALL_SPACE,
left: SMALL_SPACE,
start: SMALL_SPACE,
),
child: LanguageSelector(
setLanguage: (final OpenFoodFactsLanguage? language) async {
Expand All @@ -311,8 +311,8 @@ class _ApplicationSettings extends StatelessWidget {
),
const UserPreferencesListItemDivider(),
Padding(
padding: const EdgeInsets.only(
left: LARGE_SPACE,
padding: const EdgeInsetsDirectional.only(
start: LARGE_SPACE,
top: MEDIUM_SPACE,
),
child: Row(
Expand All @@ -326,8 +326,8 @@ class _ApplicationSettings extends StatelessWidget {
),
),
Padding(
padding: const EdgeInsets.only(
right: LARGE_SPACE,
padding: const EdgeInsetsDirectional.only(
end: LARGE_SPACE,
bottom: MEDIUM_SPACE,
),
child: Row(
Expand Down Expand Up @@ -392,8 +392,8 @@ class ChooseAccentColor extends StatelessWidget {
}

return Padding(
padding: const EdgeInsets.only(
right: LARGE_SPACE,
padding: const EdgeInsetsDirectional.only(
end: LARGE_SPACE,
bottom: MEDIUM_SPACE,
),
child: Row(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ class _ProductListPageState extends State<ProductListPage>
builder: (BuildContext context) {
return SmoothAlertDialog(
body: Container(
padding: const EdgeInsets.only(left: SMALL_SPACE),
padding: const EdgeInsetsDirectional.only(
start: SMALL_SPACE),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expand Down Expand Up @@ -321,8 +322,8 @@ class _ProductListPageState extends State<ProductListPage>
final Widget child = InkWell(
onTap: _selectionMode ? onTap : null,
child: Container(
padding: EdgeInsets.only(
left: _selectionMode ? SMALL_SPACE : 0,
padding: EdgeInsetsDirectional.only(
start: _selectionMode ? SMALL_SPACE : 0,
),
child: Row(
children: <Widget>[
Expand Down Expand Up @@ -354,7 +355,7 @@ class _ProductListPageState extends State<ProductListPage>
return Dismissible(
direction: DismissDirection.endToStart,
background: Container(
alignment: Alignment.centerRight,
alignment: AlignmentDirectional.centerEnd,
margin: const EdgeInsets.symmetric(vertical: 14),
color: RED_COLOR,
padding: const EdgeInsetsDirectional.only(end: 30),
Expand Down
12 changes: 6 additions & 6 deletions packages/smooth_app/lib/pages/product/edit_new_packagings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ class _EditNewPackagingsState extends State<EditNewPackagings>
);
children.add(
Padding(
padding: const EdgeInsets.only(
padding: const EdgeInsetsDirectional.only(
top: VERY_LARGE_SPACE,
left: SMALL_SPACE,
right: SMALL_SPACE,
start: SMALL_SPACE,
end: SMALL_SPACE,
),
child: addPanelButton(
appLocalizations.edit_packagings_element_add.toUpperCase(),
Expand All @@ -158,10 +158,10 @@ class _EditNewPackagingsState extends State<EditNewPackagings>
);
children.add(
Padding(
padding: const EdgeInsets.only(
padding: const EdgeInsetsDirectional.only(
bottom: VERY_LARGE_SPACE,
left: SMALL_SPACE,
right: SMALL_SPACE,
start: SMALL_SPACE,
end: SMALL_SPACE,
),
child: addPanelButton(
appLocalizations.add_packaging_photo_button_label.toUpperCase(),
Expand Down
8 changes: 4 additions & 4 deletions packages/smooth_app/lib/pages/product/edit_ocr_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class _EditOcrPageState extends State<EditOcrPage> with UpToDateMixin {
Flexible(
flex: 1,
child: Align(
alignment: Alignment.bottomRight,
alignment: AlignmentDirectional.bottomEnd,
child: Padding(
padding: const EdgeInsetsDirectional.only(
bottom: LARGE_SPACE,
Expand Down Expand Up @@ -280,9 +280,9 @@ class _EditOcrPageState extends State<EditOcrPage> with UpToDateMixin {
child: Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background,
borderRadius: const BorderRadius.only(
topLeft: ANGULAR_RADIUS,
topRight: ANGULAR_RADIUS,
borderRadius: const BorderRadiusDirectional.only(
topStart: ANGULAR_RADIUS,
topEnd: ANGULAR_RADIUS,
)),
child: SingleChildScrollView(
child: Padding(
Expand Down
Loading