@@ -8,12 +8,16 @@ class Bip85DerivationWidget extends StatefulWidget {
88 final String xprvBase58;
99 final Bip85DerivationEntity derivation;
1010 final Future <void > Function (Bip85DerivationEntity , String )? onAliasChanged;
11+ final Future <void > Function (Bip85DerivationEntity )? onDerivationRevoked;
12+ final Future <void > Function (Bip85DerivationEntity )? onDerivationActivated;
1113
1214 const Bip85DerivationWidget ({
1315 super .key,
1416 required this .derivation,
1517 required this .xprvBase58,
1618 this .onAliasChanged,
19+ this .onDerivationRevoked,
20+ this .onDerivationActivated,
1721 });
1822
1923 @override
@@ -46,13 +50,27 @@ class _Bip85DerivationWidgetState extends State<Bip85DerivationWidget> {
4650 }
4751 }
4852
53+ Future <void > _revokeDerivation () async {
54+ if (widget.onDerivationRevoked != null ) {
55+ await widget.onDerivationRevoked !(widget.derivation);
56+ }
57+ }
58+
59+ Future <void > _activateDerivation () async {
60+ if (widget.onDerivationActivated != null ) {
61+ await widget.onDerivationActivated !(widget.derivation);
62+ }
63+ }
64+
4965 @override
5066 Widget build (BuildContext context) {
5167 final data = bip85.Bip85Entropy .deriveFromHardenedPath (
5268 xprvBase58: widget.xprvBase58,
5369 path: bip85.Bip85HardenedPath (widget.derivation.path),
5470 );
5571
72+ final isRevoked = widget.derivation.status == Bip85Status .revoked;
73+
5674 return Container (
5775 padding: const EdgeInsets .all (16 ),
5876 decoration: BoxDecoration (
@@ -76,73 +94,91 @@ class _Bip85DerivationWidgetState extends State<Bip85DerivationWidget> {
7694 widget.derivation.status.name,
7795 style: TextStyle (color: context.appColors.text),
7896 ),
97+ if (isRevoked && widget.onDerivationActivated != null )
98+ IconButton (
99+ icon: Icon (Icons .replay, color: context.appColors.success),
100+ onPressed: _activateDerivation,
101+ )
102+ else if (widget.onDerivationRevoked != null && ! isRevoked)
103+ IconButton (
104+ icon: Icon (Icons .block, color: context.appColors.error),
105+ onPressed: _revokeDerivation,
106+ ),
79107 ],
80108 ),
81- Row (
82- children: [
83- Expanded (
84- child: _isEditingAlias
85- ? TextField (
86- controller: _aliasController,
87- autofocus: true ,
88- style: TextStyle (color: context.appColors.text),
89- decoration: InputDecoration (
90- border: OutlineInputBorder (
91- borderSide: BorderSide (
92- color: context.appColors.border,
109+ if (! isRevoked) ...[
110+ Row (
111+ children: [
112+ Expanded (
113+ child: _isEditingAlias
114+ ? TextField (
115+ controller: _aliasController,
116+ autofocus: true ,
117+ style: TextStyle (color: context.appColors.text),
118+ decoration: InputDecoration (
119+ border: OutlineInputBorder (
120+ borderSide: BorderSide (
121+ color: context.appColors.border,
122+ ),
93123 ),
94124 ),
125+ )
126+ : Text (
127+ widget.derivation.alias ?? '' ,
128+ style: TextStyle (color: context.appColors.text),
95129 ),
96- )
97- : Text (
98- widget.derivation.alias ?? '' ,
99- style: TextStyle (color: context.appColors.text),
130+ ),
131+ if (widget.onAliasChanged != null )
132+ if (_isEditingAlias)
133+ IconButton (
134+ icon: Icon (
135+ Icons .check,
136+ color: context.appColors.onSurface,
100137 ),
101- ),
102- if (widget.onAliasChanged != null )
103- if (_isEditingAlias)
104- IconButton (
105- icon: Icon (Icons .check, color: context.appColors.onSurface),
106- onPressed: _saveAlias,
107- )
108- else
109- IconButton (
110- icon: Icon (Icons .edit, color: context.appColors.onSurface),
111- onPressed: () => setState (() => _isEditingAlias = true ),
138+ onPressed: _saveAlias,
139+ )
140+ else
141+ IconButton (
142+ icon: Icon (
143+ Icons .edit,
144+ color: context.appColors.onSurface,
145+ ),
146+ onPressed: () => setState (() => _isEditingAlias = true ),
147+ ),
148+ ],
149+ ),
150+ Row (
151+ children: [
152+ Expanded (
153+ child: TextField (
154+ controller: TextEditingController (text: data),
155+ obscureText: _isObscured,
156+ readOnly: true ,
157+ decoration: const InputDecoration (border: InputBorder .none),
112158 ),
113- ],
114- ),
115- Row (
116- children: [
117- Expanded (
118- child: TextField (
119- controller: TextEditingController (text: data),
120- obscureText: _isObscured,
121- readOnly: true ,
122- decoration: const InputDecoration (border: InputBorder .none),
123159 ),
124- ),
125- IconButton (
126- icon: Icon (
127- _isObscured ? Icons .visibility : Icons .visibility_off,
128- color: context.appColors.onSurface,
160+ IconButton (
161+ icon: Icon (
162+ _isObscured ? Icons .visibility : Icons .visibility_off,
163+ color: context.appColors.onSurface,
164+ ),
165+ onPressed: () => setState (() => _isObscured = ! _isObscured),
129166 ),
130- onPressed: () => setState (() => _isObscured = ! _isObscured),
131- ),
132- IconButton (
133- icon: Icon (Icons .copy, color: context.appColors.onSurface),
134- onPressed: () {
135- Clipboard .setData (ClipboardData (text: data));
136- ScaffoldMessenger .of (context).showSnackBar (
137- const SnackBar (
138- content: Text ('Copied to clipboard' ),
139- duration: Duration (seconds: 1 ),
140- ),
141- );
142- },
143- ),
144- ],
145- ),
167+ IconButton (
168+ icon: Icon (Icons .copy, color: context.appColors.onSurface),
169+ onPressed: () {
170+ Clipboard .setData (ClipboardData (text: data));
171+ ScaffoldMessenger .of (context).showSnackBar (
172+ const SnackBar (
173+ content: Text ('Copied to clipboard' ),
174+ duration: Duration (seconds: 1 ),
175+ ),
176+ );
177+ },
178+ ),
179+ ],
180+ ),
181+ ],
146182 ],
147183 ),
148184 );
0 commit comments