Skip to content

Commit

Permalink
feat: FCM topic subscribe
Browse files Browse the repository at this point in the history
  • Loading branch information
sparcscasio committed Sep 11, 2024
1 parent b6505e0 commit 5378959
Show file tree
Hide file tree
Showing 4 changed files with 259 additions and 106 deletions.
5 changes: 5 additions & 0 deletions assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@
"language": "Language",
"korean": "Korean",
"english": "English",
"get_alarm" : "Receive notifications",
"get_alarm_desc" : "Receive notifications about various topics",
"get_promotion_alarm" : "Receive promotion notifications",
"get_information_alarm" : "Receive information notifications",
"get_subject_suggestion_alarm" : "Receive subject suggestion notification",
"send_error_log": "Send error log",
"send_error_log_desc": "Automatically collect logs without user reporting",
"send_anonymously": "Send anonymously",
Expand Down
5 changes: 5 additions & 0 deletions assets/translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@
"language": "언어",
"korean": "한국어",
"english": "영어",
"get_alarm" : "알림 받기",
"get_alarm_desc" : "다양한 주제에 대한 알림을 수신합니다.",
"get_promotion_alarm" : "광고성 알림 수신",
"get_information_alarm" : "정보성 알림 수신",
"get_subject_suggestion_alarm" : "과목 제안 알림 수신",
"send_error_log": "오류 로그 전송",
"send_error_log_desc": "사용자의 제보 없이 자동으로 오류를 수집합니다.",
"send_anonymously": "익명으로 전송",
Expand Down
269 changes: 163 additions & 106 deletions lib/pages/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,127 +25,184 @@ class SettingsPage extends StatelessWidget {
color: OTLColor.grayF,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"settings.language".tr(),
style: bodyBold,
),
Dropdown<bool>(
customButton: Container(
height: 34,
padding: const EdgeInsets.symmetric(horizontal: 16),
decoration: BoxDecoration(
color: OTLColor.pinksLight,
borderRadius: BorderRadius.circular(20),
),
child: Row(
children: [
Icon(
Icons.language,
color: OTLColor.pinksMain,
),
const SizedBox(width: 8),
Text(
isEn
? "settings.english".tr()
: "settings.korean".tr(),
style: bodyBold.copyWith(
height: 1.2, color: OTLColor.pinksMain),
)
],
),
child: SingleChildScrollView(
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"settings.language".tr(),
style: bodyBold,
),
items: [
ItemData(
value: false,
text: "settings.korean".tr(),
icon: !isEn ? Icons.check : null,
),
ItemData(
value: true,
text: "settings.english".tr(),
icon: isEn ? Icons.check : null,
Dropdown<bool>(
customButton: Container(
height: 34,
padding: const EdgeInsets.symmetric(horizontal: 16),
decoration: BoxDecoration(
color: OTLColor.pinksLight,
borderRadius: BorderRadius.circular(20),
),
child: Row(
children: [
Icon(
Icons.language,
color: OTLColor.pinksMain,
),
const SizedBox(width: 8),
Text(
isEn
? "settings.english".tr()

Check warning on line 55 in lib/pages/settings_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/settings_page.dart#L55

Added line #L55 was not covered by tests
: "settings.korean".tr(),
style: bodyBold.copyWith(
height: 1.2, color: OTLColor.pinksMain),
)
],
),
),
],
isIconLeft: true,
offsetY: -6,
onChanged: (value) {
if (value!) {
EasyLocalization.of(context)?.setLocale(Locale('en'));
} else {
EasyLocalization.of(context)?.setLocale(Locale('ko'));
}
},
items: [
ItemData(
value: false,
text: "settings.korean".tr(),
icon: !isEn ? Icons.check : null,
),
ItemData(
value: true,
text: "settings.english".tr(),
icon: isEn ? Icons.check : null,
),
],
isIconLeft: true,
offsetY: -6,
onChanged: (value) {

Check warning on line 77 in lib/pages/settings_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/settings_page.dart#L77

Added line #L77 was not covered by tests
if (value!) {
EasyLocalization.of(context)
?.setLocale(Locale('en'));

Check warning on line 80 in lib/pages/settings_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/settings_page.dart#L79-L80

Added lines #L79 - L80 were not covered by tests
} else {
EasyLocalization.of(context)
?.setLocale(Locale('ko'));

Check warning on line 83 in lib/pages/settings_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/settings_page.dart#L82-L83

Added lines #L82 - L83 were not covered by tests
}
},
),
],
),
// TODO : UI 좀 예쁘게 어떻게 안되나 + 번역 추가
_buildListTile(
title: "settings.get_alarm".tr(),
subtitle: "settings.get_alarm_desc".tr(),
trailing: CupertinoSwitch(
value: context.watch<SettingsModel>().getSendAlarm(),
onChanged: (value) =>
context.read<SettingsModel>().setSendAlarm(value),

Check warning on line 96 in lib/pages/settings_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/settings_page.dart#L95-L96

Added lines #L95 - L96 were not covered by tests
),
],
),
_buildListTile(
title: "settings.send_error_log".tr(),
subtitle: "settings.send_error_log_desc".tr(),
trailing: CupertinoSwitch(
value: context.watch<SettingsModel>().getSendCrashlytics(),
onChanged: (value) =>
context.read<SettingsModel>().setSendCrashlytics(value),
),
),
Visibility(
visible: context.watch<SettingsModel>().getSendCrashlytics(),
child: _buildListTile(
title: "settings.send_anonymously".tr(),
subtitle: "settings.send_anonymously_desc".tr(),
Visibility(
visible: context.watch<SettingsModel>().getSendAlarm(),
child: _buildListTile(
title: "settings.get_subject_suggestion_alarm".tr(),
trailing: CupertinoSwitch(
value: context
.watch<SettingsModel>()
.getSubjectSuggestionAlarm(),
onChanged: (value) => context
.read<SettingsModel>()
.setSubjectSuggestionAlarm(value),

Check warning on line 109 in lib/pages/settings_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/settings_page.dart#L107-L109

Added lines #L107 - L109 were not covered by tests
),
),
),
Visibility(
visible: context.watch<SettingsModel>().getSendAlarm(),
child: _buildListTile(
title: "settings.get_promotion_alarm".tr(),
trailing: CupertinoSwitch(
value:
context.watch<SettingsModel>().getPromotionAlarm(),
onChanged: (value) => context
.read<SettingsModel>()
.setPromotionAlarm(value),

Check warning on line 122 in lib/pages/settings_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/settings_page.dart#L120-L122

Added lines #L120 - L122 were not covered by tests
),
),
),
Visibility(
visible: context.watch<SettingsModel>().getSendAlarm(),
child: _buildListTile(
title: "settings.get_information_alarm".tr(),
trailing: CupertinoSwitch(
value:
context.watch<SettingsModel>().getInfomationAlarm(),
onChanged: (value) => context
.read<SettingsModel>()
.setInformationAlarm(value),

Check warning on line 135 in lib/pages/settings_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/settings_page.dart#L133-L135

Added lines #L133 - L135 were not covered by tests
),
),
),
_buildListTile(
title: "settings.send_error_log".tr(),
subtitle: "settings.send_error_log_desc".tr(),
trailing: CupertinoSwitch(
value: context
.watch<SettingsModel>()
.getSendCrashlyticsAnonymously(),
value:
context.watch<SettingsModel>().getSendCrashlytics(),
onChanged: (value) => context
.read<SettingsModel>()
.setSendCrashlyticsAnonymously(value),
.setSendCrashlytics(value),

Check warning on line 147 in lib/pages/settings_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/settings_page.dart#L147

Added line #L147 was not covered by tests
),
),
),
Visibility(
visible: kDebugMode,
child: _buildListTile(
title: "settings.throw_test".tr(),
subtitle: "settings.throw_test_desc".tr(),
onTap: () => throw Exception(),
Visibility(
visible:
context.watch<SettingsModel>().getSendCrashlytics(),
child: _buildListTile(
title: "settings.send_anonymously".tr(),
subtitle: "settings.send_anonymously_desc".tr(),
trailing: CupertinoSwitch(
value: context
.watch<SettingsModel>()
.getSendCrashlyticsAnonymously(),
onChanged: (value) => context
.read<SettingsModel>()
.setSendCrashlyticsAnonymously(value),

Check warning on line 162 in lib/pages/settings_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/settings_page.dart#L160-L162

Added lines #L160 - L162 were not covered by tests
),
),
),
),
_buildListTile(
title: "settings.reset_all".tr(),
onTap: () {
OTLNavigator.pushDialog(
Visibility(
visible: kDebugMode,
child: _buildListTile(
title: "settings.throw_test".tr(),
subtitle: "settings.throw_test_desc".tr(),
onTap: () => throw Exception(),

Check warning on line 171 in lib/pages/settings_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/settings_page.dart#L171

Added line #L171 was not covered by tests
),
),
_buildListTile(
title: "settings.reset_all".tr(),
onTap: () {
OTLNavigator.pushDialog(

Check warning on line 177 in lib/pages/settings_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/settings_page.dart#L176-L177

Added lines #L176 - L177 were not covered by tests
context: context,
builder: (_) => OTLDialog(

Check warning on line 179 in lib/pages/settings_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/settings_page.dart#L179

Added line #L179 was not covered by tests
type: OTLDialogType.resetSettings,
onTapPos: () =>
context.read<SettingsModel>().clearAllValues(),

Check warning on line 182 in lib/pages/settings_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/settings_page.dart#L181-L182

Added lines #L181 - L182 were not covered by tests
),
);
},
),
_buildListTile(
title: "settings.about".tr(),
onTap: () => OTLNavigator.pushDialog(

Check warning on line 189 in lib/pages/settings_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/settings_page.dart#L189

Added line #L189 was not covered by tests
context: context,
builder: (_) => OTLDialog(
type: OTLDialogType.resetSettings,
onTapPos: () =>
context.read<SettingsModel>().clearAllValues(),
),
);
},
),
_buildListTile(
title: "settings.about".tr(),
onTap: () => OTLNavigator.pushDialog(
context: context,
builder: (_) => OTLDialog(
type: OTLDialogType.about,
onTapContent: () =>
launchUrl(Uri.parse("mailto:$CONTACT")),
onTapPos: () => showLicensePage(
context: context,
applicationName: "",
applicationIcon:
Image.asset("assets/images/logo.png", height: 48.0),
type: OTLDialogType.about,
onTapContent: () =>
launchUrl(Uri.parse("mailto:$CONTACT")),
onTapPos: () => showLicensePage(

Check warning on line 195 in lib/pages/settings_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/settings_page.dart#L193-L195

Added lines #L193 - L195 were not covered by tests
context: context,
applicationName: "",
applicationIcon: Image.asset("assets/images/logo.png",

Check warning on line 198 in lib/pages/settings_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/settings_page.dart#L198

Added line #L198 was not covered by tests
height: 48.0),
),
),
),
),
),
],
],
),
),
),
),
Expand Down
Loading

0 comments on commit 5378959

Please sign in to comment.