Skip to content

Commit 0b73055

Browse files
add optional description field in divider and move some setting to their respective pages
1 parent 4e03571 commit 0b73055

File tree

6 files changed

+322
-300
lines changed

6 files changed

+322
-300
lines changed

lib/screens/settings/basic_settings.dart

Lines changed: 3 additions & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,7 @@ class BasicSettingsScreen extends StatelessWidget {
3636
TextEditingController(text: state.settingsModel.startat);
3737
TextEditingController endat =
3838
TextEditingController(text: state.settingsModel.endat);
39-
TextEditingController startcreditstext =
40-
TextEditingController(text: state.settingsModel.startcreditstext);
41-
TextEditingController startcreditsnotbefore = TextEditingController(
42-
text: state.settingsModel.startcreditsnotbefore);
43-
TextEditingController startcreditsnotafter = TextEditingController(
44-
text: state.settingsModel.startcreditsnotafter);
45-
TextEditingController startcreditsforatleast = TextEditingController(
46-
text: state.settingsModel.startcreditsforatleast);
47-
TextEditingController startcreditsforatmost = TextEditingController(
48-
text: state.settingsModel.startcreditsforatmost);
49-
TextEditingController endcreditstext =
50-
TextEditingController(text: state.settingsModel.endcreditstext);
51-
TextEditingController endcreditsforatleast = TextEditingController(
52-
text: state.settingsModel.endcreditsforatleast);
53-
TextEditingController endcreditsforatmost = TextEditingController(
54-
text: state.settingsModel.endcreditsforatmost);
39+
5540
return Scaffold(
5641
appBar: AppBar(
5742
flexibleSpace: FlexibleSpaceBar(
@@ -60,7 +45,7 @@ class BasicSettingsScreen extends StatelessWidget {
6045
const EdgeInsets.symmetric(horizontal: 24, vertical: 10),
6146
),
6247
elevation: 0,
63-
toolbarHeight: 120,
48+
toolbarHeight: 110,
6449
backgroundColor: Colors.transparent,
6550
),
6651
body: Padding(
@@ -195,163 +180,7 @@ class BasicSettingsScreen extends StatelessWidget {
195180
},
196181
controller: endat,
197182
),
198-
CustomDivider(title: 'Add credits options'),
199-
CustomTextField(
200-
title: 'Start credits',
201-
subtitle:
202-
'Write this text as start credits. Can be separated with \\n',
203-
onEditingComplete: () {
204-
context.read<SettingsBloc>().add(
205-
SaveSettingsEvent(
206-
state.settingsModel.copyWith(
207-
startcreditstext: startcreditstext.text,
208-
),
209-
),
210-
);
211-
},
212-
controller: startcreditstext,
213-
),
214-
CustomTextField(
215-
title: "Don't start credits before",
216-
subtitle:
217-
"Don't display the start credits before this time (S, or MM:SS).",
218-
onEditingComplete: () {
219-
RegExp(r'^(?:(?:([01]?\d|2[0-3]):)?([0-5]?\d):)?([0-5]?\d)$')
220-
.hasMatch(startcreditsnotbefore.text) ||
221-
startcreditsnotbefore.text.isEmpty
222-
? context.read<SettingsBloc>().add(
223-
SaveSettingsEvent(
224-
state.settingsModel.copyWith(
225-
startcreditsnotbefore:
226-
startcreditsnotbefore.text,
227-
),
228-
),
229-
)
230-
: CustomSnackBarMessage.show(
231-
context, 'Invalid time format');
232-
},
233-
controller: startcreditsnotbefore,
234-
),
235-
CustomTextField(
236-
title: "Don't start credits after",
237-
subtitle:
238-
"Don't display the start credits after this time (S, or MM:SS).",
239-
onEditingComplete: () {
240-
RegExp(r'^(?:(?:([01]?\d|2[0-3]):)?([0-5]?\d):)?([0-5]?\d)$')
241-
.hasMatch(startcreditsnotafter.text) ||
242-
startcreditsnotafter.text.isEmpty
243-
? context.read<SettingsBloc>().add(
244-
SaveSettingsEvent(
245-
state.settingsModel.copyWith(
246-
startcreditsnotafter:
247-
startcreditsnotafter.text,
248-
),
249-
),
250-
)
251-
: CustomSnackBarMessage.show(
252-
context, 'Invalid time format');
253-
},
254-
controller: startcreditsnotafter,
255-
),
256-
CustomTextField(
257-
title: 'Display start credits for atleast',
258-
subtitle:
259-
'Start credits need to be displayed for at least this much time (S, or MM:SS).',
260-
onEditingComplete: () {
261-
RegExp(r'^(?:(?:([01]?\d|2[0-3]):)?([0-5]?\d):)?([0-5]?\d)$')
262-
.hasMatch(startcreditsforatleast.text) ||
263-
startcreditsforatleast.text.isEmpty
264-
? context.read<SettingsBloc>().add(
265-
SaveSettingsEvent(
266-
state.settingsModel.copyWith(
267-
startcreditsforatleast:
268-
startcreditsforatleast.text,
269-
),
270-
),
271-
)
272-
: CustomSnackBarMessage.show(
273-
context, 'Invalid time format');
274-
},
275-
controller: startcreditsforatleast,
276-
),
277-
CustomTextField(
278-
title: 'Display start credits for atmost',
279-
subtitle:
280-
'Start credits need to be displayed for at atmost this much time (S, or MM:SS).',
281-
onEditingComplete: () {
282-
RegExp(r'^(?:(?:([01]?\d|2[0-3]):)?([0-5]?\d):)?([0-5]?\d)$')
283-
.hasMatch(startcreditsforatmost.text) ||
284-
startcreditsforatmost.text.isEmpty
285-
? context.read<SettingsBloc>().add(
286-
SaveSettingsEvent(
287-
state.settingsModel.copyWith(
288-
startcreditsforatmost:
289-
startcreditsforatmost.text,
290-
),
291-
),
292-
)
293-
: CustomSnackBarMessage.show(
294-
context, 'Invalid time format');
295-
},
296-
controller: startcreditsforatmost,
297-
),
298-
CustomTextField(
299-
title: 'End credits',
300-
subtitle:
301-
'Write this text as end credits. Can be separated with \\n',
302-
onEditingComplete: () {
303-
context.read<SettingsBloc>().add(
304-
SaveSettingsEvent(
305-
state.settingsModel.copyWith(
306-
endcreditstext: endcreditstext.text,
307-
),
308-
),
309-
);
310-
},
311-
controller: endcreditstext,
312-
),
313-
CustomTextField(
314-
title: 'Display end credits for atleast',
315-
subtitle:
316-
'End credits need to be displayed for at atleast this much time (S, or MM:SS).',
317-
onEditingComplete: () {
318-
RegExp(r'^(?:(?:([01]?\d|2[0-3]):)?([0-5]?\d):)?([0-5]?\d)$')
319-
.hasMatch(endcreditsforatleast.text) ||
320-
endcreditsforatleast.text.isEmpty
321-
? context.read<SettingsBloc>().add(
322-
SaveSettingsEvent(
323-
state.settingsModel.copyWith(
324-
endcreditsforatleast:
325-
endcreditsforatleast.text,
326-
),
327-
),
328-
)
329-
: CustomSnackBarMessage.show(
330-
context, 'Invalid time format');
331-
},
332-
controller: endcreditsforatleast,
333-
),
334-
CustomTextField(
335-
title: 'Display end credits for atmost',
336-
subtitle:
337-
'End credits need to be displayed for at atmost this much time (S, or MM:SS).',
338-
onEditingComplete: () {
339-
RegExp(r'^(?:(?:([01]?\d|2[0-3]):)?([0-5]?\d):)?([0-5]?\d)$')
340-
.hasMatch(endcreditsforatmost.text) ||
341-
endcreditsforatmost.text.isEmpty
342-
? context.read<SettingsBloc>().add(
343-
SaveSettingsEvent(
344-
state.settingsModel.copyWith(
345-
endcreditsforatmost:
346-
endcreditsforatmost.text,
347-
),
348-
),
349-
)
350-
: CustomSnackBarMessage.show(
351-
context, 'Invalid time format');
352-
},
353-
controller: endcreditsforatmost,
354-
),
183+
355184
],
356185
),
357186
),

lib/screens/settings/components/custom_divider.dart

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import 'package:flutter/material.dart';
22

33
class CustomDivider extends StatelessWidget {
44
final String title;
5-
6-
const CustomDivider({Key? key, required this.title}) : super(key: key);
5+
final String? description;
6+
const CustomDivider({Key? key, required this.title, this.description})
7+
: super(key: key);
78

89
@override
910
Widget build(BuildContext context) {
@@ -12,13 +13,26 @@ class CustomDivider extends StatelessWidget {
1213
children: [
1314
Divider(),
1415
Padding(
15-
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
16-
child: Text(
17-
title,
18-
style: TextStyle(
19-
fontSize: 19,
20-
color: Theme.of(context).colorScheme.secondary,
21-
),
16+
padding: const EdgeInsets.symmetric(horizontal: 15),
17+
child: Column(
18+
crossAxisAlignment: CrossAxisAlignment.start,
19+
children: [
20+
Text(
21+
title,
22+
style: TextStyle(
23+
fontSize: 19,
24+
color: Theme.of(context).colorScheme.secondary,
25+
),
26+
),
27+
if (description != null) SizedBox(height: 10),
28+
Text(
29+
description ?? '',
30+
style: TextStyle(
31+
fontSize: 13,
32+
color: Colors.grey.shade400,
33+
),
34+
),
35+
],
2236
),
2337
),
2438
],

lib/screens/settings/hardsubx_settings.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class HardSubxSettingsScreen extends StatelessWidget {
5151
const EdgeInsets.symmetric(horizontal: 24, vertical: 10),
5252
),
5353
elevation: 0,
54-
toolbarHeight: 120,
54+
toolbarHeight: 110,
5555
backgroundColor: Colors.transparent,
5656
),
5757
body: Padding(

lib/screens/settings/input_settings.dart

Lines changed: 65 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ class InputSettingsScreen extends StatelessWidget {
3131
TextEditingController(text: state.settingsModel.outInterval);
3232
TextEditingController streamController =
3333
TextEditingController(text: state.settingsModel.stream);
34-
TextEditingController minlevdist =
35-
TextEditingController(text: state.settingsModel.minlevdist);
36-
TextEditingController maxlevdist =
37-
TextEditingController(text: state.settingsModel.maxlevdist);
34+
TextEditingController tpageController =
35+
TextEditingController(text: state.settingsModel.tpage);
3836
return Scaffold(
3937
appBar: AppBar(
4038
flexibleSpace: FlexibleSpaceBar(
@@ -43,7 +41,7 @@ class InputSettingsScreen extends StatelessWidget {
4341
const EdgeInsets.symmetric(horizontal: 24, vertical: 10),
4442
),
4543
elevation: 0,
46-
toolbarHeight: 120,
44+
toolbarHeight: 110,
4745
backgroundColor: Colors.transparent,
4846
),
4947
body: Padding(
@@ -284,50 +282,6 @@ class InputSettingsScreen extends StatelessWidget {
284282
);
285283
},
286284
),
287-
CustomDivider(title: 'Levenshtein distance'),
288-
CustomSwitchListTile(
289-
title: 'No Levenshtein distance',
290-
subtitle:
291-
"Don't attempt to correct typos with Levenshtein distance.",
292-
value: state.settingsModel.nolevdist,
293-
onTap: (value) {
294-
context.read<SettingsBloc>().add(
295-
SettingsUpdatedEvent(
296-
state.settingsModel.copyWith(
297-
nolevdist: value,
298-
),
299-
),
300-
);
301-
},
302-
),
303-
CustomTextField(
304-
title: 'Minumin Levenshtein distance count',
305-
intOnly: true,
306-
subtitle:
307-
'Minimum distance we always allow regardless of the length of the strings.Default 2.',
308-
onEditingComplete: () => context.read<SettingsBloc>().add(
309-
SaveSettingsEvent(
310-
state.settingsModel.copyWith(
311-
minlevdist: minlevdist.text,
312-
),
313-
),
314-
),
315-
controller: minlevdist,
316-
),
317-
CustomTextField(
318-
title: 'Maximun eLvenshtein distance percentage',
319-
intOnly: true,
320-
subtitle:
321-
'Maximum distance we allow, as a percentage of the shortest string length. Default 10%.',
322-
onEditingComplete: () => context.read<SettingsBloc>().add(
323-
SaveSettingsEvent(
324-
state.settingsModel.copyWith(
325-
maxlevdist: maxlevdist.text,
326-
),
327-
),
328-
),
329-
controller: maxlevdist,
330-
),
331285
CustomDivider(title: 'Codec settings'),
332286
CustomDropDown(
333287
title: 'Codec',
@@ -361,6 +315,68 @@ class InputSettingsScreen extends StatelessWidget {
361315
);
362316
},
363317
),
318+
CustomDivider(title: 'Teletext settings'),
319+
CustomTextField(
320+
title: 'Teletext page',
321+
subtitle:
322+
'Use this page for subtitles, for example in Spain the page is always 888',
323+
intOnly: true,
324+
onEditingComplete: () => context.read<SettingsBloc>().add(
325+
SaveSettingsEvent(
326+
state.settingsModel.copyWith(
327+
tpage: tpageController.text,
328+
),
329+
),
330+
),
331+
controller: tpageController,
332+
),
333+
CustomSwitchListTile(
334+
title: 'Teletext mode',
335+
subtitle:
336+
'Force teletext mode even if teletext is not detected..',
337+
value: state.settingsModel.teletext,
338+
onTap: (bool value) {
339+
value == true
340+
? context.read<SettingsBloc>().add(
341+
SettingsUpdatedEvent(
342+
state.settingsModel.copyWith(
343+
teletext: value,
344+
noteletext: false,
345+
),
346+
),
347+
)
348+
: context.read<SettingsBloc>().add(
349+
SettingsUpdatedEvent(
350+
state.settingsModel.copyWith(
351+
teletext: value,
352+
),
353+
),
354+
);
355+
},
356+
),
357+
CustomSwitchListTile(
358+
title: 'Disable teletext',
359+
subtitle: 'Disable teletext processing.',
360+
value: state.settingsModel.noteletext,
361+
onTap: (bool value) {
362+
value == true
363+
? context.read<SettingsBloc>().add(
364+
SettingsUpdatedEvent(
365+
state.settingsModel.copyWith(
366+
noteletext: value,
367+
teletext: false,
368+
),
369+
),
370+
)
371+
: context.read<SettingsBloc>().add(
372+
SettingsUpdatedEvent(
373+
state.settingsModel.copyWith(
374+
noteletext: value,
375+
),
376+
),
377+
);
378+
},
379+
),
364380
],
365381
),
366382
),

0 commit comments

Comments
 (0)