@@ -8,6 +8,7 @@ import 'package:namecoin/namecoin.dart';
88import '../../../models/isar/models/isar_models.dart' ;
99import '../../../providers/db/main_db_provider.dart' ;
1010import '../../../providers/global/secure_store_provider.dart' ;
11+ import '../../../providers/global/wallets_provider.dart' ;
1112import '../../../themes/stack_colors.dart' ;
1213import '../../../utilities/text_styles.dart' ;
1314import '../../../utilities/util.dart' ;
@@ -105,6 +106,47 @@ class _ManageDomainsWidgetState extends ConsumerState<NameDetailsView> {
105106 }
106107 }
107108
109+ (String , Color ) _getExpiry (int currentChainHeight, StackColors theme) {
110+ final String message;
111+ final Color color;
112+
113+ if (utxo? .blockHash == null ) {
114+ message = "Expires in $blocksNameExpiration + blocks" ;
115+ color = theme.accentColorGreen;
116+ } else {
117+ final remaining = opNameData? .expiredBlockLeft (
118+ currentChainHeight,
119+ false ,
120+ );
121+ final semiRemaining = opNameData? .expiredBlockLeft (
122+ currentChainHeight,
123+ true ,
124+ );
125+
126+ if (remaining == null ) {
127+ color = theme.accentColorRed;
128+ message = "Expired" ;
129+ } else {
130+ message = "Expires in $remaining blocks" ;
131+ if (semiRemaining == null ) {
132+ color = theme.accentColorYellow;
133+ } else {
134+ color = theme.accentColorGreen;
135+ }
136+ }
137+ }
138+
139+ return (message, color);
140+ }
141+
142+ bool _checkConfirmedUtxo (int currentHeight) {
143+ return (ref.read (pWallets).getWallet (widget.walletId) as NamecoinWallet )
144+ .checkUtxoConfirmed (
145+ utxo! ,
146+ currentHeight,
147+ );
148+ }
149+
108150 @override
109151 void initState () {
110152 super .initState ();
@@ -140,10 +182,13 @@ class _ManageDomainsWidgetState extends ConsumerState<NameDetailsView> {
140182 Widget build (BuildContext context) {
141183 final currentHeight = ref.watch (pWalletChainHeight (widget.walletId));
142184
143- final isExpired = opNameData? .expired (currentHeight) == true ;
144- final isSemiExpired = opNameData? .expired (currentHeight, true ) == true ;
185+ final (message, color) = _getExpiry (
186+ currentHeight,
187+ Theme .of (context).extension < StackColors > ()! ,
188+ );
145189
146190 final canManage = utxo != null &&
191+ _checkConfirmedUtxo (currentHeight) &&
147192 (opNameData? .op == OpName .nameUpdate ||
148193 opNameData? .op == OpName .nameFirstUpdate);
149194
@@ -616,45 +661,11 @@ class _ManageDomainsWidgetState extends ConsumerState<NameDetailsView> {
616661 const SizedBox (
617662 height: 4 ,
618663 ),
619- Row (
620- children: [
621- SelectableText (
622- isExpired
623- ? "Expired"
624- : "${opNameData !.expiredBlockLeft (currentHeight )!}" ,
625- style: STextStyles .w500_14 (context).copyWith (
626- color: isExpired
627- ? Theme .of (context)
628- .extension < StackColors > ()!
629- .accentColorRed
630- : isSemiExpired
631- ? Theme .of (context)
632- .extension < StackColors > ()!
633- .accentColorYellow
634- : Theme .of (context)
635- .extension < StackColors > ()!
636- .accentColorGreen,
637- ),
638- ),
639- if (! isExpired)
640- Text (
641- " blocks remaining" ,
642- style:
643- STextStyles .w500_14 (context).copyWith (
644- color: isExpired
645- ? Theme .of (context)
646- .extension < StackColors > ()!
647- .accentColorRed
648- : isSemiExpired
649- ? Theme .of (context)
650- .extension < StackColors > ()!
651- .accentColorYellow
652- : Theme .of (context)
653- .extension < StackColors > ()!
654- .accentColorGreen,
655- ),
656- ),
657- ],
664+ SelectableText (
665+ message,
666+ style: STextStyles .w500_14 (context).copyWith (
667+ color: color,
668+ ),
658669 ),
659670 ],
660671 ),
0 commit comments