-
-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Input Source picker in a bottom sheet (#4281)
- Loading branch information
Showing
2 changed files
with
260 additions
and
39 deletions.
There are no files selected for viewing
100 changes: 100 additions & 0 deletions
100
packages/smooth_app/lib/generic_lib/widgets/smooth_bottom_sheet.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/semantics.dart'; | ||
import 'package:smooth_app/generic_lib/design_constants.dart'; | ||
|
||
Future<T?> showSmoothModalSheet<T>({ | ||
required BuildContext context, | ||
required WidgetBuilder builder, | ||
}) { | ||
return showModalBottomSheet<T>( | ||
context: context, | ||
shape: const RoundedRectangleBorder( | ||
borderRadius: BorderRadius.vertical(top: ROUNDED_RADIUS), | ||
), | ||
builder: builder, | ||
); | ||
} | ||
|
||
class SmoothModalSheet extends StatelessWidget { | ||
const SmoothModalSheet({ | ||
required this.title, | ||
required this.body, | ||
this.closeButton = true, | ||
this.bodyPadding, | ||
this.closeButtonSemanticsOrder = 2.0, | ||
}); | ||
|
||
final String title; | ||
final bool closeButton; | ||
final double closeButtonSemanticsOrder; | ||
final Widget body; | ||
final EdgeInsetsGeometry? bodyPadding; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final Color primaryColor = Theme.of(context).primaryColor; | ||
|
||
return ClipRRect( | ||
borderRadius: const BorderRadius.vertical(top: ROUNDED_RADIUS), | ||
child: DecoratedBox( | ||
decoration: const BoxDecoration( | ||
borderRadius: BorderRadius.vertical(top: ROUNDED_RADIUS), | ||
), | ||
child: Column( | ||
mainAxisSize: MainAxisSize.min, | ||
children: <Widget>[ | ||
Container( | ||
color: primaryColor.withOpacity(0.2), | ||
padding: EdgeInsetsDirectional.only( | ||
start: VERY_LARGE_SPACE, | ||
top: VERY_SMALL_SPACE, | ||
bottom: VERY_SMALL_SPACE, | ||
end: VERY_LARGE_SPACE - (closeButton ? LARGE_SPACE : 0), | ||
), | ||
child: Row( | ||
children: <Widget>[ | ||
Expanded( | ||
child: Semantics( | ||
sortKey: const OrdinalSortKey(1.0), | ||
child: Text( | ||
title, | ||
maxLines: 1, | ||
overflow: TextOverflow.ellipsis, | ||
style: Theme.of(context).textTheme.titleLarge, | ||
), | ||
), | ||
), | ||
if (closeButton) | ||
Semantics( | ||
value: MaterialLocalizations.of(context) | ||
.closeButtonTooltip, | ||
button: true, | ||
excludeSemantics: true, | ||
onScrollDown: () {}, | ||
sortKey: OrdinalSortKey(closeButtonSemanticsOrder), | ||
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: Icon(Icons.clear), | ||
), | ||
), | ||
), | ||
) | ||
], | ||
), | ||
), | ||
Padding( | ||
padding: bodyPadding ?? const EdgeInsets.all(MEDIUM_SPACE), | ||
child: body, | ||
), | ||
], | ||
)), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters