2022-09-15 21:38:30 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:stackwallet/utilities/text_styles.dart';
|
2022-09-22 23:48:50 +00:00
|
|
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
2022-09-15 21:38:30 +00:00
|
|
|
|
|
|
|
class DesktopMenuItem<T> extends StatelessWidget {
|
|
|
|
const DesktopMenuItem({
|
|
|
|
Key? key,
|
|
|
|
required this.icon,
|
|
|
|
required this.label,
|
|
|
|
required this.value,
|
|
|
|
required this.group,
|
|
|
|
required this.onChanged,
|
2022-09-16 17:26:12 +00:00
|
|
|
required this.iconOnly,
|
2022-09-15 21:38:30 +00:00
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
final Widget icon;
|
|
|
|
final String label;
|
|
|
|
final T value;
|
|
|
|
final T group;
|
|
|
|
final void Function(T) onChanged;
|
2022-09-16 17:26:12 +00:00
|
|
|
final bool iconOnly;
|
2022-09-15 21:38:30 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return TextButton(
|
|
|
|
style: value == group
|
2022-09-22 23:48:50 +00:00
|
|
|
? Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.getDesktopMenuButtonColorSelected(context)
|
|
|
|
: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.getDesktopMenuButtonColor(context),
|
2022-09-15 21:38:30 +00:00
|
|
|
onPressed: () {
|
|
|
|
onChanged(value);
|
|
|
|
},
|
|
|
|
child: Padding(
|
2022-09-16 17:26:12 +00:00
|
|
|
padding: EdgeInsets.symmetric(
|
2022-09-15 21:38:30 +00:00
|
|
|
vertical: 16,
|
2022-09-16 17:26:12 +00:00
|
|
|
horizontal: iconOnly ? 0 : 16,
|
2022-09-15 21:38:30 +00:00
|
|
|
),
|
|
|
|
child: Row(
|
2022-09-16 17:26:12 +00:00
|
|
|
mainAxisAlignment:
|
|
|
|
iconOnly ? MainAxisAlignment.center : MainAxisAlignment.start,
|
2022-09-15 21:38:30 +00:00
|
|
|
children: [
|
|
|
|
icon,
|
2022-09-16 17:26:12 +00:00
|
|
|
if (!iconOnly)
|
|
|
|
const SizedBox(
|
|
|
|
width: 12,
|
|
|
|
),
|
|
|
|
if (!iconOnly)
|
|
|
|
Text(
|
|
|
|
label,
|
|
|
|
style: value == group
|
2022-09-22 22:17:21 +00:00
|
|
|
? STextStyles.desktopMenuItemSelected(context)
|
|
|
|
: STextStyles.desktopMenuItem(context),
|
2022-09-16 17:26:12 +00:00
|
|
|
),
|
2022-09-15 21:38:30 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|