This commit is contained in:
Hillel Coren 2018-12-20 16:12:31 +02:00
parent 97e772825f
commit 67d372f996
10 changed files with 66 additions and 23 deletions

View File

@ -14,6 +14,7 @@ const String kSharedPrefUrl = 'url';
const String kSharedPrefSecret = 'secret'; const String kSharedPrefSecret = 'secret';
const String kSharedPrefEnableDarkMode = 'enable_dark_mode'; const String kSharedPrefEnableDarkMode = 'enable_dark_mode';
const String kSharedPrefEmailPayment = 'email_payment'; const String kSharedPrefEmailPayment = 'email_payment';
const String kSharedPrefManualTimer = 'manual_timer';
const String kSharedPrefAppVersion = 'app_version'; const String kSharedPrefAppVersion = 'app_version';
const String kSharedPrefRequireAuthentication = 'require_authentication'; const String kSharedPrefRequireAuthentication = 'require_authentication';

View File

@ -69,7 +69,7 @@ class TaskTime {
abstract class TaskEntity extends Object abstract class TaskEntity extends Object
with BaseEntity, SelectableEntity with BaseEntity, SelectableEntity
implements Built<TaskEntity, TaskEntityBuilder> { implements Built<TaskEntity, TaskEntityBuilder> {
factory TaskEntity() { factory TaskEntity({bool isRunning = false}) {
return _$TaskEntity._( return _$TaskEntity._(
id: --TaskEntity.counter, id: --TaskEntity.counter,
description: '', description: '',
@ -77,7 +77,9 @@ abstract class TaskEntity extends Object
invoiceId: null, invoiceId: null,
clientId: null, clientId: null,
projectId: null, projectId: null,
timeLog: '[[${(DateTime.now().millisecondsSinceEpoch / 1000).floor()},0]]', timeLog: isRunning
? '[[${(DateTime.now().millisecondsSinceEpoch / 1000).floor()},0]]'
: '',
isRunning: false, isRunning: false,
customValue1: '', customValue1: '',
customValue2: '', customValue2: '',

View File

@ -27,11 +27,15 @@ class LoadStaticSuccess {
class UserSettingsChanged implements PersistUI { class UserSettingsChanged implements PersistUI {
UserSettingsChanged( UserSettingsChanged(
{this.enableDarkMode, this.emailPayment, this.requireAuthentication}); {this.enableDarkMode,
this.emailPayment,
this.requireAuthentication,
this.manualTimer});
final bool enableDarkMode; final bool enableDarkMode;
final bool emailPayment; final bool emailPayment;
final bool requireAuthentication; final bool requireAuthentication;
final bool manualTimer;
} }
class LoadDataSuccess { class LoadDataSuccess {

View File

@ -47,13 +47,15 @@ void _loadAuthLocal(Store<AppState> store, dynamic action) async {
final bool enableDarkMode = prefs.getBool(kSharedPrefEnableDarkMode) ?? false; final bool enableDarkMode = prefs.getBool(kSharedPrefEnableDarkMode) ?? false;
final bool emailPayment = prefs.getBool(kSharedPrefEmailPayment) ?? false; final bool emailPayment = prefs.getBool(kSharedPrefEmailPayment) ?? false;
final bool manualTimer = prefs.getBool(kSharedPrefManualTimer) ?? false;
final bool requireAuthentication = final bool requireAuthentication =
prefs.getBool(kSharedPrefRequireAuthentication) ?? false; prefs.getBool(kSharedPrefRequireAuthentication) ?? false;
store.dispatch(UserSettingsChanged( store.dispatch(UserSettingsChanged(
enableDarkMode: enableDarkMode, enableDarkMode: enableDarkMode,
emailPayment: emailPayment, emailPayment: emailPayment,
requireAuthentication: requireAuthentication)); requireAuthentication: requireAuthentication,
manualTimer: manualTimer));
} }
Middleware<AppState> _createLoginInit() { Middleware<AppState> _createLoginInit() {

View File

@ -27,15 +27,14 @@ abstract class UIState implements Built<UIState, UIStateBuilder> {
enableDarkMode: enableDarkMode ?? false, enableDarkMode: enableDarkMode ?? false,
requireAuthentication: requireAuthentication ?? false, requireAuthentication: requireAuthentication ?? false,
emailPayment: false, emailPayment: false,
manualTimer: false,
dashboardUIState: DashboardUIState(), dashboardUIState: DashboardUIState(),
productUIState: ProductUIState(), productUIState: ProductUIState(),
clientUIState: ClientUIState(), clientUIState: ClientUIState(),
invoiceUIState: InvoiceUIState(), invoiceUIState: InvoiceUIState(),
// STARTER: constructor - do not remove comment // STARTER: constructor - do not remove comment
taskUIState: TaskUIState(), taskUIState: TaskUIState(),
projectUIState: ProjectUIState(),
projectUIState: ProjectUIState(),
paymentUIState: PaymentUIState(company), paymentUIState: PaymentUIState(company),
quoteUIState: QuoteUIState(), quoteUIState: QuoteUIState(),
); );
@ -53,6 +52,8 @@ projectUIState: ProjectUIState(),
bool get emailPayment; bool get emailPayment;
bool get manualTimer;
DashboardUIState get dashboardUIState; DashboardUIState get dashboardUIState;
ProductUIState get productUIState; ProductUIState get productUIState;
@ -65,9 +66,9 @@ projectUIState: ProjectUIState(),
String get filter; String get filter;
// STARTER: properties - do not remove comment // STARTER: properties - do not remove comment
TaskUIState get taskUIState; TaskUIState get taskUIState;
ProjectUIState get projectUIState; ProjectUIState get projectUIState;
PaymentUIState get paymentUIState; PaymentUIState get paymentUIState;

View File

@ -46,6 +46,9 @@ class _$UIStateSerializer implements StructuredSerializer<UIState> {
'emailPayment', 'emailPayment',
serializers.serialize(object.emailPayment, serializers.serialize(object.emailPayment,
specifiedType: const FullType(bool)), specifiedType: const FullType(bool)),
'manualTimer',
serializers.serialize(object.manualTimer,
specifiedType: const FullType(bool)),
'dashboardUIState', 'dashboardUIState',
serializers.serialize(object.dashboardUIState, serializers.serialize(object.dashboardUIState,
specifiedType: const FullType(DashboardUIState)), specifiedType: const FullType(DashboardUIState)),
@ -112,6 +115,10 @@ class _$UIStateSerializer implements StructuredSerializer<UIState> {
result.emailPayment = serializers.deserialize(value, result.emailPayment = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool; specifiedType: const FullType(bool)) as bool;
break; break;
case 'manualTimer':
result.manualTimer = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
break;
case 'dashboardUIState': case 'dashboardUIState':
result.dashboardUIState.replace(serializers.deserialize(value, result.dashboardUIState.replace(serializers.deserialize(value,
specifiedType: const FullType(DashboardUIState)) specifiedType: const FullType(DashboardUIState))
@ -168,6 +175,8 @@ class _$UIState extends UIState {
@override @override
final bool emailPayment; final bool emailPayment;
@override @override
final bool manualTimer;
@override
final DashboardUIState dashboardUIState; final DashboardUIState dashboardUIState;
@override @override
final ProductUIState productUIState; final ProductUIState productUIState;
@ -195,6 +204,7 @@ class _$UIState extends UIState {
this.enableDarkMode, this.enableDarkMode,
this.requireAuthentication, this.requireAuthentication,
this.emailPayment, this.emailPayment,
this.manualTimer,
this.dashboardUIState, this.dashboardUIState,
this.productUIState, this.productUIState,
this.clientUIState, this.clientUIState,
@ -220,6 +230,9 @@ class _$UIState extends UIState {
if (emailPayment == null) { if (emailPayment == null) {
throw new BuiltValueNullFieldError('UIState', 'emailPayment'); throw new BuiltValueNullFieldError('UIState', 'emailPayment');
} }
if (manualTimer == null) {
throw new BuiltValueNullFieldError('UIState', 'manualTimer');
}
if (dashboardUIState == null) { if (dashboardUIState == null) {
throw new BuiltValueNullFieldError('UIState', 'dashboardUIState'); throw new BuiltValueNullFieldError('UIState', 'dashboardUIState');
} }
@ -262,6 +275,7 @@ class _$UIState extends UIState {
enableDarkMode == other.enableDarkMode && enableDarkMode == other.enableDarkMode &&
requireAuthentication == other.requireAuthentication && requireAuthentication == other.requireAuthentication &&
emailPayment == other.emailPayment && emailPayment == other.emailPayment &&
manualTimer == other.manualTimer &&
dashboardUIState == other.dashboardUIState && dashboardUIState == other.dashboardUIState &&
productUIState == other.productUIState && productUIState == other.productUIState &&
clientUIState == other.clientUIState && clientUIState == other.clientUIState &&
@ -289,13 +303,18 @@ class _$UIState extends UIState {
$jc( $jc(
$jc( $jc(
$jc( $jc(
0, $jc(
selectedCompanyIndex 0,
selectedCompanyIndex
.hashCode),
currentRoute
.hashCode), .hashCode),
currentRoute.hashCode), enableDarkMode
enableDarkMode.hashCode), .hashCode),
requireAuthentication.hashCode), requireAuthentication
emailPayment.hashCode), .hashCode),
emailPayment.hashCode),
manualTimer.hashCode),
dashboardUIState.hashCode), dashboardUIState.hashCode),
productUIState.hashCode), productUIState.hashCode),
clientUIState.hashCode), clientUIState.hashCode),
@ -315,6 +334,7 @@ class _$UIState extends UIState {
..add('enableDarkMode', enableDarkMode) ..add('enableDarkMode', enableDarkMode)
..add('requireAuthentication', requireAuthentication) ..add('requireAuthentication', requireAuthentication)
..add('emailPayment', emailPayment) ..add('emailPayment', emailPayment)
..add('manualTimer', manualTimer)
..add('dashboardUIState', dashboardUIState) ..add('dashboardUIState', dashboardUIState)
..add('productUIState', productUIState) ..add('productUIState', productUIState)
..add('clientUIState', clientUIState) ..add('clientUIState', clientUIState)
@ -354,6 +374,10 @@ class UIStateBuilder implements Builder<UIState, UIStateBuilder> {
bool get emailPayment => _$this._emailPayment; bool get emailPayment => _$this._emailPayment;
set emailPayment(bool emailPayment) => _$this._emailPayment = emailPayment; set emailPayment(bool emailPayment) => _$this._emailPayment = emailPayment;
bool _manualTimer;
bool get manualTimer => _$this._manualTimer;
set manualTimer(bool manualTimer) => _$this._manualTimer = manualTimer;
DashboardUIStateBuilder _dashboardUIState; DashboardUIStateBuilder _dashboardUIState;
DashboardUIStateBuilder get dashboardUIState => DashboardUIStateBuilder get dashboardUIState =>
_$this._dashboardUIState ??= new DashboardUIStateBuilder(); _$this._dashboardUIState ??= new DashboardUIStateBuilder();
@ -415,6 +439,7 @@ class UIStateBuilder implements Builder<UIState, UIStateBuilder> {
_enableDarkMode = _$v.enableDarkMode; _enableDarkMode = _$v.enableDarkMode;
_requireAuthentication = _$v.requireAuthentication; _requireAuthentication = _$v.requireAuthentication;
_emailPayment = _$v.emailPayment; _emailPayment = _$v.emailPayment;
_manualTimer = _$v.manualTimer;
_dashboardUIState = _$v.dashboardUIState?.toBuilder(); _dashboardUIState = _$v.dashboardUIState?.toBuilder();
_productUIState = _$v.productUIState?.toBuilder(); _productUIState = _$v.productUIState?.toBuilder();
_clientUIState = _$v.clientUIState?.toBuilder(); _clientUIState = _$v.clientUIState?.toBuilder();
@ -453,6 +478,7 @@ class UIStateBuilder implements Builder<UIState, UIStateBuilder> {
enableDarkMode: enableDarkMode, enableDarkMode: enableDarkMode,
requireAuthentication: requireAuthentication, requireAuthentication: requireAuthentication,
emailPayment: emailPayment, emailPayment: emailPayment,
manualTimer: manualTimer,
dashboardUIState: dashboardUIState.build(), dashboardUIState: dashboardUIState.build(),
productUIState: productUIState.build(), productUIState: productUIState.build(),
clientUIState: clientUIState.build(), clientUIState: clientUIState.build(),

View File

@ -235,7 +235,9 @@ class AppDrawer extends StatelessWidget {
onTap: () => store.dispatch(ViewTaskList(context)), onTap: () => store.dispatch(ViewTaskList(context)),
onCreateTap: () { onCreateTap: () {
navigator.pop(); navigator.pop();
store.dispatch(EditTask(task: TaskEntity(), context: context)); store.dispatch(EditTask(
task: TaskEntity(isRunning: !state.uiState.manualTimer),
context: context));
}, },
), ),
ListTile( ListTile(

View File

@ -141,7 +141,9 @@ class _ClientViewState extends State<ClientView>
onTap: () { onTap: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
store.dispatch(EditTask( store.dispatch(EditTask(
task: TaskEntity() task: TaskEntity(
isRunning:
!store.state.uiState.manualTimer)
.rebuild((b) => b.clientId = client.id), .rebuild((b) => b.clientId = client.id),
context: context)); context: context));
}, },

View File

@ -83,9 +83,10 @@ class ProjectViewVM {
}, },
onAddTaskPressed: (context) => store.dispatch(EditTask( onAddTaskPressed: (context) => store.dispatch(EditTask(
context: context, context: context,
task: TaskEntity().rebuild((b) => b task: TaskEntity(isRunning: !state.uiState.manualTimer)
..projectId = project.id .rebuild((b) => b
..clientId = project.clientId))), ..projectId = project.id
..clientId = project.clientId))),
onBackPressed: () { onBackPressed: () {
if (state.uiState.currentRoute.contains(ProjectScreen.route)) { if (state.uiState.currentRoute.contains(ProjectScreen.route)) {
store.dispatch(UpdateCurrentRoute(ProjectScreen.route)); store.dispatch(UpdateCurrentRoute(ProjectScreen.route));

View File

@ -71,8 +71,10 @@ class TaskScreen extends StatelessWidget {
//key: Key(TaskKeys.taskScreenFABKeyString), //key: Key(TaskKeys.taskScreenFABKeyString),
backgroundColor: Theme.of(context).primaryColorDark, backgroundColor: Theme.of(context).primaryColorDark,
onPressed: () { onPressed: () {
store.dispatch( store.dispatch(EditTask(
EditTask(task: TaskEntity(), context: context)); task: TaskEntity(
isRunning: !store.state.uiState.manualTimer),
context: context));
}, },
child: Icon( child: Icon(
Icons.add, Icons.add,