@@ -7,7 +7,12 @@ import 'package:waves/features/auth/presentation/widgets/auth_button.dart';
77enum TipSigningMethod { hiveSigner, hiveKeychain, ecency, hiveAuth }
88
99class TipSigningDialog extends StatelessWidget {
10- const TipSigningDialog ({super .key});
10+ const TipSigningDialog ({
11+ super .key,
12+ this .availableMethods = TipSigningMethod .values,
13+ });
14+
15+ final List <TipSigningMethod > availableMethods;
1116
1217 @override
1318 Widget build (BuildContext context) {
@@ -29,29 +34,7 @@ class TipSigningDialog extends StatelessWidget {
2934 theme.textTheme.bodyMedium? .copyWith (color: onSurface),
3035 ),
3136 const Gap (16 ),
32- AuthButton (
33- authType: AuthType .hiveSign,
34- onTap: () => _onSelect (context, TipSigningMethod .hiveSigner),
35- label: LocaleText .signWithSigner,
36- ),
37- const Gap (12 ),
38- AuthButton (
39- authType: AuthType .hiveKeyChain,
40- onTap: () => _onSelect (context, TipSigningMethod .hiveKeychain),
41- label: LocaleText .signWithKeychain,
42- ),
43- const Gap (12 ),
44- AuthButton (
45- authType: AuthType .ecency,
46- onTap: () => _onSelect (context, TipSigningMethod .ecency),
47- label: LocaleText .signWithEcency,
48- ),
49- const Gap (12 ),
50- AuthButton (
51- authType: AuthType .hiveAuth,
52- onTap: () => _onSelect (context, TipSigningMethod .hiveAuth),
53- label: LocaleText .signWithAuth,
54- ),
37+ ..._buildMethodButtons (context),
5538 ],
5639 ),
5740 actions: [
@@ -69,4 +52,46 @@ class TipSigningDialog extends StatelessWidget {
6952 void _onSelect (BuildContext context, TipSigningMethod method) {
7053 Navigator .of (context).pop (method);
7154 }
55+
56+ List <Widget > _buildMethodButtons (BuildContext context) {
57+ final buttons = < Widget > [];
58+ for (var index = 0 ; index < availableMethods.length; index++ ) {
59+ final method = availableMethods[index];
60+ late final AuthType authType;
61+ late final String label;
62+ switch (method) {
63+ case TipSigningMethod .hiveSigner:
64+ authType = AuthType .hiveSign;
65+ label = LocaleText .signWithSigner;
66+ break ;
67+ case TipSigningMethod .hiveKeychain:
68+ authType = AuthType .hiveKeyChain;
69+ label = LocaleText .signWithKeychain;
70+ break ;
71+ case TipSigningMethod .ecency:
72+ authType = AuthType .ecency;
73+ label = LocaleText .signWithEcency;
74+ break ;
75+ case TipSigningMethod .hiveAuth:
76+ authType = AuthType .hiveAuth;
77+ label = LocaleText .signWithAuth;
78+ break ;
79+ }
80+
81+ buttons.add (
82+ AuthButton (
83+ authType: authType,
84+ onTap: () => _onSelect (context, method),
85+ label: label,
86+ ),
87+ );
88+
89+ final isLast = index == availableMethods.length - 1 ;
90+ if (! isLast) {
91+ buttons.add (const Gap (12 ));
92+ }
93+ }
94+
95+ return buttons;
96+ }
7297}
0 commit comments