Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Add notification bar state for recommend premium plan" #511

Merged
merged 1 commit into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import 'package:pilll/domain/premium_trial/premium_trial_modal.dart';
import 'package:pilll/domain/record/components/notification_bar/components/announce_supported_multiple_pill_sheet.dart';
import 'package:pilll/domain/record/components/notification_bar/components/discount_price_deadline.dart';
import 'package:pilll/domain/record/components/notification_bar/components/ended_pill_sheet.dart';
import 'package:pilll/domain/record/components/notification_bar/components/recommend_premium_plan_in_trial.dart';
import 'package:pilll/domain/record/components/notification_bar/notification_bar_store.dart';
import 'package:pilll/domain/record/components/notification_bar/components/premium_trial_guide.dart';
import 'package:pilll/domain/record/components/notification_bar/components/premium_trial_limit.dart';
Expand All @@ -20,7 +19,6 @@ import 'package:pilll/domain/record/components/notification_bar/components/rest_
import 'package:pilll/domain/record/record_page_state.dart';
import 'package:pilll/signin/signin_sheet.dart';
import 'package:pilll/signin/signin_sheet_state.dart';
import 'package:pilll/util/datetime/day.dart';
import 'package:pilll/util/shared_preference/keys.dart';
import 'package:shared_preferences/shared_preferences.dart';

Expand All @@ -46,27 +44,6 @@ class NotificationBar extends HookConsumerWidget {
final state = ref.watch(notificationBarStateProvider(parameter));
final store = ref.watch(notificationBarStoreProvider(parameter).notifier);
if (!state.isPremium) {
if (!state.recommendPremiumPlainInTrialIsAlreadyClose) {
if (state.isTrial) {
final beginTrialDate = state.beginTrialDate;
if (beginTrialDate != null) {
final difference = now().difference(beginTrialDate).inSeconds;
final days14 = Duration(days: 14).inSeconds;
final days14Plus2 = Duration(days: 14 + 2).inSeconds;
if (difference > days14 && difference < days14Plus2) {
return RecommendPremiumPlainInTrialNotificationBar(
onTap: () {
showPremiumIntroductionSheet(context);
},
onClose: () {
store.closeRecommendedPremiumPlainInTrial();
},
);
}
}
}
}

final premiumTrialLimit = state.premiumTrialLimit;
if (premiumTrialLimit != null) {
return PremiumTrialLimitNotificationBar(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ class NotificationBarState with _$NotificationBarState {
required bool isTrial,
required bool isAlreadyShowAnnouncementSupportedMultilplePillSheet,
required bool hasDiscountEntitlement,
required DateTime? beginTrialDate,
required DateTime? trialDeadlineDate,
required DateTime? discountEntitlementDeadlineDate,
required bool recommendPremiumPlainInTrialIsAlreadyClose,
required bool recommendedSignupNotificationIsAlreadyShow,
required bool premiumTrialGuideNotificationIsClosed,
required bool isLinkedLoginProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ class _$NotificationBarStateTearOff {
required bool isTrial,
required bool isAlreadyShowAnnouncementSupportedMultilplePillSheet,
required bool hasDiscountEntitlement,
required DateTime? beginTrialDate,
required DateTime? trialDeadlineDate,
required DateTime? discountEntitlementDeadlineDate,
required bool recommendPremiumPlainInTrialIsAlreadyClose,
required bool recommendedSignupNotificationIsAlreadyShow,
required bool premiumTrialGuideNotificationIsClosed,
required bool isLinkedLoginProvider}) {
Expand All @@ -40,11 +38,8 @@ class _$NotificationBarStateTearOff {
isAlreadyShowAnnouncementSupportedMultilplePillSheet:
isAlreadyShowAnnouncementSupportedMultilplePillSheet,
hasDiscountEntitlement: hasDiscountEntitlement,
beginTrialDate: beginTrialDate,
trialDeadlineDate: trialDeadlineDate,
discountEntitlementDeadlineDate: discountEntitlementDeadlineDate,
recommendPremiumPlainInTrialIsAlreadyClose:
recommendPremiumPlainInTrialIsAlreadyClose,
recommendedSignupNotificationIsAlreadyShow:
recommendedSignupNotificationIsAlreadyShow,
premiumTrialGuideNotificationIsClosed:
Expand All @@ -67,12 +62,9 @@ mixin _$NotificationBarState {
bool get isAlreadyShowAnnouncementSupportedMultilplePillSheet =>
throw _privateConstructorUsedError;
bool get hasDiscountEntitlement => throw _privateConstructorUsedError;
DateTime? get beginTrialDate => throw _privateConstructorUsedError;
DateTime? get trialDeadlineDate => throw _privateConstructorUsedError;
DateTime? get discountEntitlementDeadlineDate =>
throw _privateConstructorUsedError;
bool get recommendPremiumPlainInTrialIsAlreadyClose =>
throw _privateConstructorUsedError;
bool get recommendedSignupNotificationIsAlreadyShow =>
throw _privateConstructorUsedError;
bool get premiumTrialGuideNotificationIsClosed =>
Expand All @@ -96,10 +88,8 @@ abstract class $NotificationBarStateCopyWith<$Res> {
bool isTrial,
bool isAlreadyShowAnnouncementSupportedMultilplePillSheet,
bool hasDiscountEntitlement,
DateTime? beginTrialDate,
DateTime? trialDeadlineDate,
DateTime? discountEntitlementDeadlineDate,
bool recommendPremiumPlainInTrialIsAlreadyClose,
bool recommendedSignupNotificationIsAlreadyShow,
bool premiumTrialGuideNotificationIsClosed,
bool isLinkedLoginProvider});
Expand All @@ -124,10 +114,8 @@ class _$NotificationBarStateCopyWithImpl<$Res>
Object? isTrial = freezed,
Object? isAlreadyShowAnnouncementSupportedMultilplePillSheet = freezed,
Object? hasDiscountEntitlement = freezed,
Object? beginTrialDate = freezed,
Object? trialDeadlineDate = freezed,
Object? discountEntitlementDeadlineDate = freezed,
Object? recommendPremiumPlainInTrialIsAlreadyClose = freezed,
Object? recommendedSignupNotificationIsAlreadyShow = freezed,
Object? premiumTrialGuideNotificationIsClosed = freezed,
Object? isLinkedLoginProvider = freezed,
Expand Down Expand Up @@ -158,10 +146,6 @@ class _$NotificationBarStateCopyWithImpl<$Res>
? _value.hasDiscountEntitlement
: hasDiscountEntitlement // ignore: cast_nullable_to_non_nullable
as bool,
beginTrialDate: beginTrialDate == freezed
? _value.beginTrialDate
: beginTrialDate // ignore: cast_nullable_to_non_nullable
as DateTime?,
trialDeadlineDate: trialDeadlineDate == freezed
? _value.trialDeadlineDate
: trialDeadlineDate // ignore: cast_nullable_to_non_nullable
Expand All @@ -171,11 +155,6 @@ class _$NotificationBarStateCopyWithImpl<$Res>
? _value.discountEntitlementDeadlineDate
: discountEntitlementDeadlineDate // ignore: cast_nullable_to_non_nullable
as DateTime?,
recommendPremiumPlainInTrialIsAlreadyClose:
recommendPremiumPlainInTrialIsAlreadyClose == freezed
? _value.recommendPremiumPlainInTrialIsAlreadyClose
: recommendPremiumPlainInTrialIsAlreadyClose // ignore: cast_nullable_to_non_nullable
as bool,
recommendedSignupNotificationIsAlreadyShow:
recommendedSignupNotificationIsAlreadyShow == freezed
? _value.recommendedSignupNotificationIsAlreadyShow
Expand Down Expand Up @@ -219,10 +198,8 @@ abstract class _$NotificationBarStateCopyWith<$Res>
bool isTrial,
bool isAlreadyShowAnnouncementSupportedMultilplePillSheet,
bool hasDiscountEntitlement,
DateTime? beginTrialDate,
DateTime? trialDeadlineDate,
DateTime? discountEntitlementDeadlineDate,
bool recommendPremiumPlainInTrialIsAlreadyClose,
bool recommendedSignupNotificationIsAlreadyShow,
bool premiumTrialGuideNotificationIsClosed,
bool isLinkedLoginProvider});
Expand Down Expand Up @@ -250,10 +227,8 @@ class __$NotificationBarStateCopyWithImpl<$Res>
Object? isTrial = freezed,
Object? isAlreadyShowAnnouncementSupportedMultilplePillSheet = freezed,
Object? hasDiscountEntitlement = freezed,
Object? beginTrialDate = freezed,
Object? trialDeadlineDate = freezed,
Object? discountEntitlementDeadlineDate = freezed,
Object? recommendPremiumPlainInTrialIsAlreadyClose = freezed,
Object? recommendedSignupNotificationIsAlreadyShow = freezed,
Object? premiumTrialGuideNotificationIsClosed = freezed,
Object? isLinkedLoginProvider = freezed,
Expand Down Expand Up @@ -284,10 +259,6 @@ class __$NotificationBarStateCopyWithImpl<$Res>
? _value.hasDiscountEntitlement
: hasDiscountEntitlement // ignore: cast_nullable_to_non_nullable
as bool,
beginTrialDate: beginTrialDate == freezed
? _value.beginTrialDate
: beginTrialDate // ignore: cast_nullable_to_non_nullable
as DateTime?,
trialDeadlineDate: trialDeadlineDate == freezed
? _value.trialDeadlineDate
: trialDeadlineDate // ignore: cast_nullable_to_non_nullable
Expand All @@ -297,11 +268,6 @@ class __$NotificationBarStateCopyWithImpl<$Res>
? _value.discountEntitlementDeadlineDate
: discountEntitlementDeadlineDate // ignore: cast_nullable_to_non_nullable
as DateTime?,
recommendPremiumPlainInTrialIsAlreadyClose:
recommendPremiumPlainInTrialIsAlreadyClose == freezed
? _value.recommendPremiumPlainInTrialIsAlreadyClose
: recommendPremiumPlainInTrialIsAlreadyClose // ignore: cast_nullable_to_non_nullable
as bool,
recommendedSignupNotificationIsAlreadyShow:
recommendedSignupNotificationIsAlreadyShow == freezed
? _value.recommendedSignupNotificationIsAlreadyShow
Expand Down Expand Up @@ -330,10 +296,8 @@ class _$_NotificationBarState extends _NotificationBarState {
required this.isTrial,
required this.isAlreadyShowAnnouncementSupportedMultilplePillSheet,
required this.hasDiscountEntitlement,
required this.beginTrialDate,
required this.trialDeadlineDate,
required this.discountEntitlementDeadlineDate,
required this.recommendPremiumPlainInTrialIsAlreadyClose,
required this.recommendedSignupNotificationIsAlreadyShow,
required this.premiumTrialGuideNotificationIsClosed,
required this.isLinkedLoginProvider})
Expand All @@ -352,14 +316,10 @@ class _$_NotificationBarState extends _NotificationBarState {
@override
final bool hasDiscountEntitlement;
@override
final DateTime? beginTrialDate;
@override
final DateTime? trialDeadlineDate;
@override
final DateTime? discountEntitlementDeadlineDate;
@override
final bool recommendPremiumPlainInTrialIsAlreadyClose;
@override
final bool recommendedSignupNotificationIsAlreadyShow;
@override
final bool premiumTrialGuideNotificationIsClosed;
Expand All @@ -368,7 +328,7 @@ class _$_NotificationBarState extends _NotificationBarState {

@override
String toString() {
return 'NotificationBarState(latestPillSheetGroup: $latestPillSheetGroup, totalCountOfActionForTakenPill: $totalCountOfActionForTakenPill, isPremium: $isPremium, isTrial: $isTrial, isAlreadyShowAnnouncementSupportedMultilplePillSheet: $isAlreadyShowAnnouncementSupportedMultilplePillSheet, hasDiscountEntitlement: $hasDiscountEntitlement, beginTrialDate: $beginTrialDate, trialDeadlineDate: $trialDeadlineDate, discountEntitlementDeadlineDate: $discountEntitlementDeadlineDate, recommendPremiumPlainInTrialIsAlreadyClose: $recommendPremiumPlainInTrialIsAlreadyClose, recommendedSignupNotificationIsAlreadyShow: $recommendedSignupNotificationIsAlreadyShow, premiumTrialGuideNotificationIsClosed: $premiumTrialGuideNotificationIsClosed, isLinkedLoginProvider: $isLinkedLoginProvider)';
return 'NotificationBarState(latestPillSheetGroup: $latestPillSheetGroup, totalCountOfActionForTakenPill: $totalCountOfActionForTakenPill, isPremium: $isPremium, isTrial: $isTrial, isAlreadyShowAnnouncementSupportedMultilplePillSheet: $isAlreadyShowAnnouncementSupportedMultilplePillSheet, hasDiscountEntitlement: $hasDiscountEntitlement, trialDeadlineDate: $trialDeadlineDate, discountEntitlementDeadlineDate: $discountEntitlementDeadlineDate, recommendedSignupNotificationIsAlreadyShow: $recommendedSignupNotificationIsAlreadyShow, premiumTrialGuideNotificationIsClosed: $premiumTrialGuideNotificationIsClosed, isLinkedLoginProvider: $isLinkedLoginProvider)';
}

@override
Expand All @@ -388,16 +348,11 @@ class _$_NotificationBarState extends _NotificationBarState {
isAlreadyShowAnnouncementSupportedMultilplePillSheet) &&
const DeepCollectionEquality()
.equals(other.hasDiscountEntitlement, hasDiscountEntitlement) &&
const DeepCollectionEquality()
.equals(other.beginTrialDate, beginTrialDate) &&
const DeepCollectionEquality()
.equals(other.trialDeadlineDate, trialDeadlineDate) &&
const DeepCollectionEquality().equals(
other.discountEntitlementDeadlineDate,
discountEntitlementDeadlineDate) &&
const DeepCollectionEquality().equals(
other.recommendPremiumPlainInTrialIsAlreadyClose,
recommendPremiumPlainInTrialIsAlreadyClose) &&
const DeepCollectionEquality().equals(
other.recommendedSignupNotificationIsAlreadyShow,
recommendedSignupNotificationIsAlreadyShow) &&
Expand All @@ -418,11 +373,8 @@ class _$_NotificationBarState extends _NotificationBarState {
const DeepCollectionEquality()
.hash(isAlreadyShowAnnouncementSupportedMultilplePillSheet),
const DeepCollectionEquality().hash(hasDiscountEntitlement),
const DeepCollectionEquality().hash(beginTrialDate),
const DeepCollectionEquality().hash(trialDeadlineDate),
const DeepCollectionEquality().hash(discountEntitlementDeadlineDate),
const DeepCollectionEquality()
.hash(recommendPremiumPlainInTrialIsAlreadyClose),
const DeepCollectionEquality()
.hash(recommendedSignupNotificationIsAlreadyShow),
const DeepCollectionEquality()
Expand All @@ -444,10 +396,8 @@ abstract class _NotificationBarState extends NotificationBarState {
required bool isTrial,
required bool isAlreadyShowAnnouncementSupportedMultilplePillSheet,
required bool hasDiscountEntitlement,
required DateTime? beginTrialDate,
required DateTime? trialDeadlineDate,
required DateTime? discountEntitlementDeadlineDate,
required bool recommendPremiumPlainInTrialIsAlreadyClose,
required bool recommendedSignupNotificationIsAlreadyShow,
required bool premiumTrialGuideNotificationIsClosed,
required bool isLinkedLoginProvider}) = _$_NotificationBarState;
Expand All @@ -466,14 +416,10 @@ abstract class _NotificationBarState extends NotificationBarState {
@override
bool get hasDiscountEntitlement;
@override
DateTime? get beginTrialDate;
@override
DateTime? get trialDeadlineDate;
@override
DateTime? get discountEntitlementDeadlineDate;
@override
bool get recommendPremiumPlainInTrialIsAlreadyClose;
@override
bool get recommendedSignupNotificationIsAlreadyShow;
@override
bool get premiumTrialGuideNotificationIsClosed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,16 @@ class NotificationBarStateStore extends StateNotifier<NotificationBarState> {
hasDiscountEntitlement: parameter.hasDiscountEntitlement,
isAlreadyShowAnnouncementSupportedMultilplePillSheet:
parameter.isAlreadyShowAnnouncementSupportedMultilplePillSheet,
beginTrialDate: parameter.beginTrialDate,
trialDeadlineDate: parameter.trialDeadlineDate,
discountEntitlementDeadlineDate:
parameter.discountEntitlementDeadlineDate,
isLinkedLoginProvider: parameter.isLinkedLoginProvider,
recommendPremiumPlainInTrialIsAlreadyClose:
parameter.recommendPremiumPlainInTrialIsAlreadyClose,
premiumTrialGuideNotificationIsClosed:
parameter.premiumTrialGuideNotificationIsClosed,
recommendedSignupNotificationIsAlreadyShow:
parameter.recommendedSignupNotificationIsAlreadyShow,
),
);
Future<void> closeRecommendedPremiumPlainInTrial() async {
final sharedPreferences = await SharedPreferences.getInstance();
sharedPreferences.setBool(
BoolKey.recommendPremiumPlainInTrialIsAlreadyClose, true);
state = state.copyWith(recommendPremiumPlainInTrialIsAlreadyClose: true);
}

Future<void> closeRecommendedSignupNotification() async {
final sharedPreferences = await SharedPreferences.getInstance();
sharedPreferences.setBool(
Expand Down
1 change: 0 additions & 1 deletion lib/domain/record/record_page_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class RecordPageState with _$RecordPageState {
DateTime? beginTrialDate,
DateTime? trialDeadlineDate,
DateTime? discountEntitlementDeadlineDate,
@Default(false) bool recommendPremiumPlainInTrialIsAlreadyClose,
@Default(true) bool recommendedSignupNotificationIsAlreadyShow,
@Default(true) bool premiumTrialGuideNotificationIsClosed,
Object? exception,
Expand Down
Loading