Feature/code cleanup (#9)
* Implemented hasSettingsLoaded reducer * Added Padding to Progress List View * Created Settings and Time Progress List Store Connector * Rewritten Home Active Tab * Fixed missing onTap in Progress List Tile * Started using new Store Connectors in Inactive and Settings Tab * Created Time Progress Store Connector * Rewritten ProgressDetailScreen with new Store Connectors * Rewritten DatePickerBtn with TextButton * Deleted unused widget * Changed Foreground Color behaviour in ColorPicker BTN * Created Select Duration Button * Rewritten Duration Setting Widget * Updated Version Number Signed-off-by: Andreas Fahrecker <AndreasFahrecker@gmail.com>
This commit is contained in:
committed by
GitHub
parent
fc35476503
commit
40bdcc44f9
@ -1,49 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
|
||||
|
||||
class ColorPickerButton extends StatelessWidget {
|
||||
final String title, dialogTitle;
|
||||
final Color selectedColor;
|
||||
final void Function(Color) onColorPicked;
|
||||
|
||||
ColorPickerButton({
|
||||
@required this.title,
|
||||
@required this.dialogTitle,
|
||||
@required this.selectedColor,
|
||||
@required this.onColorPicked,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Color getBtnPrimaryColor() => Color.fromARGB(
|
||||
selectedColor.alpha,
|
||||
selectedColor.alpha - selectedColor.red,
|
||||
selectedColor.alpha - selectedColor.green,
|
||||
selectedColor.alpha - selectedColor.blue,
|
||||
);
|
||||
|
||||
return TextButton(
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: Text(dialogTitle),
|
||||
content: SingleChildScrollView(
|
||||
child: BlockPicker(
|
||||
pickerColor: selectedColor,
|
||||
onColorChanged: onColorPicked,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Text(title),
|
||||
style: TextButton.styleFrom(
|
||||
primary: getBtnPrimaryColor(),
|
||||
backgroundColor: selectedColor,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:time_progress_tracker/widgets/home/tabs/settings/color_picker_btn.dart';
|
||||
import 'package:time_progress_tracker/widgets/buttons/color_picker_btn.dart';
|
||||
|
||||
class ColorSettingsWidget extends StatelessWidget {
|
||||
final Color doneColor, leftColor;
|
||||
@ -14,13 +14,14 @@ class ColorSettingsWidget extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
ThemeData appTheme = Theme.of(context);
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"Color Settings",
|
||||
style:
|
||||
TextStyle(fontWeight: FontWeight.bold, color: Colors.black87),
|
||||
style: appTheme.textTheme.headline6,
|
||||
),
|
||||
),
|
||||
Row(
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_picker/flutter_picker.dart';
|
||||
import 'package:time_progress_tracker/widgets/buttons/select_duration_btn.dart';
|
||||
|
||||
class DurationSettingsWidget extends StatelessWidget {
|
||||
final Duration duration;
|
||||
@ -12,49 +12,29 @@ class DurationSettingsWidget extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
ThemeData appTheme = Theme.of(context);
|
||||
|
||||
int years = duration.inDays ~/ 365;
|
||||
int months = (duration.inDays - (365 * years)) ~/ 30;
|
||||
int days = duration.inDays - (365 * years) - (30 * months);
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
Picker(
|
||||
adapter: NumberPickerAdapter(
|
||||
data: [
|
||||
const NumberPickerColumn(
|
||||
begin: 0,
|
||||
end: 999,
|
||||
suffix: Text(" Y"),
|
||||
),
|
||||
const NumberPickerColumn(
|
||||
begin: 0,
|
||||
end: 11,
|
||||
suffix: Text(" M"),
|
||||
),
|
||||
const NumberPickerColumn(
|
||||
begin: 0,
|
||||
end: 30,
|
||||
suffix: Text(" D"),
|
||||
),
|
||||
],
|
||||
),
|
||||
hideHeader: true,
|
||||
confirmText: "OK",
|
||||
title: const Text("Select Duration"),
|
||||
selectedTextStyle: TextStyle(color: Colors.blue),
|
||||
onConfirm: (Picker picker, List<int> value) {
|
||||
int years = value[0], months = value[1], days = value[2];
|
||||
days = (years * 365) + (months * 30) + days;
|
||||
Duration newDuration = Duration(days: days);
|
||||
updateDuration(newDuration);
|
||||
},
|
||||
).showDialog(context);
|
||||
},
|
||||
child: Text("Default Duration: $years Y - $months M - $days D"),
|
||||
child: Text(
|
||||
"Duration Settings",
|
||||
style: appTheme.textTheme.headline6,
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SelectDurationBtn(
|
||||
duration: duration,
|
||||
updateDuration: updateDuration,
|
||||
),
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user