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

add condition of if is not JP store #670

Merged
merged 3 commits into from
Aug 27, 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
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:pilll/analytics.dart';
Expand All @@ -14,6 +16,7 @@ import 'package:pilll/domain/record/components/notification_bar/components/recom
import 'package:pilll/domain/record/components/notification_bar/components/rest_duration.dart';
import 'package:pilll/domain/sign_in/sign_in_sheet.dart';
import 'package:pilll/domain/sign_in/sign_in_sheet_state.codegen.dart';
import 'package:pilll/provider/locale.dart';
import 'package:pilll/util/datetime/day.dart';

class NotificationBar extends HookConsumerWidget {
Expand All @@ -34,7 +37,11 @@ class NotificationBar extends HookConsumerWidget {
final store = ref.watch(notificationBarStoreProvider.notifier);
final discountEntitlementDeadlineDate = state.premiumAndTrial.discountEntitlementDeadlineDate;
final isOverDiscountDeadline = ref.watch(isOverDiscountDeadlineProvider(discountEntitlementDeadlineDate));
final isJaLocale = ref.watch(isJaLocaleProvider);
final isAdsDisabled = () {
if (!isJaLocale) {
return true;
}
final begin = DateTime(2022, 8, 10, 0, 0, 0);
final end = DateTime(2022, 8, 23, 23, 59, 59);
return now().isBefore(begin) || now().isAfter(end);
Expand Down
6 changes: 6 additions & 0 deletions lib/provider/locale.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import 'dart:io';

import 'package:riverpod/riverpod.dart';

final localeNameProvider = Provider.autoDispose((_) => Platform.localeName);
final isJaLocaleProvider = Provider.autoDispose((ref) => Platform.localeName.contains("_JP"));
21 changes: 21 additions & 0 deletions test/domain/record/notification_bar/notification_bar_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:pilll/domain/record/components/notification_bar/components/rest_
import 'package:pilll/entity/pill_sheet.codegen.dart';
import 'package:pilll/entity/pill_sheet_group.codegen.dart';
import 'package:pilll/entity/pill_sheet_type.dart';
import 'package:pilll/provider/locale.dart';
import 'package:pilll/provider/premium_and_trial.codegen.dart';
import 'package:pilll/service/day.dart';
import 'package:pilll/util/datetime/day.dart';
Expand Down Expand Up @@ -78,6 +79,7 @@ void main() {
await tester.pumpWidget(
ProviderScope(
overrides: [
isJaLocaleProvider.overrideWithValue(true),
notificationBarStoreProvider.overrideWithProvider(StateNotifierProvider.autoDispose((_) => NotificationBarStateStore(state))),
notificationBarStateProvider.overrideWithProvider(Provider.autoDispose((_) => state)),
isOverDiscountDeadlineProvider.overrideWithProvider((param) => Provider.autoDispose((_) => false)),
Expand Down Expand Up @@ -132,6 +134,7 @@ void main() {
await tester.pumpWidget(
ProviderScope(
overrides: [
isJaLocaleProvider.overrideWithValue(true),
notificationBarStoreProvider.overrideWithProvider(StateNotifierProvider.autoDispose((_) => NotificationBarStateStore(state))),
notificationBarStateProvider.overrideWithProvider(Provider.autoDispose((_) => state)),
isOverDiscountDeadlineProvider.overrideWithProvider((param) => Provider.autoDispose((_) => false)),
Expand Down Expand Up @@ -186,6 +189,7 @@ void main() {
await tester.pumpWidget(
ProviderScope(
overrides: [
isJaLocaleProvider.overrideWithValue(true),
notificationBarStoreProvider.overrideWithProvider(StateNotifierProvider.autoDispose((_) => NotificationBarStateStore(state))),
notificationBarStateProvider.overrideWithProvider(Provider.autoDispose((_) => state)),
],
Expand Down Expand Up @@ -239,6 +243,7 @@ void main() {
await tester.pumpWidget(
ProviderScope(
overrides: [
isJaLocaleProvider.overrideWithValue(true),
notificationBarStoreProvider.overrideWithProvider(StateNotifierProvider.autoDispose((_) => NotificationBarStateStore(state))),
notificationBarStateProvider.overrideWithProvider(Provider.autoDispose((_) => state)),
],
Expand Down Expand Up @@ -292,6 +297,7 @@ void main() {
await tester.pumpWidget(
ProviderScope(
overrides: [
isJaLocaleProvider.overrideWithValue(true),
notificationBarStoreProvider.overrideWithProvider(StateNotifierProvider.autoDispose((_) => NotificationBarStateStore(state))),
notificationBarStateProvider.overrideWithProvider(Provider.autoDispose((_) => state)),
],
Expand Down Expand Up @@ -345,6 +351,7 @@ void main() {
await tester.pumpWidget(
ProviderScope(
overrides: [
isJaLocaleProvider.overrideWithValue(true),
notificationBarStoreProvider.overrideWithProvider(StateNotifierProvider.autoDispose((_) => NotificationBarStateStore(state))),
notificationBarStateProvider.overrideWithProvider(Provider.autoDispose((_) => state)),
],
Expand Down Expand Up @@ -397,6 +404,7 @@ void main() {
await tester.pumpWidget(
ProviderScope(
overrides: [
isJaLocaleProvider.overrideWithValue(true),
notificationBarStoreProvider.overrideWithProvider(StateNotifierProvider.autoDispose((_) => NotificationBarStateStore(state))),
notificationBarStateProvider.overrideWithProvider(Provider.autoDispose((_) => state)),
],
Expand Down Expand Up @@ -447,6 +455,7 @@ void main() {
await tester.pumpWidget(
ProviderScope(
overrides: [
isJaLocaleProvider.overrideWithValue(true),
notificationBarStoreProvider.overrideWithProvider(StateNotifierProvider.autoDispose((_) => NotificationBarStateStore(state))),
notificationBarStateProvider.overrideWithProvider(Provider.autoDispose((_) => state)),
],
Expand Down Expand Up @@ -497,6 +506,7 @@ void main() {
await tester.pumpWidget(
ProviderScope(
overrides: [
isJaLocaleProvider.overrideWithValue(true),
notificationBarStoreProvider.overrideWithProvider(StateNotifierProvider.autoDispose((_) => NotificationBarStateStore(state))),
notificationBarStateProvider.overrideWithProvider(Provider.autoDispose((_) => state)),
],
Expand Down Expand Up @@ -547,6 +557,7 @@ void main() {
await tester.pumpWidget(
ProviderScope(
overrides: [
isJaLocaleProvider.overrideWithValue(true),
notificationBarStoreProvider.overrideWithProvider(StateNotifierProvider.autoDispose((_) => NotificationBarStateStore(state))),
notificationBarStateProvider.overrideWithProvider(Provider.autoDispose((_) => state)),
],
Expand Down Expand Up @@ -597,6 +608,7 @@ void main() {
await tester.pumpWidget(
ProviderScope(
overrides: [
isJaLocaleProvider.overrideWithValue(true),
notificationBarStoreProvider.overrideWithProvider(StateNotifierProvider.autoDispose((_) => NotificationBarStateStore(state))),
notificationBarStateProvider.overrideWithProvider(Provider.autoDispose((_) => state)),
],
Expand Down Expand Up @@ -654,6 +666,7 @@ void main() {
await tester.pumpWidget(
ProviderScope(
overrides: [
isJaLocaleProvider.overrideWithValue(true),
notificationBarStoreProvider.overrideWithProvider(StateNotifierProvider.autoDispose((_) => NotificationBarStateStore(state))),
notificationBarStateProvider.overrideWithProvider(Provider.autoDispose((_) => state)),
],
Expand Down Expand Up @@ -706,6 +719,7 @@ void main() {
await tester.pumpWidget(
ProviderScope(
overrides: [
isJaLocaleProvider.overrideWithValue(true),
notificationBarStoreProvider.overrideWithProvider(StateNotifierProvider.autoDispose((_) => NotificationBarStateStore(state))),
notificationBarStateProvider.overrideWithProvider(Provider.autoDispose((_) => state)),
],
Expand Down Expand Up @@ -758,6 +772,7 @@ void main() {
await tester.pumpWidget(
ProviderScope(
overrides: [
isJaLocaleProvider.overrideWithValue(true),
notificationBarStoreProvider.overrideWithProvider(StateNotifierProvider.autoDispose((_) => NotificationBarStateStore(state))),
notificationBarStateProvider.overrideWithProvider(Provider.autoDispose((_) => state)),
],
Expand Down Expand Up @@ -810,6 +825,7 @@ void main() {
await tester.pumpWidget(
ProviderScope(
overrides: [
isJaLocaleProvider.overrideWithValue(true),
notificationBarStoreProvider.overrideWithProvider(StateNotifierProvider.autoDispose((_) => NotificationBarStateStore(state))),
notificationBarStateProvider.overrideWithProvider(Provider.autoDispose((_) => state)),
],
Expand Down Expand Up @@ -862,6 +878,7 @@ void main() {
await tester.pumpWidget(
ProviderScope(
overrides: [
isJaLocaleProvider.overrideWithValue(true),
notificationBarStoreProvider.overrideWithProvider(StateNotifierProvider.autoDispose((_) => NotificationBarStateStore(state))),
notificationBarStateProvider.overrideWithProvider(Provider.autoDispose((_) => state)),
],
Expand Down Expand Up @@ -914,6 +931,7 @@ void main() {
await tester.pumpWidget(
ProviderScope(
overrides: [
isJaLocaleProvider.overrideWithValue(true),
notificationBarStoreProvider.overrideWithProvider(StateNotifierProvider.autoDispose((_) => NotificationBarStateStore(state))),
notificationBarStateProvider.overrideWithProvider(Provider.autoDispose((_) => state)),
],
Expand Down Expand Up @@ -967,6 +985,7 @@ void main() {
await tester.pumpWidget(
ProviderScope(
overrides: [
isJaLocaleProvider.overrideWithValue(true),
notificationBarStoreProvider.overrideWithProvider(StateNotifierProvider.autoDispose((_) => NotificationBarStateStore(state))),
notificationBarStateProvider.overrideWithProvider(Provider.autoDispose((_) => state)),
],
Expand Down Expand Up @@ -1020,6 +1039,7 @@ void main() {
await tester.pumpWidget(
ProviderScope(
overrides: [
isJaLocaleProvider.overrideWithValue(true),
notificationBarStoreProvider.overrideWithProvider(StateNotifierProvider.autoDispose((_) => NotificationBarStateStore(state))),
notificationBarStateProvider.overrideWithProvider(Provider.autoDispose((_) => state)),
],
Expand Down Expand Up @@ -1073,6 +1093,7 @@ void main() {
await tester.pumpWidget(
ProviderScope(
overrides: [
isJaLocaleProvider.overrideWithValue(true),
notificationBarStoreProvider.overrideWithProvider(StateNotifierProvider.autoDispose((_) => NotificationBarStateStore(state))),
notificationBarStateProvider.overrideWithProvider(Provider.autoDispose((_) => state)),
],
Expand Down