Add more prompts for review

This commit is contained in:
Hillel Coren 2023-03-01 23:31:05 +02:00
parent 0731b07847
commit 0ba5b435f9
8 changed files with 108 additions and 5 deletions

View File

@ -233,7 +233,7 @@ Future<AppState> _initialState(bool isTesting) async {
prefState = serializers.deserializeWith(
PrefState.serializer, json.decode(prefString));
} catch (e) {
print('Failed to load prefs: $e');
print('## Error: Failed to load prefs: $e');
}
}

View File

@ -105,6 +105,10 @@ class DismissGatewayWarningPermanently implements PersistUI, PersistPrefs {}
class DismissReviewAppPermanently implements PersistUI, PersistPrefs {}
class DismissOneYearReviewAppPermanently implements PersistUI, PersistPrefs {}
class DismissTwoYearReviewAppPermanently implements PersistUI, PersistPrefs {}
class ViewMainScreen {
ViewMainScreen({this.addDelay = false});

View File

@ -192,6 +192,14 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
return color.isNotEmpty;
}
bool get showReviewApp => !prefState.hideReviewApp && company.daysActive > 60;
bool get showOneYearReviewApp =>
!prefState.hideOneYearReviewApp && company.daysActive > 365;
bool get showTwoYearReviewApp =>
!prefState.hideTwoYearReviewApp && company.daysActive > 730;
Color get linkColor => prefState.enableDarkMode
? convertHexStringToColor('#FFFFFF')
: accentColor;

View File

@ -67,6 +67,10 @@ PrefState prefReducer(
..hideGatewayWarning =
hideGatewayWarningReducer(state.hideGatewayWarning, action)
..hideReviewApp = hideReviewAppReducer(state.hideReviewApp, action)
..hideOneYearReviewApp =
hideOneYearReviewAppReducer(state.hideOneYearReviewApp, action)
..hideTwoYearReviewApp =
hideTwoYearReviewAppReducer(state.hideTwoYearReviewApp, action)
..textScaleFactor = textScaleFactorReducer(state.textScaleFactor, action)
..isMenuVisible = menuVisibleReducer(state.isMenuVisible, action)
..isHistoryVisible = historyVisibleReducer(state.isHistoryVisible, action)
@ -253,6 +257,27 @@ Reducer<bool> hideReviewAppReducer = combineReducers([
TypedReducer<bool, DismissReviewAppPermanently>((filter, action) {
return true;
}),
TypedReducer<bool, DismissOneYearReviewAppPermanently>((filter, action) {
return true;
}),
TypedReducer<bool, DismissTwoYearReviewAppPermanently>((filter, action) {
return true;
}),
]);
Reducer<bool> hideOneYearReviewAppReducer = combineReducers([
TypedReducer<bool, DismissOneYearReviewAppPermanently>((filter, action) {
return true;
}),
TypedReducer<bool, DismissTwoYearReviewAppPermanently>((filter, action) {
return true;
}),
]);
Reducer<bool> hideTwoYearReviewAppReducer = combineReducers([
TypedReducer<bool, DismissTwoYearReviewAppPermanently>((filter, action) {
return true;
}),
]);
Reducer<int> filterClearedAtReducer = combineReducers([

View File

@ -40,6 +40,8 @@ abstract class PrefState implements Built<PrefState, PrefStateBuilder> {
hideDesktopWarning: false,
hideGatewayWarning: false,
hideReviewApp: false,
hideOneYearReviewApp: false,
hideTwoYearReviewApp: false,
showKanban: false,
showPdfPreview: true,
showPdfPreviewSideBySide: false,
@ -151,6 +153,10 @@ abstract class PrefState implements Built<PrefState, PrefStateBuilder> {
bool get hideReviewApp;
bool get hideOneYearReviewApp;
bool get hideTwoYearReviewApp;
bool get editAfterSaving;
double get textScaleFactor;
@ -233,6 +239,8 @@ abstract class PrefState implements Built<PrefState, PrefStateBuilder> {
..hideDesktopWarning = false
..hideGatewayWarning = false
..hideReviewApp = false
..hideOneYearReviewApp = false
..hideTwoYearReviewApp = false
..tapSelectedToEdit = false
..persistData = false
..persistUI = true

View File

@ -200,6 +200,12 @@ class _$PrefStateSerializer implements StructuredSerializer<PrefState> {
'hideReviewApp',
serializers.serialize(object.hideReviewApp,
specifiedType: const FullType(bool)),
'hideOneYearReviewApp',
serializers.serialize(object.hideOneYearReviewApp,
specifiedType: const FullType(bool)),
'hideTwoYearReviewApp',
serializers.serialize(object.hideTwoYearReviewApp,
specifiedType: const FullType(bool)),
'editAfterSaving',
serializers.serialize(object.editAfterSaving,
specifiedType: const FullType(bool)),
@ -349,6 +355,14 @@ class _$PrefStateSerializer implements StructuredSerializer<PrefState> {
result.hideReviewApp = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
break;
case 'hideOneYearReviewApp':
result.hideOneYearReviewApp = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
break;
case 'hideTwoYearReviewApp':
result.hideTwoYearReviewApp = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
break;
case 'editAfterSaving':
result.editAfterSaving = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
@ -658,6 +672,10 @@ class _$PrefState extends PrefState {
@override
final bool hideReviewApp;
@override
final bool hideOneYearReviewApp;
@override
final bool hideTwoYearReviewApp;
@override
final bool editAfterSaving;
@override
final double textScaleFactor;
@ -698,6 +716,8 @@ class _$PrefState extends PrefState {
this.hideDesktopWarning,
this.hideGatewayWarning,
this.hideReviewApp,
this.hideOneYearReviewApp,
this.hideTwoYearReviewApp,
this.editAfterSaving,
this.textScaleFactor,
this.sortFields,
@ -757,6 +777,10 @@ class _$PrefState extends PrefState {
hideGatewayWarning, r'PrefState', 'hideGatewayWarning');
BuiltValueNullFieldError.checkNotNull(
hideReviewApp, r'PrefState', 'hideReviewApp');
BuiltValueNullFieldError.checkNotNull(
hideOneYearReviewApp, r'PrefState', 'hideOneYearReviewApp');
BuiltValueNullFieldError.checkNotNull(
hideTwoYearReviewApp, r'PrefState', 'hideTwoYearReviewApp');
BuiltValueNullFieldError.checkNotNull(
editAfterSaving, r'PrefState', 'editAfterSaving');
BuiltValueNullFieldError.checkNotNull(
@ -806,6 +830,8 @@ class _$PrefState extends PrefState {
hideDesktopWarning == other.hideDesktopWarning &&
hideGatewayWarning == other.hideGatewayWarning &&
hideReviewApp == other.hideReviewApp &&
hideOneYearReviewApp == other.hideOneYearReviewApp &&
hideTwoYearReviewApp == other.hideTwoYearReviewApp &&
editAfterSaving == other.editAfterSaving &&
textScaleFactor == other.textScaleFactor &&
sortFields == other.sortFields &&
@ -845,6 +871,8 @@ class _$PrefState extends PrefState {
_$hash = $jc(_$hash, hideDesktopWarning.hashCode);
_$hash = $jc(_$hash, hideGatewayWarning.hashCode);
_$hash = $jc(_$hash, hideReviewApp.hashCode);
_$hash = $jc(_$hash, hideOneYearReviewApp.hashCode);
_$hash = $jc(_$hash, hideTwoYearReviewApp.hashCode);
_$hash = $jc(_$hash, editAfterSaving.hashCode);
_$hash = $jc(_$hash, textScaleFactor.hashCode);
_$hash = $jc(_$hash, sortFields.hashCode);
@ -884,6 +912,8 @@ class _$PrefState extends PrefState {
..add('hideDesktopWarning', hideDesktopWarning)
..add('hideGatewayWarning', hideGatewayWarning)
..add('hideReviewApp', hideReviewApp)
..add('hideOneYearReviewApp', hideOneYearReviewApp)
..add('hideTwoYearReviewApp', hideTwoYearReviewApp)
..add('editAfterSaving', editAfterSaving)
..add('textScaleFactor', textScaleFactor)
..add('sortFields', sortFields)
@ -1032,6 +1062,16 @@ class PrefStateBuilder implements Builder<PrefState, PrefStateBuilder> {
set hideReviewApp(bool hideReviewApp) =>
_$this._hideReviewApp = hideReviewApp;
bool _hideOneYearReviewApp;
bool get hideOneYearReviewApp => _$this._hideOneYearReviewApp;
set hideOneYearReviewApp(bool hideOneYearReviewApp) =>
_$this._hideOneYearReviewApp = hideOneYearReviewApp;
bool _hideTwoYearReviewApp;
bool get hideTwoYearReviewApp => _$this._hideTwoYearReviewApp;
set hideTwoYearReviewApp(bool hideTwoYearReviewApp) =>
_$this._hideTwoYearReviewApp = hideTwoYearReviewApp;
bool _editAfterSaving;
bool get editAfterSaving => _$this._editAfterSaving;
set editAfterSaving(bool editAfterSaving) =>
@ -1089,6 +1129,8 @@ class PrefStateBuilder implements Builder<PrefState, PrefStateBuilder> {
_hideDesktopWarning = $v.hideDesktopWarning;
_hideGatewayWarning = $v.hideGatewayWarning;
_hideReviewApp = $v.hideReviewApp;
_hideOneYearReviewApp = $v.hideOneYearReviewApp;
_hideTwoYearReviewApp = $v.hideTwoYearReviewApp;
_editAfterSaving = $v.editAfterSaving;
_textScaleFactor = $v.textScaleFactor;
_sortFields = $v.sortFields.toBuilder();
@ -1153,6 +1195,8 @@ class PrefStateBuilder implements Builder<PrefState, PrefStateBuilder> {
hideDesktopWarning: BuiltValueNullFieldError.checkNotNull(hideDesktopWarning, r'PrefState', 'hideDesktopWarning'),
hideGatewayWarning: BuiltValueNullFieldError.checkNotNull(hideGatewayWarning, r'PrefState', 'hideGatewayWarning'),
hideReviewApp: BuiltValueNullFieldError.checkNotNull(hideReviewApp, r'PrefState', 'hideReviewApp'),
hideOneYearReviewApp: BuiltValueNullFieldError.checkNotNull(hideOneYearReviewApp, r'PrefState', 'hideOneYearReviewApp'),
hideTwoYearReviewApp: BuiltValueNullFieldError.checkNotNull(hideTwoYearReviewApp, r'PrefState', 'hideTwoYearReviewApp'),
editAfterSaving: BuiltValueNullFieldError.checkNotNull(editAfterSaving, r'PrefState', 'editAfterSaving'),
textScaleFactor: BuiltValueNullFieldError.checkNotNull(textScaleFactor, r'PrefState', 'textScaleFactor'),
sortFields: sortFields.build(),

View File

@ -21,6 +21,7 @@ class _ReviewAppState extends State<ReviewApp> {
Widget build(BuildContext context) {
final localization = AppLocalization.of(context);
final store = StoreProvider.of<AppState>(context);
final state = store.state;
if (kIsWeb || isLinux()) {
return SizedBox();
@ -53,7 +54,13 @@ class _ReviewAppState extends State<ReviewApp> {
AppReview.openStoreListing();
}
store.dispatch(DismissReviewAppPermanently());
if (state.showTwoYearReviewApp) {
store.dispatch(DismissTwoYearReviewAppPermanently());
} else if (state.showOneYearReviewApp) {
store.dispatch(DismissOneYearReviewAppPermanently());
} else if (state.showReviewApp) {
store.dispatch(DismissReviewAppPermanently());
}
},
child: ConstrainedBox(
constraints: const BoxConstraints(minWidth: 100),
@ -68,7 +75,13 @@ class _ReviewAppState extends State<ReviewApp> {
),
TextButton(
onPressed: () async {
store.dispatch(DismissReviewAppPermanently());
if (state.showTwoYearReviewApp) {
store.dispatch(DismissTwoYearReviewAppPermanently());
} else if (state.showOneYearReviewApp) {
store.dispatch(DismissOneYearReviewAppPermanently());
} else if (state.showReviewApp) {
store.dispatch(DismissReviewAppPermanently());
}
},
child: ConstrainedBox(
constraints: const BoxConstraints(minWidth: 100),

View File

@ -459,8 +459,9 @@ class DashboardPanels extends StatelessWidget {
case DashboardSections.messages:
return Column(
children: [
if (!state.prefState.hideReviewApp &&
state.company.daysActive > (isMobileOS() ? 60 : 120))
if (state.showReviewApp ||
state.showOneYearReviewApp ||
state.showTwoYearReviewApp)
ReviewApp(),
if (state.userCompany.isAdmin &&
state.company.daysActive < 30 &&