2022-10-05 17:37:58 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:stackwallet/utilities/text_styles.dart';
|
|
|
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
|
|
|
|
|
|
|
class SettingsMenuItem<T> extends StatelessWidget {
|
|
|
|
const SettingsMenuItem({
|
|
|
|
Key? key,
|
|
|
|
required this.icon,
|
|
|
|
required this.label,
|
|
|
|
required this.value,
|
|
|
|
required this.group,
|
|
|
|
required this.onChanged,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
final Widget icon;
|
|
|
|
final String label;
|
|
|
|
final T value;
|
|
|
|
final T group;
|
|
|
|
final void Function(T) onChanged;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return TextButton(
|
2022-10-06 18:25:36 +00:00
|
|
|
//if val == group, then button is selected, otherwise unselected
|
2022-10-05 17:37:58 +00:00
|
|
|
style: value == group
|
|
|
|
? Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
2023-01-24 19:29:12 +00:00
|
|
|
.getDesktopSettingsButtonStyle(context)
|
2022-10-05 17:37:58 +00:00
|
|
|
: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
2023-01-24 19:29:12 +00:00
|
|
|
.getDesktopSettingsButtonStyle(context),
|
2022-10-05 17:37:58 +00:00
|
|
|
onPressed: () {
|
|
|
|
onChanged(value);
|
|
|
|
},
|
|
|
|
child: Padding(
|
2022-12-01 16:10:18 +00:00
|
|
|
padding: const EdgeInsets.symmetric(
|
2022-10-05 17:37:58 +00:00
|
|
|
vertical: 16,
|
|
|
|
horizontal: 16,
|
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
icon,
|
|
|
|
const SizedBox(
|
|
|
|
width: 12,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
label,
|
|
|
|
style: value == group //checks if option is selected
|
2022-10-07 00:23:49 +00:00
|
|
|
? STextStyles.settingsMenuItemSelected(context)
|
|
|
|
: STextStyles.settingsMenuItem(context),
|
2022-10-05 17:37:58 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|