@@ -17,6 +17,7 @@ class SubscriptionImportPage extends StatefulWidget {
1717}
1818
1919enum _Method { url, qr, file }
20+
2021enum _ImportState { idle, fetching, success, error }
2122
2223class _SubscriptionImportPageState extends State <SubscriptionImportPage > {
@@ -45,10 +46,10 @@ class _SubscriptionImportPageState extends State<SubscriptionImportPage> {
4546 setState (() => _state = _ImportState .fetching);
4647 try {
4748 final n = await context.read <SubscriptionProvider >().importFromUrl (
48- url: _urlCtrl.text.trim (),
49- name: _nameCtrl.text.trim ().isEmpty ? null : _nameCtrl.text.trim (),
50- autoUpdate: _autoUpdate,
51- );
49+ url: _urlCtrl.text.trim (),
50+ name: _nameCtrl.text.trim ().isEmpty ? null : _nameCtrl.text.trim (),
51+ autoUpdate: _autoUpdate,
52+ );
5253 if (! mounted) return ;
5354 setState (() {
5455 _state = _ImportState .success;
@@ -69,8 +70,8 @@ class _SubscriptionImportPageState extends State<SubscriptionImportPage> {
6970 final l = AppLocalizations .of (context)! ;
7071 final theme = Theme .of (context);
7172 final media = MediaQuery .of (context);
72- final canImport = _urlCtrl.text. trim ().isNotEmpty &&
73- _state != _ImportState .fetching;
73+ final canImport =
74+ _urlCtrl.text. trim ().isNotEmpty && _state != _ImportState .fetching;
7475
7576 return Padding (
7677 padding: EdgeInsets .only (bottom: media.viewInsets.bottom),
@@ -79,14 +80,16 @@ class _SubscriptionImportPageState extends State<SubscriptionImportPage> {
7980 decoration: BoxDecoration (
8081 color: theme.scaffoldBackgroundColor,
8182 borderRadius: const BorderRadius .vertical (
82- top: Radius .circular (AppSpacing .radiusLg)),
83+ top: Radius .circular (AppSpacing .radiusLg),
84+ ),
8385 ),
8486 child: Column (
8587 mainAxisSize: MainAxisSize .min,
8688 children: [
8789 const SizedBox (height: AppSpacing .sm),
8890 Container (
89- width: 40 , height: 4 ,
91+ width: 40 ,
92+ height: 4 ,
9093 decoration: BoxDecoration (
9194 color: AppColors .textMuted.withValues (alpha: 0.3 ),
9295 borderRadius: BorderRadius .circular (2 ),
@@ -95,7 +98,8 @@ class _SubscriptionImportPageState extends State<SubscriptionImportPage> {
9598 const SizedBox (height: AppSpacing .md),
9699 Padding (
97100 padding: const EdgeInsets .symmetric (
98- horizontal: AppSpacing .pageGutter),
101+ horizontal: AppSpacing .pageGutter,
102+ ),
99103 child: Row (
100104 children: [
101105 IconButton (
@@ -132,32 +136,38 @@ class _SubscriptionImportPageState extends State<SubscriptionImportPage> {
132136 onChanged: (_) => setState (() {}),
133137 ),
134138 const SizedBox (height: AppSpacing .sm),
135- Row (children: [
136- _Chip (
137- icon: Icons .content_paste_rounded,
138- label: l.paste,
139- onTap: () async { await _paste (); setState (() {}); },
140- ),
141- const SizedBox (width: AppSpacing .xs),
142- _Chip (
143- icon: Icons .qr_code_scanner_rounded,
144- label: l.scan_qr,
145- onTap: () {
146- // TODO: open camera scanner; on success, set _urlCtrl.
147- },
148- ),
149- ]),
139+ Row (
140+ children: [
141+ _Chip (
142+ icon: Icons .content_paste_rounded,
143+ label: l.paste,
144+ onTap: () async {
145+ await _paste ();
146+ setState (() {});
147+ },
148+ ),
149+ const SizedBox (width: AppSpacing .xs),
150+ _Chip (
151+ icon: Icons .qr_code_scanner_rounded,
152+ label: l.scan_qr,
153+ onTap: () {
154+ // TODO: open camera scanner; on success, set _urlCtrl.
155+ },
156+ ),
157+ ],
158+ ),
150159 const SizedBox (height: AppSpacing .lg),
151160 _FieldLabel (text: l.display_name_optional),
152161 TextField (
153162 controller: _nameCtrl,
154163 decoration: InputDecoration (
155- hintText: 'Hiddify · Public ' ,
164+ hintText: 'Subscription #1 ' ,
156165 filled: true ,
157166 fillColor: theme.colorScheme.surface,
158167 border: OutlineInputBorder (
159- borderRadius:
160- BorderRadius .circular (AppSpacing .radiusMd),
168+ borderRadius: BorderRadius .circular (
169+ AppSpacing .radiusMd,
170+ ),
161171 borderSide: BorderSide .none,
162172 ),
163173 ),
@@ -197,8 +207,9 @@ class _SubscriptionImportPageState extends State<SubscriptionImportPage> {
197207 padding: EdgeInsets .only (bottom: AppSpacing .sm),
198208 child: LinearProgressIndicator (
199209 backgroundColor: Color (0x2900C6FB ),
200- valueColor:
201- AlwaysStoppedAnimation <Color >(AppColors .brandBlue),
210+ valueColor: AlwaysStoppedAnimation <Color >(
211+ AppColors .brandBlue,
212+ ),
202213 ),
203214 ),
204215 SizedBox (
@@ -208,24 +219,28 @@ class _SubscriptionImportPageState extends State<SubscriptionImportPage> {
208219 decoration: BoxDecoration (
209220 gradient: canImport ? AppColors .brandGradient : null ,
210221 color: canImport ? null : const Color (0xFFC8D4DC ),
211- borderRadius:
212- BorderRadius .circular (AppSpacing .radiusMd),
213- boxShadow: canImport
214- ? [
215- BoxShadow (
216- color: AppColors .brandBlue
217- .withValues (alpha: 0.3 ),
218- blurRadius: 16 ,
219- offset: const Offset (0 , 6 ),
220- ),
221- ]
222- : null ,
222+ borderRadius: BorderRadius .circular (
223+ AppSpacing .radiusMd,
224+ ),
225+ boxShadow:
226+ canImport
227+ ? [
228+ BoxShadow (
229+ color: AppColors .brandBlue.withValues (
230+ alpha: 0.3 ,
231+ ),
232+ blurRadius: 16 ,
233+ offset: const Offset (0 , 6 ),
234+ ),
235+ ]
236+ : null ,
223237 ),
224238 child: Material (
225239 color: Colors .transparent,
226240 child: InkWell (
227- borderRadius:
228- BorderRadius .circular (AppSpacing .radiusMd),
241+ borderRadius: BorderRadius .circular (
242+ AppSpacing .radiusMd,
243+ ),
229244 onTap: canImport ? _doImport : null ,
230245 child: Center (
231246 child: Text (
@@ -290,9 +305,8 @@ class _MethodSegment extends StatelessWidget {
290305 child: Text (
291306 it.$2,
292307 style: theme.textTheme.bodyMedium? .copyWith (
293- color: method == it.$1
294- ? Colors .white
295- : AppColors .textMuted,
308+ color:
309+ method == it.$1 ? Colors .white : AppColors .textMuted,
296310 fontWeight: FontWeight .w500,
297311 ),
298312 ),
@@ -315,7 +329,9 @@ class _UrlField extends StatelessWidget {
315329 final l = AppLocalizations .of (context)! ;
316330 return Container (
317331 padding: const EdgeInsets .symmetric (
318- horizontal: AppSpacing .md, vertical: AppSpacing .sm),
332+ horizontal: AppSpacing .md,
333+ vertical: AppSpacing .sm,
334+ ),
319335 decoration: BoxDecoration (
320336 color: theme.colorScheme.surface,
321337 borderRadius: BorderRadius .circular (AppSpacing .radiusMd),
@@ -353,14 +369,22 @@ class _Chip extends StatelessWidget {
353369 onTap: onTap,
354370 child: Padding (
355371 padding: const EdgeInsets .symmetric (
356- horizontal: AppSpacing .sm, vertical: 6 ),
357- child: Row (mainAxisSize: MainAxisSize .min, children: [
358- Icon (icon, size: 16 , color: theme.colorScheme.primary),
359- const SizedBox (width: 6 ),
360- Text (label,
361- style: theme.textTheme.bodySmall
362- ? .copyWith (color: theme.colorScheme.primary)),
363- ]),
372+ horizontal: AppSpacing .sm,
373+ vertical: 6 ,
374+ ),
375+ child: Row (
376+ mainAxisSize: MainAxisSize .min,
377+ children: [
378+ Icon (icon, size: 16 , color: theme.colorScheme.primary),
379+ const SizedBox (width: 6 ),
380+ Text (
381+ label,
382+ style: theme.textTheme.bodySmall? .copyWith (
383+ color: theme.colorScheme.primary,
384+ ),
385+ ),
386+ ],
387+ ),
364388 ),
365389 ),
366390 );
@@ -374,11 +398,12 @@ class _FieldLabel extends StatelessWidget {
374398 Widget build (BuildContext context) {
375399 return Padding (
376400 padding: const EdgeInsets .only (left: 4 , bottom: 6 ),
377- child: Text (text,
378- style: Theme .of (context)
379- .textTheme
380- .bodySmall
381- ? .copyWith (color: AppColors .textMuted)),
401+ child: Text (
402+ text,
403+ style: Theme .of (
404+ context,
405+ ).textTheme.bodySmall? .copyWith (color: AppColors .textMuted),
406+ ),
382407 );
383408 }
384409}
@@ -399,9 +424,12 @@ class _AutoUpdateRow extends StatelessWidget {
399424 children: [
400425 Text (l.auto_update, style: theme.textTheme.titleMedium),
401426 const SizedBox (height: 2 ),
402- Text (l.auto_update_hint,
403- style: theme.textTheme.bodySmall
404- ? .copyWith (color: AppColors .textMuted)),
427+ Text (
428+ l.auto_update_hint,
429+ style: theme.textTheme.bodySmall? .copyWith (
430+ color: AppColors .textMuted,
431+ ),
432+ ),
405433 ],
406434 ),
407435 ),
@@ -420,17 +448,22 @@ class _Toast extends StatelessWidget {
420448 Widget build (BuildContext context) {
421449 return Container (
422450 padding: const EdgeInsets .symmetric (
423- horizontal: AppSpacing .md, vertical: AppSpacing .sm),
451+ horizontal: AppSpacing .md,
452+ vertical: AppSpacing .sm,
453+ ),
424454 decoration: BoxDecoration (
425455 color: color.withValues (alpha: 0.12 ),
426456 borderRadius: BorderRadius .circular (AppSpacing .radiusMd),
427457 ),
428- child: Row (children: [
429- Icon (icon, color: color, size: 20 ),
430- const SizedBox (width: AppSpacing .xs),
431- Expanded (
432- child: Text (text, style: Theme .of (context).textTheme.bodyMedium)),
433- ]),
458+ child: Row (
459+ children: [
460+ Icon (icon, color: color, size: 20 ),
461+ const SizedBox (width: AppSpacing .xs),
462+ Expanded (
463+ child: Text (text, style: Theme .of (context).textTheme.bodyMedium),
464+ ),
465+ ],
466+ ),
434467 );
435468 }
436469}
0 commit comments