dev
dart 113 lines 3.74 KB
Raw
1 import 'package:flutter/material.dart';
2 import 'package:cake_wallet/src/widgets/base_alert_dialog.dart';
3
4 class AlertWithPickerOption extends BaseAlertDialog {
5 AlertWithPickerOption(
6 {required this.alertTitle,
7 required this.alertTitleTextSize,
8 required this.alertSubtitle,
9 required this.options,
10 this.onOptionSelected,
11 this.alertBarrierDismissible = true,
12 Key? key});
13
14 final String alertTitle;
15 final double alertTitleTextSize;
16 final String alertSubtitle;
17 final List<Map<String, String>> options;
18 final ValueChanged<Map<String, String>>? onOptionSelected;
19 final bool alertBarrierDismissible;
20
21 @override
22 String get titleText => alertTitle;
23
24 @override
25 double? get titleTextSize => alertTitleTextSize;
26
27 @override
28 String get contentText => alertSubtitle;
29
30 @override
31 bool get barrierDismissible => alertBarrierDismissible;
32
33 @override
34 Widget actionButtons(BuildContext context) => Container();
35
36 @override
37 bool get isBottomDividerExists => false;
38
39 @override
40 Widget content(BuildContext context) {
41 return Column(
42 mainAxisSize: MainAxisSize.min,
43 children: [
44 const SizedBox(height: 16),
45 Text(
46 contentText,
47 textAlign: TextAlign.center,
48 style: Theme.of(context).textTheme.bodyMedium!.copyWith(
49 fontSize: 10,
50 fontWeight: FontWeight.w500,
51 color: Theme.of(context).colorScheme.onSurface,
52 decoration: TextDecoration.none,
53 ),
54 ),
55 const SizedBox(height: 4),
56 Container(
57 constraints: const BoxConstraints(maxHeight: 200),
58 child: ListView.separated(
59 shrinkWrap: true,
60 padding: EdgeInsets.zero,
61 separatorBuilder: (context, index) => const SizedBox(height: 8),
62 itemCount: options.length,
63 itemBuilder: (context, index) {
64 final item = options[index];
65 final displayKey = item['displayKey'] ?? '';
66 final displayValue = item['displayValue'] ?? '';
67 return GestureDetector(
68 onTap: () {
69 onOptionSelected?.call(item);
70 Navigator.of(context).pop();
71 },
72 child: Container(
73 width: double.infinity,
74 padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 12),
75 decoration: BoxDecoration(
76 borderRadius: BorderRadius.circular(30),
77 color: Theme.of(context).colorScheme.surface),
78 child: Row(
79 mainAxisAlignment: MainAxisAlignment.spaceBetween,
80 children: [
81 Text(
82 displayKey,
83 style: Theme.of(context).textTheme.bodySmall!.copyWith(
84 decoration: TextDecoration.none,
85 ),
86 ),
87 Row(
88 children: [
89 Text(
90 displayValue,
91 style: Theme.of(context).textTheme.bodySmall!.copyWith(
92 decoration: TextDecoration.none,
93 ),
94 ),
95 const SizedBox(width: 4),
96 Icon(
97 Icons.arrow_forward_ios,
98 size: 18,
99 color: Theme.of(context).colorScheme.onSurface,
100 ),
101 ],
102 ),
103 ],
104 ),
105 ),
106 );
107 },
108 ),
109 ),
110 ],
111 );
112 }
113 }