Cleaned up the repo
Singed-off-by: Andreas Fahrecker <AndreasFahrecker@gmail.com>
This commit is contained in:
32
lib/ui/screens/active_time_progresses_screen.dart
Normal file
32
lib/ui/screens/active_time_progresses_screen.dart
Normal file
@ -0,0 +1,32 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
|
||||
import 'package:time_progress_tracker/redux/store_connectors/settings_store_connector.dart';
|
||||
import 'package:time_progress_tracker/redux/store_connectors/time_progress_list_store_connector.dart';
|
||||
import 'package:time_progress_tracker/utils/helper_functions.dart';
|
||||
import 'package:time_progress_tracker/models/time_progress.dart';
|
||||
import 'package:time_progress_tracker/ui/progress/progress_list_view.dart';
|
||||
|
||||
class ActiveTimeProgressesScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SettingsStoreConnector(loadedBuilder: (context, settingsVm) {
|
||||
return TimeProgressListStoreConnector(loadedBuilder: (context, tpListVm) {
|
||||
List<TimeProgress> activeTpList =
|
||||
selectActiveProgresses(tpListVm.tpList);
|
||||
if (activeTpList.length < 1)
|
||||
return Container(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Center(
|
||||
child: PlatformText(
|
||||
"You don't have any active time progress, that are tracked."),
|
||||
),
|
||||
);
|
||||
return ProgressListView(
|
||||
timeProgressList: activeTpList,
|
||||
doneColor: settingsVm.appSettings.doneColor,
|
||||
leftColor: settingsVm.appSettings.leftColor,
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
85
lib/ui/screens/dashboard_screen.dart
Normal file
85
lib/ui/screens/dashboard_screen.dart
Normal file
@ -0,0 +1,85 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
|
||||
import 'package:time_progress_tracker/ui/screens/active_time_progresses_screen.dart';
|
||||
import 'package:time_progress_tracker/ui/screens/inactive_time_progresses_screen.dart';
|
||||
import 'package:time_progress_tracker/ui/screens/settings_screen.dart';
|
||||
import 'package:time_progress_tracker/utils/color_utils.dart';
|
||||
import 'package:time_progress_tracker/utils/constants.dart';
|
||||
|
||||
class DashboardScreen extends StatefulWidget {
|
||||
static const routeName = "/dashboard";
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _DashboardScreenState();
|
||||
}
|
||||
|
||||
class _DashboardScreenState extends State<DashboardScreen> {
|
||||
int _tabSelectedIndex = 0;
|
||||
String title = txtActiveProgressesScreen;
|
||||
|
||||
Widget _renderTabScreen(int tabIndex) {
|
||||
switch (tabIndex) {
|
||||
case 1:
|
||||
return InactiveTimeProgressesScreen();
|
||||
case 2:
|
||||
return SettingsScreen();
|
||||
default:
|
||||
return ActiveTimeProgressesScreen();
|
||||
}
|
||||
}
|
||||
|
||||
String getScreenTitle(int tabIndex) {
|
||||
switch (tabIndex) {
|
||||
case 1:
|
||||
return txtInactiveProgressesScreen;
|
||||
case 2:
|
||||
return txtSettingsScreen;
|
||||
default:
|
||||
return txtActiveProgressesScreen;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PlatformScaffold(
|
||||
appBar: PlatformAppBar(
|
||||
title: Text(
|
||||
title,
|
||||
style: toolbarTextStyle,
|
||||
),
|
||||
cupertino: (_, __) => CupertinoNavigationBarData(
|
||||
transitionBetweenRoutes: false,
|
||||
),
|
||||
),
|
||||
material: (_, __) => MaterialScaffoldData(),
|
||||
body: _renderTabScreen(_tabSelectedIndex),
|
||||
bottomNavBar: PlatformNavBar(
|
||||
currentIndex: _tabSelectedIndex,
|
||||
itemChanged: (index) {
|
||||
setState(() {
|
||||
_tabSelectedIndex = index;
|
||||
title = getScreenTitle(index);
|
||||
});
|
||||
},
|
||||
backgroundColor: bottomTabsBackground,
|
||||
items: [
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.alarm, color: Colors.grey),
|
||||
label: txtActiveProgressesScreen,
|
||||
activeIcon: Icon(Icons.alarm, color: Colors.white),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.alarm_off, color: Colors.grey),
|
||||
label: txtInactiveProgressesScreen,
|
||||
activeIcon: Icon(Icons.alarm_off, color: Colors.white),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.settings, color: Colors.grey),
|
||||
label: txtSettingsScreen,
|
||||
activeIcon: Icon(Icons.settings, color: Colors.white),
|
||||
)
|
||||
]),
|
||||
);
|
||||
}
|
||||
}
|
32
lib/ui/screens/inactive_time_progresses_screen.dart
Normal file
32
lib/ui/screens/inactive_time_progresses_screen.dart
Normal file
@ -0,0 +1,32 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
|
||||
import 'package:time_progress_tracker/redux/store_connectors/settings_store_connector.dart';
|
||||
import 'package:time_progress_tracker/redux/store_connectors/time_progress_list_store_connector.dart';
|
||||
import 'package:time_progress_tracker/utils/helper_functions.dart';
|
||||
import 'package:time_progress_tracker/models/time_progress.dart';
|
||||
import 'package:time_progress_tracker/ui/progress/progress_list_view.dart';
|
||||
|
||||
class InactiveTimeProgressesScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SettingsStoreConnector(loadedBuilder: (context, settingsVm) {
|
||||
return TimeProgressListStoreConnector(loadedBuilder: (context, tpListVm) {
|
||||
List<TimeProgress> activeTpList =
|
||||
selectInactiveProgresses(tpListVm.tpList);
|
||||
if (activeTpList.length < 1)
|
||||
return Container(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Center(
|
||||
child: PlatformText(
|
||||
"You don't have any inactive time progress, that are tracked."),
|
||||
),
|
||||
);
|
||||
return ProgressListView(
|
||||
timeProgressList: activeTpList,
|
||||
doneColor: settingsVm.appSettings.doneColor,
|
||||
leftColor: settingsVm.appSettings.leftColor,
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
117
lib/ui/screens/progress_creation_screen.dart
Normal file
117
lib/ui/screens/progress_creation_screen.dart
Normal file
@ -0,0 +1,117 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
import 'package:time_progress_tracker/models/app_settings.dart';
|
||||
import 'package:time_progress_tracker/redux/actions/time_progress_actions.dart';
|
||||
import 'package:time_progress_tracker/redux/app_state.dart';
|
||||
import 'package:time_progress_tracker/models/time_progress.dart';
|
||||
import 'package:time_progress_tracker/redux/redux_selectors.dart';
|
||||
import 'package:time_progress_tracker/utils/helper_functions.dart';
|
||||
import 'package:time_progress_tracker/ui/progress/progress_editor_widget.dart';
|
||||
|
||||
class ProgressCreationScreen extends StatefulWidget {
|
||||
static const routeName = "/create-progress";
|
||||
static const title = "Create Time Progress";
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _ProgressCreationScreenState();
|
||||
}
|
||||
}
|
||||
|
||||
class _ProgressCreationScreenState extends State<ProgressCreationScreen> {
|
||||
TimeProgress timeProgressToCreate;
|
||||
bool _isProgressValid = false;
|
||||
|
||||
void initTimeProgress(TimeProgress timeProgress) {
|
||||
if (timeProgressToCreate == null)
|
||||
setState(() {
|
||||
timeProgressToCreate = timeProgress;
|
||||
});
|
||||
}
|
||||
|
||||
void onTimeProgressChanged(
|
||||
TimeProgress newTimeProgress, bool isNewProgressValid) {
|
||||
setState(() {
|
||||
timeProgressToCreate = newTimeProgress;
|
||||
_isProgressValid = isNewProgressValid;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(ProgressCreationScreen.title),
|
||||
),
|
||||
body: Container(
|
||||
padding: EdgeInsets.all(12),
|
||||
child: StoreConnector<AppState, _ViewModel>(
|
||||
onInit: loadSettingsIfUnloaded,
|
||||
converter: (store) => _ViewModel.create(store),
|
||||
builder: (context, _ViewModel viewModel) {
|
||||
initTimeProgress(viewModel.defaultDurationProgress);
|
||||
return ProgressEditorWidget(
|
||||
timeProgress: timeProgressToCreate,
|
||||
onTimeProgressChanged: onTimeProgressChanged,
|
||||
);
|
||||
}),
|
||||
),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
|
||||
floatingActionButton: Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: StoreConnector<AppState, _ViewModel>(
|
||||
onInit: loadSettingsIfUnloaded,
|
||||
converter: (store) => _ViewModel.create(store),
|
||||
builder: (context, _ViewModel vm) => FloatingActionButton(
|
||||
heroTag: "createTimeProgressBTN",
|
||||
child: Icon(Icons.save),
|
||||
onPressed: _isProgressValid
|
||||
? () {
|
||||
vm.onAddTimeProgress(timeProgressToCreate);
|
||||
Navigator.pop(context);
|
||||
}
|
||||
: null,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: FloatingActionButton(
|
||||
heroTag: "cancelTimeProgressCreationBTN",
|
||||
child: Icon(Icons.cancel),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ViewModel {
|
||||
final TimeProgress defaultDurationProgress;
|
||||
final void Function(TimeProgress) onAddTimeProgress;
|
||||
|
||||
_ViewModel({
|
||||
@required this.defaultDurationProgress,
|
||||
@required this.onAddTimeProgress,
|
||||
});
|
||||
|
||||
factory _ViewModel.create(Store<AppState> store) {
|
||||
AppSettings settings = appSettingsSelector(store.state);
|
||||
|
||||
_onAddTimeProgress(TimeProgress tp) {
|
||||
if (TimeProgress.isValid(tp)) store.dispatch(AddTimeProgressAction(tp));
|
||||
}
|
||||
|
||||
return _ViewModel(
|
||||
defaultDurationProgress:
|
||||
TimeProgress.defaultFromDuration(settings.duration),
|
||||
onAddTimeProgress: _onAddTimeProgress,
|
||||
);
|
||||
}
|
||||
}
|
129
lib/ui/screens/progress_detail_screen.dart
Normal file
129
lib/ui/screens/progress_detail_screen.dart
Normal file
@ -0,0 +1,129 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:time_progress_tracker/models/time_progress.dart';
|
||||
import 'package:time_progress_tracker/redux/store_connectors/settings_store_connector.dart';
|
||||
import 'package:time_progress_tracker/redux/store_connectors/time_progress_store_connector.dart';
|
||||
import 'package:time_progress_tracker/ui/screens/dashboard_screen.dart';
|
||||
import 'package:time_progress_tracker/ui/detail_screen_floating_action_buttons.dart';
|
||||
import 'package:time_progress_tracker/ui/progress/progress_editor_widget.dart';
|
||||
import 'package:time_progress_tracker/ui/progress/progress_view_widget.dart';
|
||||
|
||||
class ProgressDetailScreenArguments {
|
||||
final String id;
|
||||
|
||||
ProgressDetailScreenArguments(this.id);
|
||||
}
|
||||
|
||||
class ProgressDetailScreen extends StatefulWidget {
|
||||
static const routeName = "/progress";
|
||||
static const title = "Progress View";
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _ProgressDetailScreenState();
|
||||
}
|
||||
}
|
||||
|
||||
class _ProgressDetailScreenState extends State<ProgressDetailScreen> {
|
||||
bool _editMode = false, _isEditedProgressValid = false;
|
||||
TimeProgress _editedProgress, _originalProgress;
|
||||
|
||||
void _initEditedProgress(TimeProgress tp) {
|
||||
if (_editedProgress == null) {
|
||||
_editedProgress = tp;
|
||||
_originalProgress = tp;
|
||||
}
|
||||
}
|
||||
|
||||
void _onEditedProgressChanged(
|
||||
TimeProgress newProgress, bool isNewProgressValid) {
|
||||
setState(() {
|
||||
_editedProgress = newProgress;
|
||||
_isEditedProgressValid = isNewProgressValid;
|
||||
});
|
||||
}
|
||||
|
||||
void _switchEditMode(bool newMode) {
|
||||
setState(() {
|
||||
_editMode = newMode;
|
||||
});
|
||||
}
|
||||
|
||||
void _cancelEditMode() {
|
||||
setState(() {
|
||||
_editMode = false;
|
||||
_editedProgress = _originalProgress;
|
||||
});
|
||||
}
|
||||
|
||||
List<Widget> _renderColumnChildren(
|
||||
SettingsViewModel settingsVm, TimeProgressViewModel tpVm) {
|
||||
List<Widget> columnChildren = [
|
||||
Expanded(
|
||||
child: ProgressViewWidget(
|
||||
timeProgress: _editMode ? _editedProgress : tpVm.tp,
|
||||
doneColor: settingsVm.appSettings.doneColor,
|
||||
leftColor: settingsVm.appSettings.leftColor,
|
||||
))
|
||||
];
|
||||
if (_editMode)
|
||||
columnChildren.add(Expanded(
|
||||
child: ProgressEditorWidget(
|
||||
timeProgress: _editedProgress,
|
||||
onTimeProgressChanged: _onEditedProgressChanged,
|
||||
)));
|
||||
return columnChildren;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ProgressDetailScreenArguments args =
|
||||
ModalRoute.of(context).settings.arguments;
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(ProgressDetailScreen.title),
|
||||
),
|
||||
body: SettingsStoreConnector(
|
||||
loadedBuilder: (context, settingsVm) {
|
||||
return TimeProgressStoreConnector(
|
||||
timeProgressId: args.id,
|
||||
loadedBuilder: (context, tpVm) {
|
||||
_initEditedProgress(tpVm.tp);
|
||||
return Container(
|
||||
margin: EdgeInsets.all(8),
|
||||
child: Column(
|
||||
children: _renderColumnChildren(settingsVm, tpVm),
|
||||
));
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
|
||||
floatingActionButton: TimeProgressStoreConnector(
|
||||
timeProgressId: args.id,
|
||||
loadedBuilder: (context, tpVm) {
|
||||
void _saveEditedProgress() {
|
||||
tpVm.updateTimeProgress(_editedProgress);
|
||||
_switchEditMode(false);
|
||||
}
|
||||
|
||||
void _deleteTimeProgress() {
|
||||
tpVm.deleteTimeProgress();
|
||||
Navigator.popUntil(
|
||||
context, ModalRoute.withName(DashboardScreen.routeName));
|
||||
}
|
||||
|
||||
return DetailScreenFloatingActionButtons(
|
||||
editMode: _editMode,
|
||||
originalProgress: tpVm.tp,
|
||||
editedProgress: _editedProgress,
|
||||
isEditedProgressValid: _isEditedProgressValid,
|
||||
onEditProgress: () => _switchEditMode(true),
|
||||
onSaveEditedProgress: _saveEditedProgress,
|
||||
onCancelEditProgress: _cancelEditMode,
|
||||
onDeleteProgress: _deleteTimeProgress);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
89
lib/ui/screens/settings_screen.dart
Normal file
89
lib/ui/screens/settings_screen.dart
Normal file
@ -0,0 +1,89 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
|
||||
import 'package:time_progress_tracker/app.dart';
|
||||
import 'package:time_progress_tracker/redux/store_connectors/settings_store_connector.dart';
|
||||
import 'package:time_progress_tracker/ui/buttons/color_picker_btn.dart';
|
||||
import 'package:time_progress_tracker/ui/settings/duration_settings_widget.dart';
|
||||
|
||||
class SettingsScreen extends StatelessWidget {
|
||||
Widget _renderColorSettings(
|
||||
BuildContext context, SettingsViewModel settingsVm) {
|
||||
ThemeData appTheme = Theme.of(context);
|
||||
return Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: PlatformText(
|
||||
"Color Settings",
|
||||
style: appTheme.primaryTextTheme.caption,
|
||||
)),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(right: 5),
|
||||
child: ColorPickerButton(
|
||||
title: "Done Color",
|
||||
dialogTitle: "Select Done Color",
|
||||
selectedColor: settingsVm.appSettings.doneColor,
|
||||
onColorPicked: settingsVm.updateDoneColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(left: 5),
|
||||
child: ColorPickerButton(
|
||||
title: "Left Color",
|
||||
dialogTitle: "Select Left Color",
|
||||
selectedColor: settingsVm.appSettings.leftColor,
|
||||
onColorPicked: settingsVm.updateLeftColor,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SettingsStoreConnector(loadedBuilder: (context, settingsVm) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _renderColorSettings(context, settingsVm),
|
||||
),
|
||||
Expanded(
|
||||
child: DurationSettingsWidget(
|
||||
duration: settingsVm.appSettings.duration,
|
||||
updateDuration: settingsVm.updateDuration,
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
Expanded(
|
||||
child: PlatformButton(
|
||||
onPressed: () {
|
||||
showAboutDialog(
|
||||
context: context,
|
||||
applicationName: TimeProgressTrackerApp.name,
|
||||
applicationVersion: "Beta",
|
||||
applicationLegalese:
|
||||
'\u00a9Andreas Fahrecker 2020-2021');
|
||||
},
|
||||
child: Text("About"),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user