Skip to content

Commit b1adaeb

Browse files
committed
Version 4.0.4
1 parent adcbecd commit b1adaeb

File tree

8 files changed

+207
-64
lines changed

8 files changed

+207
-64
lines changed

RELEASE_NOTES.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Release Notes
22

3+
---
4+
---
5+
6+
## Version 4.0.4
7+
8+
### Enhancements
9+
10+
- TextField and Slider Changes ([#110](https://github.com/Jules-sh/Reading-Diary/issues/110))
11+
- Color Chooser Update
12+
13+
314
---
415
---
516

lib/blocs/add_entry_bloc.dart

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@ class AddEntryBloc extends Bloc {
2020
/// Corresponding Image to the Entry created
2121
Image? _entryImage;
2222

23+
/// The Page the User started
24+
/// reading on
2325
int? entryStartPage;
2426

27+
/// The Page the User stopped
28+
/// reading on
2529
int? entryEndPage;
2630

2731
/// The book this Entry corresponds to.
@@ -30,6 +34,30 @@ class AddEntryBloc extends Bloc {
3034
// Whether the Done Button is enabled or not.
3135
bool _doneButtonEnabled = false;
3236

37+
/// The Variable that holds the value
38+
/// determing whether the sliver or
39+
/// a textField is used to enter
40+
/// which pages the User read.
41+
bool _pagesReadSliderActive = true;
42+
43+
/// The Variable that holds the value
44+
/// determing whether the sliver or
45+
/// a textField is used to enter
46+
/// which pages the User read.
47+
bool get pagesReadSliderActive => _pagesReadSliderActive;
48+
49+
/// Setter for the Variable that holds the value
50+
/// determing whether the sliver or
51+
/// a textField is used to enter
52+
/// which pages the User read.
53+
set pagesReadSliderActive(bool pRSA) {
54+
if (entryBook != const Book.none()) {
55+
_pagesReadSliderActive = pRSA;
56+
} else {
57+
return;
58+
}
59+
}
60+
3361
/// Setter for the Entry Image
3462
set entryImage(Image image) => _entryImage = image;
3563

@@ -75,7 +103,10 @@ class AddEntryBloc extends Bloc {
75103
if (entryContent.isNotEmpty &&
76104
entryBook != const Book.none() &&
77105
entryStartPage != null &&
78-
entryEndPage != null) {
106+
entryEndPage != null &&
107+
entryStartPage! > 0 &&
108+
entryEndPage! > 0 &&
109+
entryStartPage! < entryEndPage!) {
79110
_doneButtonEnabled = true;
80111
} else {
81112
_doneButtonEnabled = false;

lib/components/mobile/add_model_container_mobile.dart

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ library mobile_components;
33
import 'package:flutter/gestures.dart' show DragStartBehavior;
44
import 'package:flutter/material.dart';
55
import 'package:flutter/services.dart' show MaxLengthEnforcement;
6+
import 'package:helpful_extensions/helpful_extensions.dart';
67

78
/// A Container with an input field and
89
/// the Option to replace that input field
@@ -23,6 +24,7 @@ class AddModelContainerMobile extends StatefulWidget {
2324
this.initialValue,
2425
this.textCapitalization = TextCapitalization.sentences,
2526
this.selectOnTap = false,
27+
this.iconButton,
2628
Key? key,
2729
}) : assert(
2830
child == null && done != null || child != null,
@@ -92,6 +94,10 @@ class AddModelContainerMobile extends StatefulWidget {
9294
/// Text Field.
9395
final bool selectOnTap;
9496

97+
/// An Icon button in the right
98+
/// upper corner of this Widget.
99+
final IconButton? iconButton;
100+
95101
@override
96102
State<StatefulWidget> createState() => _AddModelContainerMobileState();
97103
}
@@ -170,7 +176,37 @@ class _AddModelContainerMobileState extends State<AddModelContainerMobile> {
170176
textDirection: TextDirection.ltr,
171177
verticalDirection: VerticalDirection.down,
172178
children: [
173-
Text(widget.name, style: _tStyle),
179+
widget.iconButton != null
180+
? Row(
181+
mainAxisAlignment: MainAxisAlignment.center,
182+
crossAxisAlignment: CrossAxisAlignment.center,
183+
mainAxisSize: MainAxisSize.max,
184+
textBaseline: TextBaseline.alphabetic,
185+
textDirection: TextDirection.ltr,
186+
verticalDirection: VerticalDirection.down,
187+
children: [
188+
const Spacer(flex: 2),
189+
Text(widget.name, style: _tStyle),
190+
const Spacer(flex: 1),
191+
widget.iconButton != null
192+
? IconButton(
193+
alignment: widget.iconButton!.alignment,
194+
autofocus: widget.iconButton!.autofocus,
195+
constraints: widget.iconButton!.constraints,
196+
enableFeedback: true,
197+
tooltip: widget.iconButton!.tooltip,
198+
style: widget.iconButton!.style,
199+
icon: widget.iconButton!.icon,
200+
onPressed: () =>
201+
widget.iconButton!.onPressed!(),
202+
color: Theme.of(context)
203+
.scaffoldBackgroundColor
204+
.secondaryColor,
205+
)
206+
: Container(),
207+
],
208+
)
209+
: Text(widget.name, style: _tStyle),
174210
const SizedBox(height: 18),
175211
widget.child ??
176212
SizedBox(

lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void main() async {
2424

2525
/// The current Version of the App
2626
/// as a String.
27-
const String appVersion = '4.0.2';
27+
const String appVersion = '4.0.4';
2828

2929
/// Determines the Platform this Apps is running on.
3030
/// Also sets the [WidgetRouter.isDesktop] Variable.

lib/screens/mobile/add_entry_screen_mobile.dart

Lines changed: 115 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ class _AddEntryScreenMobileState extends State<AddEntryScreenMobile> {
102102
children: <Widget>[
103103
AddModelContainerMobile(
104104
name: 'Title'.tr(),
105-
autofocus: true,
106105
maxLines: 1,
107106
done: (title) {
108107
setState(() {
@@ -150,6 +149,18 @@ class _AddEntryScreenMobileState extends State<AddEntryScreenMobile> {
150149
AddModelContainerMobile(
151150
name: 'Pages read'.tr(),
152151
big: true,
152+
iconButton: IconButton(
153+
tooltip: 'Change way of input'.tr(),
154+
onPressed: () {
155+
setState(() {
156+
_bloc!.pagesReadSliderActive =
157+
!_bloc!.pagesReadSliderActive;
158+
});
159+
},
160+
icon: _bloc!.pagesReadSliderActive
161+
? const Icon(Icons.edit)
162+
: const Icon(Icons.edit_attributes_outlined),
163+
),
153164
child: _pagesReadChild,
154165
),
155166
FittedBox(
@@ -260,7 +271,43 @@ class _AddEntryScreenMobileState extends State<AddEntryScreenMobile> {
260271
/// Returns the Widget with which you
261272
/// can make an input, of how many pages you read.
262273
Widget get _pagesReadChild {
263-
if (_bloc!.entryBook == const Book.none()) {
274+
if (_bloc!.pagesReadSliderActive && _bloc!.entryBook != const Book.none()) {
275+
return Column(
276+
crossAxisAlignment: CrossAxisAlignment.center,
277+
mainAxisAlignment: MainAxisAlignment.end,
278+
mainAxisSize: MainAxisSize.max,
279+
textBaseline: TextBaseline.alphabetic,
280+
textDirection: TextDirection.ltr,
281+
children: [
282+
const SizedBox(height: 25),
283+
RangeSlider(
284+
min: 0.0,
285+
max: _bloc!.entryBook.pages.toDouble(),
286+
divisions: _bloc!.entryBook.pages,
287+
onChanged: (RangeValues value) {
288+
setState(() {
289+
_bloc!.entryStartPage = value.start.toInt();
290+
_bloc!.entryEndPage = value.end.toInt();
291+
_bloc!.checkForVars();
292+
});
293+
},
294+
inactiveColor: Coloring.mainColor.withOpacity(.4),
295+
activeColor: Coloring.mainColor,
296+
semanticFormatterCallback: (double newValue) {
297+
return '$newValue pages read';
298+
},
299+
labels: RangeLabels(
300+
_bloc!.entryStartPage.toString(),
301+
_bloc!.entryEndPage.toString(),
302+
),
303+
values: RangeValues(
304+
_bloc!.entryStartPage!.toDouble(),
305+
_bloc!.entryEndPage!.toDouble(),
306+
),
307+
),
308+
],
309+
);
310+
} else {
264311
return Column(
265312
crossAxisAlignment: CrossAxisAlignment.center,
266313
mainAxisAlignment: MainAxisAlignment.spaceBetween,
@@ -269,11 +316,10 @@ class _AddEntryScreenMobileState extends State<AddEntryScreenMobile> {
269316
textDirection: TextDirection.ltr,
270317
verticalDirection: VerticalDirection.down,
271318
children: [
272-
TextField(
319+
TextFormField(
273320
autocorrect: true,
274321
autofocus: false,
275-
clipBehavior: Clip.antiAliasWithSaveLayer,
276-
dragStartBehavior: DragStartBehavior.down,
322+
initialValue: _bloc!.entryStartPage?.toString(),
277323
enableIMEPersonalizedLearning: true,
278324
enableInteractiveSelection: true,
279325
enableSuggestions: true,
@@ -295,20 +341,45 @@ class _AddEntryScreenMobileState extends State<AddEntryScreenMobile> {
295341
paste: true,
296342
selectAll: true,
297343
),
298-
scribbleEnabled: true,
299344
selectionControls: MaterialTextSelectionControls(),
300345
textDirection: TextDirection.ltr,
301346
textInputAction: TextInputAction.next,
302347
maxLines: 1,
303348
minLines: 1,
304-
selectionHeightStyle: BoxHeightStyle.tight,
305-
selectionWidthStyle: BoxWidthStyle.tight,
306349
showCursor: true,
307-
onSubmitted: (str) {
308-
_bloc!.entryStartPage = int.parse(str);
350+
onSaved: (str) {
351+
if (str != null) {
352+
setState(() {
353+
try {
354+
_bloc!.entryStartPage = int.parse(str);
355+
} on Exception catch (_) {
356+
_bloc!.entryStartPage = 0;
357+
}
358+
_bloc!.checkForVars();
359+
});
360+
} else {
361+
return;
362+
}
363+
},
364+
onFieldSubmitted: (str) {
365+
setState(() {
366+
try {
367+
_bloc!.entryStartPage = int.parse(str);
368+
} on Exception catch (_) {
369+
_bloc!.entryStartPage = 0;
370+
}
371+
_bloc!.checkForVars();
372+
});
309373
},
310374
onChanged: (str) {
311-
_bloc!.entryStartPage = int.parse(str);
375+
setState(() {
376+
try {
377+
_bloc!.entryStartPage = int.parse(str);
378+
} on Exception catch (_) {
379+
_bloc!.entryStartPage = 0;
380+
}
381+
_bloc!.checkForVars();
382+
});
312383
},
313384
maxLengthEnforcement:
314385
MaxLengthEnforcement.truncateAfterCompositionEnds,
@@ -317,11 +388,10 @@ class _AddEntryScreenMobileState extends State<AddEntryScreenMobile> {
317388
),
318389
),
319390
const SizedBox(height: 15),
320-
TextField(
391+
TextFormField(
321392
autocorrect: true,
322393
autofocus: false,
323-
clipBehavior: Clip.antiAliasWithSaveLayer,
324-
dragStartBehavior: DragStartBehavior.down,
394+
initialValue: _bloc!.entryEndPage?.toString(),
325395
enableIMEPersonalizedLearning: true,
326396
enableInteractiveSelection: true,
327397
enableSuggestions: true,
@@ -343,20 +413,45 @@ class _AddEntryScreenMobileState extends State<AddEntryScreenMobile> {
343413
paste: true,
344414
selectAll: true,
345415
),
346-
scribbleEnabled: true,
347416
selectionControls: MaterialTextSelectionControls(),
348417
textDirection: TextDirection.ltr,
349418
textInputAction: TextInputAction.next,
350419
maxLines: 1,
351420
minLines: 1,
352-
selectionHeightStyle: BoxHeightStyle.tight,
353-
selectionWidthStyle: BoxWidthStyle.tight,
354421
showCursor: true,
355-
onSubmitted: (str) {
356-
_bloc!.entryEndPage = int.parse(str);
422+
onSaved: (str) {
423+
if (str != null) {
424+
setState(() {
425+
try {
426+
_bloc!.entryEndPage = int.parse(str);
427+
} on Exception catch (_) {
428+
_bloc!.entryEndPage = 0;
429+
}
430+
_bloc!.checkForVars();
431+
});
432+
} else {
433+
return;
434+
}
435+
},
436+
onFieldSubmitted: (str) {
437+
setState(() {
438+
try {
439+
_bloc!.entryEndPage = int.parse(str);
440+
} on Exception catch (_) {
441+
_bloc!.entryEndPage = 0;
442+
}
443+
_bloc!.checkForVars();
444+
});
357445
},
358446
onChanged: (str) {
359-
_bloc!.entryEndPage = int.parse(str);
447+
setState(() {
448+
try {
449+
_bloc!.entryEndPage = int.parse(str);
450+
} on Exception catch (_) {
451+
_bloc!.entryEndPage = 0;
452+
}
453+
_bloc!.checkForVars();
454+
});
360455
},
361456
maxLengthEnforcement:
362457
MaxLengthEnforcement.truncateAfterCompositionEnds,
@@ -366,42 +461,6 @@ class _AddEntryScreenMobileState extends State<AddEntryScreenMobile> {
366461
),
367462
],
368463
);
369-
} else {
370-
return Column(
371-
crossAxisAlignment: CrossAxisAlignment.center,
372-
mainAxisAlignment: MainAxisAlignment.end,
373-
mainAxisSize: MainAxisSize.max,
374-
textBaseline: TextBaseline.alphabetic,
375-
textDirection: TextDirection.ltr,
376-
children: [
377-
const SizedBox(height: 25),
378-
RangeSlider(
379-
min: 0.0,
380-
max: _bloc!.entryBook.pages.toDouble(),
381-
divisions: _bloc!.entryBook.pages,
382-
onChanged: (RangeValues value) {
383-
setState(() {
384-
_bloc!.entryStartPage = value.start.toInt();
385-
_bloc!.entryEndPage = value.end.toInt();
386-
_bloc!.checkForVars();
387-
});
388-
},
389-
inactiveColor: Coloring.mainColor.withOpacity(.4),
390-
activeColor: Coloring.mainColor,
391-
semanticFormatterCallback: (double newValue) {
392-
return '$newValue books read';
393-
},
394-
labels: RangeLabels(
395-
_bloc!.entryStartPage.toString(),
396-
_bloc!.entryEndPage.toString(),
397-
),
398-
values: RangeValues(
399-
_bloc!.entryStartPage!.toDouble(),
400-
_bloc!.entryEndPage!.toDouble(),
401-
),
402-
),
403-
],
404-
);
405464
}
406465
}
407466

0 commit comments

Comments
 (0)