Made 'Icon Only'(name from Figma) type of ActionSheet

This commit is contained in:
ashilkn 2022-12-12 16:42:17 +05:30
parent 4211046d8a
commit fa4c08c699

View file

@ -7,9 +7,16 @@ import 'package:photos/theme/effects.dart';
import 'package:photos/theme/ente_theme.dart';
import 'package:photos/utils/separators_util.dart';
enum ActionSheetType {
defaultActionSheet,
iconOnly,
}
void showActionSheet({
required BuildContext context,
required List<Widget> buttons,
required ActionSheetType actionSheetType,
bool isCheckIconGreen = false,
String? title,
String? body,
}) {
@ -23,6 +30,8 @@ void showActionSheet({
title: title,
body: body,
actionButtons: buttons,
actionSheetType: actionSheetType,
isCheckIconGreen: isCheckIconGreen,
);
},
);
@ -32,9 +41,13 @@ class ActionSheetWidget extends StatelessWidget {
final String? title;
final String? body;
final List<Widget> actionButtons;
final ActionSheetType actionSheetType;
final bool isCheckIconGreen;
const ActionSheetWidget({
required this.actionButtons,
required this.actionSheetType,
required this.isCheckIconGreen,
this.title,
this.body,
super.key,
@ -73,6 +86,8 @@ class ActionSheetWidget extends StatelessWidget {
child: ContentContainerWidget(
title: title,
body: body,
actionSheetType: actionSheetType,
isCheckIconGreen: isCheckIconGreen,
),
),
ActionButtons(
@ -92,7 +107,15 @@ class ActionSheetWidget extends StatelessWidget {
class ContentContainerWidget extends StatelessWidget {
final String? title;
final String? body;
const ContentContainerWidget({this.title, this.body, super.key});
final ActionSheetType actionSheetType;
final bool isCheckIconGreen;
const ContentContainerWidget({
required this.actionSheetType,
required this.isCheckIconGreen,
this.title,
this.body,
super.key,
});
@override
Widget build(BuildContext context) {
@ -100,7 +123,9 @@ class ContentContainerWidget extends StatelessWidget {
return Column(
mainAxisSize: MainAxisSize.min,
//todo: set cross axis to center when icon should be shown in place of body
crossAxisAlignment: CrossAxisAlignment.stretch,
crossAxisAlignment: actionSheetType == ActionSheetType.defaultActionSheet
? CrossAxisAlignment.stretch
: CrossAxisAlignment.center,
children: [
title == null
? const SizedBox.shrink()
@ -112,13 +137,19 @@ class ContentContainerWidget extends StatelessWidget {
title == null || body == null
? const SizedBox.shrink()
: const SizedBox(height: 19),
body == null
? const SizedBox.shrink()
: Text(
body!,
style: textTheme.body
.copyWith(color: textMutedDark), //constant color
)
actionSheetType == ActionSheetType.defaultActionSheet
? body == null
? const SizedBox.shrink()
: Text(
body!,
style: textTheme.body
.copyWith(color: textMutedDark), //constant color
)
: Icon(Icons.check_outlined,
size: 48,
color: isCheckIconGreen
? getEnteColorScheme(context).primary700
: strokeBaseDark)
],
);
}