2022-09-28 05:00:43 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:photos/ente_theme_data.dart';
|
|
|
|
|
2022-09-28 05:35:17 +00:00
|
|
|
enum LeadingIcon {
|
|
|
|
chevronRight,
|
|
|
|
check,
|
|
|
|
}
|
|
|
|
|
2022-09-28 12:10:49 +00:00
|
|
|
// trailing icon can be passed without size as default size set by flutter is what this component expects
|
2022-09-28 05:00:43 +00:00
|
|
|
class MenuItemWidget extends StatelessWidget {
|
2022-09-28 11:51:52 +00:00
|
|
|
final Widget leadingWidget;
|
|
|
|
final LeadingIcon? trailingIcon;
|
|
|
|
final Widget? trailingSwitch;
|
|
|
|
final bool trailingIconIsMuted;
|
|
|
|
final Function? onTap;
|
|
|
|
const MenuItemWidget({
|
|
|
|
required this.leadingWidget,
|
|
|
|
this.trailingIcon,
|
|
|
|
this.trailingSwitch,
|
|
|
|
this.trailingIconIsMuted = false,
|
|
|
|
this.onTap,
|
|
|
|
Key? key,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final enteTheme = Theme.of(context).colorScheme.enteTheme;
|
|
|
|
return GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
onTap;
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
width: double.infinity,
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
leadingWidget,
|
|
|
|
Container(
|
|
|
|
child: trailingIcon == LeadingIcon.chevronRight
|
|
|
|
? Icon(
|
|
|
|
Icons.chevron_right_rounded,
|
|
|
|
color: trailingIconIsMuted
|
|
|
|
? enteTheme.colorScheme.strokeMuted
|
|
|
|
: null,
|
|
|
|
)
|
|
|
|
: trailingIcon == LeadingIcon.check
|
|
|
|
? Icon(
|
|
|
|
Icons.check,
|
|
|
|
color: enteTheme.colorScheme.strokeMuted,
|
|
|
|
)
|
|
|
|
: trailingSwitch ?? const SizedBox.shrink(),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-28 12:10:49 +00:00
|
|
|
// leading icon can be passed without specifing size, this component set size to 20x20
|
2022-09-28 11:51:52 +00:00
|
|
|
class LeadingWidget extends StatelessWidget {
|
2022-09-28 05:00:43 +00:00
|
|
|
final String text;
|
2022-09-28 12:08:04 +00:00
|
|
|
final IconData? leadingIcon;
|
|
|
|
final Color? leadingIconColor;
|
2022-09-28 05:00:43 +00:00
|
|
|
final String? subText;
|
|
|
|
final TextStyle? textStyle;
|
2022-09-28 11:51:52 +00:00
|
|
|
const LeadingWidget({
|
2022-09-28 05:00:43 +00:00
|
|
|
required this.text,
|
2022-09-28 12:08:04 +00:00
|
|
|
this.leadingIcon,
|
|
|
|
this.leadingIconColor,
|
2022-09-28 05:00:43 +00:00
|
|
|
this.subText,
|
|
|
|
this.textStyle,
|
|
|
|
Key? key,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final enteTheme = Theme.of(context).colorScheme.enteTheme;
|
2022-09-28 11:51:52 +00:00
|
|
|
|
|
|
|
return Flexible(
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
2022-09-28 12:08:04 +00:00
|
|
|
SizedBox(
|
|
|
|
height: 20,
|
|
|
|
width: 20,
|
|
|
|
child: FittedBox(
|
|
|
|
fit: BoxFit.contain,
|
|
|
|
child: Icon(
|
|
|
|
leadingIcon ?? Icons.add_outlined,
|
|
|
|
color: leadingIconColor ?? enteTheme.colorScheme.strokeBase,
|
|
|
|
),
|
|
|
|
),
|
2022-09-28 11:51:52 +00:00
|
|
|
),
|
|
|
|
const SizedBox(width: 12),
|
|
|
|
Flexible(
|
|
|
|
child: RichText(
|
|
|
|
text: TextSpan(
|
2022-09-28 07:24:22 +00:00
|
|
|
style: textStyle ?? enteTheme.textTheme.bodyBold,
|
2022-09-28 11:51:52 +00:00
|
|
|
children: [
|
|
|
|
TextSpan(
|
|
|
|
text: text,
|
|
|
|
),
|
|
|
|
subText != null
|
|
|
|
? TextSpan(
|
|
|
|
text: ' \u2022 ',
|
|
|
|
style: enteTheme.textTheme.small.copyWith(
|
|
|
|
color: enteTheme.colorScheme.textMuted,
|
2022-09-28 05:00:43 +00:00
|
|
|
),
|
2022-09-28 11:51:52 +00:00
|
|
|
)
|
|
|
|
: const TextSpan(text: ''),
|
|
|
|
subText != null
|
|
|
|
? TextSpan(
|
|
|
|
text: subText,
|
2022-09-28 07:24:22 +00:00
|
|
|
style: enteTheme.textTheme.small.copyWith(
|
2022-09-28 08:37:31 +00:00
|
|
|
color: enteTheme.colorScheme.textMuted,
|
|
|
|
),
|
2022-09-28 11:51:52 +00:00
|
|
|
)
|
|
|
|
: const TextSpan(text: ''),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
2022-09-28 05:00:43 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|