@@ -21,7 +21,6 @@ class _SubscriptionManagementScreenState
2121 final TextEditingController _nameController = TextEditingController ();
2222 final TextEditingController _urlController = TextEditingController ();
2323 bool _isUpdating = false ;
24- bool _isEditingDefaultSubscription = false ;
2524 String ? _currentSubscriptionId;
2625
2726 @override
@@ -123,7 +122,6 @@ class _SubscriptionManagementScreenState
123122 _nameController.clear ();
124123 _urlController.clear ();
125124 _isUpdating = false ;
126- _isEditingDefaultSubscription = false ;
127125 _currentSubscriptionId = null ;
128126 });
129127 }
@@ -133,8 +131,6 @@ class _SubscriptionManagementScreenState
133131 _nameController.text = subscription.name;
134132 _urlController.text = subscription.url;
135133 _isUpdating = true ;
136- _isEditingDefaultSubscription =
137- subscription.name.toLowerCase () == 'default subscription' ;
138134 _currentSubscriptionId = subscription.id;
139135 });
140136 }
@@ -404,82 +400,7 @@ class _SubscriptionManagementScreenState
404400 }
405401 }
406402
407- Future <void > _resetDefaultSubscriptionUrl (
408- BuildContext context,
409- Subscription subscription,
410- ) async {
411- // Show confirmation dialog
412- final confirmed =
413- await showDialog <bool >(
414- context: context,
415- builder: (context) => AlertDialog (
416- backgroundColor: AppTheme .secondaryDark,
417- title: Text (
418- context.tr (
419- TranslationKeys .subscriptionManagementResetDefaultUrlTitle,
420- ),
421- ),
422- content: Text (
423- context.tr (
424- TranslationKeys
425- .subscriptionManagementResetDefaultUrlConfirmation,
426- ),
427- ),
428- actions: [
429- TextButton (
430- onPressed: () => Navigator .pop (context, false ),
431- child: Text (
432- context.tr (TranslationKeys .commonCancel),
433- style: const TextStyle (color: AppTheme .primaryBlue),
434- ),
435- ),
436- TextButton (
437- onPressed: () => Navigator .pop (context, true ),
438- child: Text (
439- context.tr (TranslationKeys .commonOk),
440- style: const TextStyle (color: AppTheme .primaryBlue),
441- ),
442- ),
443- ],
444- ),
445- ) ??
446- false ;
447403
448- if (confirmed) {
449- final provider = Provider .of <V2RayProvider >(context, listen: false );
450-
451- try {
452- // Create updated subscription with default URL
453- final updatedSubscription = subscription.copyWith (
454- url:
455- 'https://raw.githubusercontent.com/darkvpnapp/CloudflarePlus/refs/heads/main/proxy' ,
456- );
457-
458- // Update the subscription
459- await provider.updateSubscriptionInfo (updatedSubscription);
460-
461- ScaffoldMessenger .of (context).showSnackBar (
462- SnackBar (
463- content: Text (
464- context.tr (TranslationKeys .subscriptionManagementDefaultUrlReset),
465- ),
466- ),
467- );
468-
469- // If we were editing this subscription, update the form
470- if (_isUpdating && _currentSubscriptionId == subscription.id) {
471- setState (() {
472- _urlController.text = updatedSubscription.url;
473- });
474- }
475- } catch (e) {
476- ErrorSnackbar .show (
477- context,
478- '${context .tr (TranslationKeys .errorUnknown )}: ${e .toString ()}' ,
479- );
480- }
481- }
482- }
483404
484405 Future <void > _updateAllSubscriptions (BuildContext context) async {
485406 final provider = Provider .of <V2RayProvider >(context, listen: false );
@@ -589,9 +510,7 @@ class _SubscriptionManagementScreenState
589510 const SizedBox (height: 16 ),
590511 TextField (
591512 controller: _nameController,
592- enabled:
593- ! _isUpdating ||
594- (_isUpdating && ! _isEditingDefaultSubscription),
513+ enabled: ! _isUpdating,
595514 decoration: InputDecoration (
596515 labelText: context.tr (
597516 TranslationKeys .subscriptionManagementName,
@@ -750,51 +669,20 @@ class _SubscriptionManagementScreenState
750669 .subscriptionManagementEdit,
751670 ),
752671 ),
753- if (subscription.name.toLowerCase () ==
754- 'default subscription' )
755- IconButton (
756- icon: const Icon (
757- Icons .restart_alt,
758- color: Colors .orange,
759- ),
760- onPressed: () =>
761- _resetDefaultSubscriptionUrl (
762- context,
763- subscription,
764- ),
765- tooltip: context.tr (
766- TranslationKeys
767- .subscriptionManagementResetDefaultUrl,
768- ),
769- ),
672+
770673 IconButton (
771674 icon: Icon (
772675 Icons .delete,
773- color:
774- subscription.name.toLowerCase () ==
775- 'default subscription'
776- ? Colors .grey
777- : Colors .red,
676+ color: Colors .red,
677+ ),
678+ onPressed: () => _deleteSubscription (
679+ context,
680+ subscription,
681+ ),
682+ tooltip: context.tr (
683+ TranslationKeys
684+ .subscriptionManagementDelete,
778685 ),
779- onPressed:
780- subscription.name.toLowerCase () ==
781- 'default subscription'
782- ? null
783- : () => _deleteSubscription (
784- context,
785- subscription,
786- ),
787- tooltip:
788- subscription.name.toLowerCase () ==
789- 'default subscription'
790- ? context.tr (
791- TranslationKeys
792- .subscriptionManagementCannotDeleteDefault,
793- )
794- : context.tr (
795- TranslationKeys
796- .subscriptionManagementDelete,
797- ),
798686 ),
799687 ],
800688 ),
0 commit comments