Skip to content

Commit

Permalink
feat: Some enhancements for the Bottom Sheet (#5803)
Browse files Browse the repository at this point in the history
* Enhance Smooth Bottom Sheet

* Fix

* Remove user_picture_source_select translation
  • Loading branch information
g123k authored Nov 7, 2024
1 parent 0a601bf commit b1005ce
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 36 deletions.
2 changes: 1 addition & 1 deletion packages/smooth_app/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -310,4 +310,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: e840dd57ba2b03bcb6fdba293a27c5f82151a80a

COCOAPODS: 1.15.2
COCOAPODS: 1.16.2
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class SmoothModalSheetHeader extends StatelessWidget implements SizeWidget {
this.backgroundColor,
});

static const double MIN_HEIGHT = 50.0;
static const double MIN_HEIGHT = 55.0;

final String title;
final SizeWidget? prefix;
Expand All @@ -108,13 +108,15 @@ class SmoothModalSheetHeader extends StatelessWidget implements SizeWidget {

@override
Widget build(BuildContext context) {
final Color primaryColor = Theme.of(context).primaryColor;
final Color primaryColor =
Theme.of(context).extension<SmoothColorsThemeExtension>()!.primaryDark;
final Color tintColor = foregroundColor ?? Colors.white;

return IconTheme(
data: IconThemeData(color: foregroundColor),
data: IconThemeData(color: tintColor),
child: Container(
height: suffix is SmoothModalSheetHeaderButton ? double.infinity : null,
color: backgroundColor ?? primaryColor.withOpacity(0.2),
color: backgroundColor ?? primaryColor,
constraints: const BoxConstraints(minHeight: MIN_HEIGHT),
padding: EdgeInsetsDirectional.only(
start: (prefix?.requiresPadding == true ? 0 : VERY_LARGE_SPACE),
Expand Down Expand Up @@ -143,7 +145,7 @@ class SmoothModalSheetHeader extends StatelessWidget implements SizeWidget {
style: Theme.of(context).textTheme.titleLarge?.copyWith(
fontWeight: FontWeight.bold,
fontSize: 18.0,
color: foregroundColor,
color: tintColor,
),
),
),
Expand Down Expand Up @@ -266,29 +268,55 @@ class SmoothModalSheetHeaderCloseButton extends StatelessWidget
const SmoothModalSheetHeaderCloseButton({
this.semanticsOrder,
this.addPadding,
this.circled = true,
});

final double? semanticsOrder;
final bool? addPadding;
final bool circled;

@override
Widget build(BuildContext context) {
final Widget icon;

if (circled == true) {
icon = Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: IconTheme.of(context).color ?? Colors.white,
width: 1.5,
),
),
margin: const EdgeInsets.all(VERY_SMALL_SPACE),
padding: const EdgeInsets.all(SMALL_SPACE),
child: const icons.Close(
size: 13.0,
),
);
} else {
icon = const Padding(
padding: EdgeInsets.all(MEDIUM_SPACE),
child: icons.Close(
size: 15.0,
),
);
}

return Semantics(
value: MaterialLocalizations.of(context).closeButtonTooltip,
button: true,
excludeSemantics: true,
sortKey: OrdinalSortKey(semanticsOrder ?? 2.0),
child: Tooltip(
message: MaterialLocalizations.of(context).closeButtonTooltip,
enableFeedback: true,
child: InkWell(
onTap: () => Navigator.of(context).pop(),
customBorder: const CircleBorder(),
child: const Padding(
padding: EdgeInsets.all(MEDIUM_SPACE),
child: icons.Close(
size: 15.0,
),
child: Padding(
padding: const EdgeInsetsDirectional.only(end: SMALL_SPACE),
child: Tooltip(
message: MaterialLocalizations.of(context).closeButtonTooltip,
enableFeedback: true,
child: InkWell(
onTap: () => Navigator.of(context).pop(),
customBorder: const CircleBorder(),
child: icon,
),
),
),
Expand Down
6 changes: 3 additions & 3 deletions packages/smooth_app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -2533,9 +2533,9 @@
"@user_picture_source_remember": {
"description": "Checkbox label when select a picture source"
},
"user_picture_source_select": "Select each time",
"@user_picture_source_select": {
"description": "Choice of selecting the picture source each time"
"user_picture_source_ask": "Ask each time",
"@user_picture_source_ask": {
"description": "Choice of asking the picture source every time"
},
"robotoff_continue": "Continue",
"@robotoff_continue": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class UserPreferencesImageSource extends StatelessWidget {
return UserPreferencesItemSimple(
labels: <String>[
appLocalizations.choose_image_source_title,
appLocalizations.user_picture_source_select,
appLocalizations.user_picture_source_ask,
appLocalizations.settings_app_camera,
appLocalizations.gallery_source_label,
],
Expand All @@ -35,7 +35,7 @@ class UserPreferencesImageSource extends StatelessWidget {
(_) => const Icon(Icons.image),
],
labels: <String>[
appLocalizations.user_picture_source_select,
appLocalizations.user_picture_source_ask,
appLocalizations.settings_app_camera,
appLocalizations.gallery_source_label,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:smooth_app/generic_lib/design_constants.dart';
import 'package:smooth_app/generic_lib/dialogs/smooth_alert_dialog.dart';
import 'package:smooth_app/pages/preferences/user_preferences_item.dart';
import 'package:smooth_app/themes/smooth_theme_colors.dart';
import 'package:smooth_app/themes/theme_provider.dart';

/// A dashed line
class UserPreferencesListItemDivider extends StatelessWidget {
Expand Down Expand Up @@ -443,15 +444,21 @@ class _ChoiceItem<T> extends StatelessWidget {
@override
Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context);
final Color? selectedColor = selected ? theme.primaryColor : null;
final SmoothColorsThemeExtension extension =
theme.extension<SmoothColorsThemeExtension>()!;
final Color? selectedColor = selected
? context.lightTheme()
? extension.primaryMedium
: extension.primaryDark
: null;

return Semantics(
value: label,
selected: selected,
button: true,
excludeSemantics: true,
child: Ink(
color: selectedColor?.withOpacity(0.1) ?? Colors.transparent,
color: selectedColor ?? Colors.transparent,
child: Column(
children: <Widget>[
ListTile(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,13 @@ class _ProductAddToListButton extends StatelessWidget {

Future<bool?> _editList(BuildContext context, Product product) async {
final AppLocalizations appLocalizations = AppLocalizations.of(context);
final SmoothColorsThemeExtension? extension =
Theme.of(context).extension<SmoothColorsThemeExtension>();

showSmoothDraggableModalSheet(
context: context,
header: SmoothModalSheetHeader(
backgroundColor: extension!.primaryDark,
foregroundColor: Colors.white,
prefix: const SmoothModalSheetHeaderPrefixIndicator(),
title: appLocalizations.user_list_title,
suffix: const SmoothModalSheetHeaderCloseButton(
addPadding: true,
),
suffix: const SmoothModalSheetHeaderCloseButton(),
),
bodyBuilder: (BuildContext context) => AddProductToListContainer(
barcode: product.barcode!,
Expand Down
6 changes: 3 additions & 3 deletions packages/smooth_app/macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,18 @@ SPEC CHECKSUMS:
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
in_app_review: a850789fad746e89bce03d4aeee8078b45a53fd0
mobile_scanner: 54ceceae0c8da2457e26a362a6be5c61154b1829
package_info_plus: fa739dd842b393193c5ca93c26798dff6e3d0e0c
package_info_plus: f5790acc797bf17c3e959e9d6cf162cc68ff7523
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
ReachabilitySwift: 7f151ff156cea1481a8411701195ac6a984f4979
rive_common: cf5ab646aa576b2d742d0e2d528126fbf032c856
Sentry: f8374b5415bc38dfb5645941b3ae31230fbeae57
sentry_flutter: 0eb93e5279eb41e2392212afe1ccd2fecb4f8cbe
share_plus: 36537c04ce0c3e3f5bd297ce4318b6d5ee5fd6cf
share_plus: fd717ef89a2801d3491e737630112b80c310640e
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
sqflite_darwin: a553b1fd6fe66f53bbb0fe5b4f5bab93f08d7a13
url_launcher_macos: 5f437abeda8c85500ceb03f5c1938a8c5a705399
webview_flutter_wkwebview: 0982481e3d9c78fd5c6f62a002fcd24fc791f1e4

PODFILE CHECKSUM: 0d3963a09fc94f580682bd88480486da345dc3f0

COCOAPODS: 1.15.2
COCOAPODS: 1.16.2
4 changes: 2 additions & 2 deletions packages/smooth_app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -696,10 +696,10 @@ packages:
dependency: "direct main"
description:
name: flutter_svg
sha256: "1b7723a814d84fb65869ea7115cdb3ee7c3be5a27a755c1ec60e049f6b9fcbb2"
sha256: de82e6bf958cec7190fbc1c5298282c851228e35ae2b14e2b103e7f777818c64
url: "https://pub.dev"
source: hosted
version: "2.0.11"
version: "2.0.13"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down

0 comments on commit b1005ce

Please sign in to comment.