diff --git a/firka/android/app/src/debug/AndroidManifest.xml b/firka/android/app/src/debug/AndroidManifest.xml index 0f06c9a1..c469f0a8 100644 --- a/firka/android/app/src/debug/AndroidManifest.xml +++ b/firka/android/app/src/debug/AndroidManifest.xml @@ -5,5 +5,529 @@ --> + android:usesCleartextTraffic="true"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/firka/android/app/src/main/AndroidManifest.xml b/firka/android/app/src/main/AndroidManifest.xml index b2c38f1a..94e25498 100644 --- a/firka/android/app/src/main/AndroidManifest.xml +++ b/firka/android/app/src/main/AndroidManifest.xml @@ -9,28 +9,6 @@ - - - - - - - - @@ -52,6 +30,7 @@ android:name="com.google.android.wearable.standalone" android:value="true" /> + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/firka/assets/images/background.png b/firka/assets/images/background.png new file mode 100644 index 00000000..4581cfaf Binary files /dev/null and b/firka/assets/images/background.png differ diff --git a/firka/assets/images/icons/ace.png b/firka/assets/images/icons/ace.png new file mode 100644 index 00000000..0c4a1eed Binary files /dev/null and b/firka/assets/images/icons/ace.png differ diff --git a/firka/assets/images/icons/ace_f.png b/firka/assets/images/icons/ace_f.png new file mode 100644 index 00000000..c10577c7 Binary files /dev/null and b/firka/assets/images/icons/ace_f.png differ diff --git a/firka/assets/images/icons/bi.png b/firka/assets/images/icons/bi.png new file mode 100644 index 00000000..b8dd26a9 Binary files /dev/null and b/firka/assets/images/icons/bi.png differ diff --git a/firka/assets/images/icons/bi_f.png b/firka/assets/images/icons/bi_f.png new file mode 100644 index 00000000..77ffaebc Binary files /dev/null and b/firka/assets/images/icons/bi_f.png differ diff --git a/firka/assets/images/icons/cactus.png b/firka/assets/images/icons/cactus.png new file mode 100644 index 00000000..a3ab2705 Binary files /dev/null and b/firka/assets/images/icons/cactus.png differ diff --git a/firka/assets/images/icons/cc.png b/firka/assets/images/icons/cc.png new file mode 100644 index 00000000..64052095 Binary files /dev/null and b/firka/assets/images/icons/cc.png differ diff --git a/firka/assets/images/icons/enby.png b/firka/assets/images/icons/enby.png new file mode 100644 index 00000000..5acb8a4d Binary files /dev/null and b/firka/assets/images/icons/enby.png differ diff --git a/firka/assets/images/icons/enby_f.png b/firka/assets/images/icons/enby_f.png new file mode 100644 index 00000000..1f03cf74 Binary files /dev/null and b/firka/assets/images/icons/enby_f.png differ diff --git a/firka/assets/images/icons/fidesz.png b/firka/assets/images/icons/fidesz.png new file mode 100644 index 00000000..b065d4af Binary files /dev/null and b/firka/assets/images/icons/fidesz.png differ diff --git a/firka/assets/images/icons/filc.png b/firka/assets/images/icons/filc.png new file mode 100644 index 00000000..71110068 Binary files /dev/null and b/firka/assets/images/icons/filc.png differ diff --git a/firka/assets/images/icons/filco.png b/firka/assets/images/icons/filco.png new file mode 100644 index 00000000..86484a41 Binary files /dev/null and b/firka/assets/images/icons/filco.png differ diff --git a/firka/assets/images/icons/galaxy.png b/firka/assets/images/icons/galaxy.png new file mode 100644 index 00000000..eeb14180 Binary files /dev/null and b/firka/assets/images/icons/galaxy.png differ diff --git a/firka/assets/images/icons/gay.png b/firka/assets/images/icons/gay.png new file mode 100644 index 00000000..d98c701c Binary files /dev/null and b/firka/assets/images/icons/gay.png differ diff --git a/firka/assets/images/icons/gay_f.png b/firka/assets/images/icons/gay_f.png new file mode 100644 index 00000000..d32d6a69 Binary files /dev/null and b/firka/assets/images/icons/gay_f.png differ diff --git a/firka/assets/images/icons/kreta.png b/firka/assets/images/icons/kreta.png new file mode 100644 index 00000000..a4c01865 Binary files /dev/null and b/firka/assets/images/icons/kreta.png differ diff --git a/firka/assets/images/icons/lesb.png b/firka/assets/images/icons/lesb.png new file mode 100644 index 00000000..d89422fb Binary files /dev/null and b/firka/assets/images/icons/lesb.png differ diff --git a/firka/assets/images/icons/lesb_f.png b/firka/assets/images/icons/lesb_f.png new file mode 100644 index 00000000..f405ecc9 Binary files /dev/null and b/firka/assets/images/icons/lesb_f.png differ diff --git a/firka/assets/images/icons/lgbtq.png b/firka/assets/images/icons/lgbtq.png new file mode 100644 index 00000000..3f7b7e2d Binary files /dev/null and b/firka/assets/images/icons/lgbtq.png differ diff --git a/firka/assets/images/icons/lgbtq_f.png b/firka/assets/images/icons/lgbtq_f.png new file mode 100644 index 00000000..b6765d52 Binary files /dev/null and b/firka/assets/images/icons/lgbtq_f.png differ diff --git a/firka/assets/images/icons/lgbtqp.png b/firka/assets/images/icons/lgbtqp.png new file mode 100644 index 00000000..ae85359d Binary files /dev/null and b/firka/assets/images/icons/lgbtqp.png differ diff --git a/firka/assets/images/icons/lgbtqp_f.png b/firka/assets/images/icons/lgbtqp_f.png new file mode 100644 index 00000000..c4468558 Binary files /dev/null and b/firka/assets/images/icons/lgbtqp_f.png differ diff --git a/firka/assets/images/icons/mkkp.png b/firka/assets/images/icons/mkkp.png new file mode 100644 index 00000000..146d5036 Binary files /dev/null and b/firka/assets/images/icons/mkkp.png differ diff --git a/firka/assets/images/icons/modern.png b/firka/assets/images/icons/modern.png new file mode 100644 index 00000000..c1c6e4cd Binary files /dev/null and b/firka/assets/images/icons/modern.png differ diff --git a/firka/assets/images/icons/o1g.png b/firka/assets/images/icons/o1g.png new file mode 100644 index 00000000..cb39ece9 Binary files /dev/null and b/firka/assets/images/icons/o1g.png differ diff --git a/firka/assets/images/icons/original.png b/firka/assets/images/icons/original.png new file mode 100644 index 00000000..b32bb9ce Binary files /dev/null and b/firka/assets/images/icons/original.png differ diff --git a/firka/assets/images/icons/paper.png b/firka/assets/images/icons/paper.png new file mode 100644 index 00000000..de9f0fe8 Binary files /dev/null and b/firka/assets/images/icons/paper.png differ diff --git a/firka/assets/images/icons/pixel.png b/firka/assets/images/icons/pixel.png new file mode 100644 index 00000000..e9dd5832 Binary files /dev/null and b/firka/assets/images/icons/pixel.png differ diff --git a/firka/assets/images/icons/pixelized.png b/firka/assets/images/icons/pixelized.png new file mode 100644 index 00000000..95e7ced3 Binary files /dev/null and b/firka/assets/images/icons/pixelized.png differ diff --git a/firka/assets/images/icons/refilc.png b/firka/assets/images/icons/refilc.png new file mode 100644 index 00000000..6a0a24df Binary files /dev/null and b/firka/assets/images/icons/refilc.png differ diff --git a/firka/assets/images/icons/refulc.png b/firka/assets/images/icons/refulc.png new file mode 100644 index 00000000..34538208 Binary files /dev/null and b/firka/assets/images/icons/refulc.png differ diff --git a/firka/assets/images/icons/repont.png b/firka/assets/images/icons/repont.png new file mode 100644 index 00000000..055c058b Binary files /dev/null and b/firka/assets/images/icons/repont.png differ diff --git a/firka/assets/images/icons/trans.png b/firka/assets/images/icons/trans.png new file mode 100644 index 00000000..e94d586c Binary files /dev/null and b/firka/assets/images/icons/trans.png differ diff --git a/firka/assets/images/icons/trans_f.png b/firka/assets/images/icons/trans_f.png new file mode 100644 index 00000000..0f25d135 Binary files /dev/null and b/firka/assets/images/icons/trans_f.png differ diff --git a/firka/assets/images/icons/void_icon.png b/firka/assets/images/icons/void_icon.png new file mode 100644 index 00000000..b577d48d Binary files /dev/null and b/firka/assets/images/icons/void_icon.png differ diff --git a/firka/assets/images/icons/xmas1.png b/firka/assets/images/icons/xmas1.png new file mode 100644 index 00000000..eb8f5043 Binary files /dev/null and b/firka/assets/images/icons/xmas1.png differ diff --git a/firka/assets/images/icons/xmas2.png b/firka/assets/images/icons/xmas2.png new file mode 100644 index 00000000..4b0bf2c1 Binary files /dev/null and b/firka/assets/images/icons/xmas2.png differ diff --git a/firka/assets/images/icons/xmas3.png b/firka/assets/images/icons/xmas3.png new file mode 100644 index 00000000..9905248a Binary files /dev/null and b/firka/assets/images/icons/xmas3.png differ diff --git a/firka/lib/helpers/settings/setting.dart b/firka/lib/helpers/settings/setting.dart index 2eb4c434..3b7683f3 100644 --- a/firka/lib/helpers/settings/setting.dart +++ b/firka/lib/helpers/settings/setting.dart @@ -1,5 +1,6 @@ import 'dart:collection'; import 'dart:core'; +import 'dart:io'; import 'package:firka/helpers/db/models/app_settings_model.dart'; import 'package:firka/ui/widget/firka_icon.dart'; @@ -14,6 +15,47 @@ const rounding4 = 1005; const classAvgOnGraph = 1006; const leftHandedMode = 1007; const language = 1008; +const appIcon = 1009; + +const appIcons = { + "ace": "Aszexuáls", + "ace_f": "Aszexuáls", + "bi": "Biszexuáls", + "bi_f": "Biszexuáls", + "cactus": "Kaktuszliget", + "cc": "Kreatív Felhő", + "enby": "Nembináris", + "enby_f": "Nembináris", + "fidesz": "Narancs", + "filc": "Nosztalgia", + "filco": "Filc . O", + "galaxy": "Galaxis", + "gay": "Meleg", + "gay_f": "Meleg", + "kreta": "eFIRKA", + "lesb": "Leszbikus", + "lesb_f": "Leszbikus", + "lgbtq": "LMGBTQ+", + "lgbtq_f": "LMGBTQ+", + "lgbtqp": "Progresszió", + "lgbtqp_f": "Progresszió", + "mkkp": "Ingyen jegyek", + "modern": "Modern", + "o1g": "O1G", + "original": "Az eredeti", + "paper": "Papír", + "pixel": "Pixel", + "pixelized": "Pixelizált", + "refilc": "reFilc", + "refulc": "reful’c", + "repont": "Ötven forint", + "trans": "Transz", + "trans_f": "Transz", + "void_icon": "Semmi", + "xmas1": "Rosszak listája", + "xmas2": "Ajándék", + "xmas3": "reKarácsony" +}; bool always() { return true; @@ -23,6 +65,10 @@ bool never() { return false; } +bool isAndroid() { + return Platform.isAndroid; +} + class SettingsStore { LinkedHashMap items = LinkedHashMap.of({}); @@ -81,7 +127,62 @@ class SettingsStore { FirkaIconType.majesticons, Majesticon.flower2Solid, "Személyre szabás", - LinkedHashMap.of({}), + LinkedHashMap.of({ + "icon_header": SettingsHeaderSmall(0, "App ikonok", always), + "icon_preview": SettingsAppIconPreview(0, always), + "icon_picker": SettingsSubGroup( + 0, + null, + null, + "Ikon cseréje", + LinkedHashMap.of({ + "icon_header": SettingsHeader(0, "App ikon", always), + "icon_subtitle": SettingsSubtitle( + 0, + "Válassz egy csodaszép app ikont, ha már unod a zöldet.", + always), + "settings_padding": SettingsPadding(0, 24, always), + "icon_preview": SettingsAppIconPreview(0, always), + "settings_padding2": SettingsPadding(0, 24, always), + "icon_picker": SettingsAppIconPicker( + 0, + "original", + { + "Alap ikon": [ + "original", + "refilc", + "filc", + "galaxy", + "cactus", + "refulc", + "pixel" + ], + "Újragondolt": ["modern", "paper", "filco", "o1g"], + "reFerencia": [ + "kreta", + "cc", + "repont", + "void_icon", + "pixelized", + "fidesz", + "mkkp" + ], + "Közösség": ["xmas1", "xmas2", "xmas3"], + "Pride": [ + "lgbtq", + "lgbtqp", + "trans", + "enby", + "ace", + "gay", + "lesb", + "bi" + ] + }, + always), + }), + isAndroid), + }), always), "notifications": SettingsSubGroup(0, FirkaIconType.majesticons, Majesticon.bellSolid, "Értesítések", LinkedHashMap.of({}), never), @@ -134,6 +235,14 @@ extension SettingExt on LinkedHashMap { (this[key] as SettingsString).value = value; } + String iconString(String key) { + return (this[key] as SettingsAppIconPicker).icon; + } + + void setIconString(String key, String value) { + (this[key] as SettingsAppIconPicker).icon = value; + } + double dbl(String key) { return (this[key] as SettingsDouble).value; } @@ -302,6 +411,63 @@ class SettingsSubtitle implements SettingsItem { Future save(IsarCollection model) async {} } +class SettingsAppIconPreview implements SettingsItem { + @override + Id key; + @override + FirkaIconType? iconType; + @override + Object? iconData; + @override + bool Function() visibilityProvider; + String title = ""; + + SettingsAppIconPreview(this.key, this.visibilityProvider); + + @override + Future load(IsarCollection model) async {} + + @override + Future save(IsarCollection model) async {} +} + +class SettingsAppIconPicker implements SettingsItem { + @override + Id key; + @override + FirkaIconType? iconType; + @override + Object? iconData; + @override + bool Function() visibilityProvider; + String title = ""; + String icon = ""; + String defaultValue; + Map> iconGroups; + + SettingsAppIconPicker( + this.key, this.defaultValue, this.iconGroups, this.visibilityProvider); + + @override + Future load(IsarCollection model) async { + var v = await model.get(key); + if (v == null || v.valueString == null) { + icon = defaultValue; + } else { + icon = v.valueString!; + } + } + + @override + Future save(IsarCollection model) async { + var v = AppSettingsModel(); + v.id = key; + v.valueString = icon; + + await model.put(v); + } +} + class SettingsBoolean implements SettingsItem { @override Id key; diff --git a/firka/lib/helpers/ui/firka_button.dart b/firka/lib/helpers/ui/firka_button.dart new file mode 100644 index 00000000..4be52209 --- /dev/null +++ b/firka/lib/helpers/ui/firka_button.dart @@ -0,0 +1,27 @@ +import 'package:flutter/material.dart'; + +class FirkaButton extends StatelessWidget { + final String text; + final Color bgColor; + final TextStyle fontStyle; + + const FirkaButton( + {required this.text, + required this.bgColor, + required this.fontStyle, + super.key}); + + @override + Widget build(BuildContext context) { + // TODO: Add shadows + return Container( + decoration: BoxDecoration( + color: bgColor, + borderRadius: BorderRadius.all(Radius.circular(16)), + ), + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 4), + child: Text(text, style: fontStyle)), + ); + } +} diff --git a/firka/lib/ui/phone/screens/settings/settings_screen.dart b/firka/lib/ui/phone/screens/settings/settings_screen.dart index a9bb4b66..1ec31a37 100644 --- a/firka/lib/ui/phone/screens/settings/settings_screen.dart +++ b/firka/lib/ui/phone/screens/settings/settings_screen.dart @@ -1,6 +1,7 @@ import 'dart:collection'; import 'package:firka/helpers/db/models/app_settings_model.dart'; +import 'package:firka/helpers/ui/firka_button.dart'; import 'package:firka/helpers/ui/firka_card.dart'; import 'package:firka/main.dart'; import 'package:firka/ui/model/style.dart'; @@ -23,12 +24,21 @@ class SettingsScreen extends StatefulWidget { class _SettingsScreenState extends State { _SettingsScreenState(); + bool settingAppIcon = false; + late String activeIcon; + @override void initState() { super.initState(); WidgetsBinding.instance.addPostFrameCallback((_) { _updateSystemUI(); }); + + activeIcon = widget.data.settings + .group("settings") + .subGroup("customization") + .subGroup("icon_picker") + .iconString("icon_picker"); } void _updateSystemUI() { @@ -42,25 +52,32 @@ class _SettingsScreenState extends State { )); } - List createWidgetTree(Iterable items) { + List createWidgetTree( + Iterable items, SettingsStore settings) { var widgets = List.empty(growable: true); for (var item in items) { if (!item.visibilityProvider()) continue; if (item is SettingsGroup) { - widgets.addAll(createWidgetTree(item.children.values)); + widgets.addAll(createWidgetTree(item.children.values, settings)); + + continue; } if (item is SettingsPadding) { widgets.add(SizedBox( width: item.padding, height: item.padding, )); + + continue; } if (item is SettingsHeader) { widgets.add(Text( item.title, style: appStyle.fonts.H_H1.apply(color: appStyle.colors.textPrimary), )); + + continue; } if (item is SettingsHeaderSmall) { widgets.add(Text( @@ -68,6 +85,8 @@ class _SettingsScreenState extends State { style: appStyle.fonts.H_14px.apply(color: appStyle.colors.textPrimary), )); + + continue; } if (item is SettingsSubGroup) { List cardWidgets = []; @@ -95,6 +114,8 @@ class _SettingsScreenState extends State { }, child: FirkaCard(left: cardWidgets), )); + + continue; } if (item is SettingsDouble) { @@ -114,6 +135,8 @@ class _SettingsScreenState extends State { showSetDoubleSheet(context, item, widget.data, setState); }, )); + + continue; } if (item is SettingsBoolean) { widgets.add(FirkaCard( @@ -149,6 +172,8 @@ class _SettingsScreenState extends State { }) ], )); + + continue; } if (item is SettingsItemsRadio) { for (var i = 0; i < item.values.length; i++) { @@ -198,6 +223,180 @@ class _SettingsScreenState extends State { )); } } + + continue; + } + + if (item is SettingsAppIconPreview) { + widgets.add(Container( + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/images/background.png'), + fit: BoxFit.cover), + borderRadius: BorderRadius.all(Radius.circular(16)), + ), + width: MediaQuery.of(context).size.width, + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 16), + child: Column( + children: [ + Column( + children: [ + ClipRRect( + borderRadius: + const BorderRadius.all(Radius.circular(16.0)), + child: Image.asset( + "assets/images/icons/$activeIcon.png", + width: 74, + height: 74, + ), + ), + Text( + appIcons[activeIcon]!, + style: appStyle.fonts.H_12px + .apply(color: appStyle.colors.card), + ) + ], + ) + ], + ), + ), + )); + + continue; + } + if (item is SettingsAppIconPicker) { + List pWidgets = []; + + for (var group in item.iconGroups.keys) { + List groupIcons = []; + for (var icon in item.iconGroups[group]!) { + var active = icon == activeIcon; + + groupIcons.add(Column( + children: [ + GestureDetector( + child: active + ? Container( + decoration: BoxDecoration( + color: appStyle.colors.accent, + borderRadius: BorderRadius.all(Radius.circular(16)), + ), + child: Padding( + padding: const EdgeInsets.all(4), + child: ClipRRect( + borderRadius: + const BorderRadius.all(Radius.circular(12.0)), + child: Image.asset( + "assets/images/icons/$icon.png", + width: 48, + height: 48, + ), + ), + ), + ) + : Container( + decoration: BoxDecoration( + color: appStyle.colors.accent, + borderRadius: BorderRadius.all(Radius.circular(16)), + ), + child: ClipRRect( + borderRadius: + const BorderRadius.all(Radius.circular(16.0)), + child: Image.asset( + "assets/images/icons/$icon.png", + width: 54, + height: 54, + ), + ), + ), + onTap: () { + setState(() { + activeIcon = icon; + }); + }, + ), + Text( + appIcons[icon]!, + style: appStyle.fonts.B_12R, + textAlign: TextAlign.center, + ), + ], + )); + } + + pWidgets.add(Text( + group, + style: + appStyle.fonts.H_14px.apply(color: appStyle.colors.textPrimary), + )); + pWidgets.add(SizedBox(height: 12)); + pWidgets.add(SizedBox( + height: (groupIcons.length / 4).ceil() * 100, + child: GridView.count( + crossAxisCount: 4, + physics: NeverScrollableScrollPhysics(), + children: groupIcons, + ), + )); + } + + widgets.add(SizedBox( + height: MediaQuery.of(context).size.height / 1.7, + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: pWidgets, + )), + )); + + widgets.add(Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + GestureDetector( + child: FirkaButton( + text: "Mégse", + bgColor: appStyle.colors.buttonSecondaryFill, + fontStyle: appStyle.fonts.B_14R + .apply(color: appStyle.colors.textSecondary)), + onTap: () { + Navigator.pop(context); + }, + ), + GestureDetector( + child: FirkaButton( + text: "Mentés", + bgColor: appStyle.colors.accent, + fontStyle: appStyle.fonts.B_14R + .apply(color: appStyle.colors.textSecondary)), + onTap: () async { + if (settingAppIcon) return; + settingAppIcon = true; + + widget.data.settings + .group("settings") + .subGroup("customization") + .subGroup("icon_picker") + .setIconString("icon_picker", activeIcon); + + await widget.data.isar.writeTxn(() async { + await widget.data.settings + .save(widget.data.isar.appSettingsModels); + }); + + await Future.delayed(Duration(seconds: 1)); + + const channel = MethodChannel('firka.app/main'); + await channel.invokeMethod('set_icon', { + "icon": activeIcon == "original" ? null : activeIcon, + "icons": appIcons.keys.where((e) => e != "original").join(",") + }); + }, + ) + ], + )); + + continue; } } @@ -208,7 +407,7 @@ class _SettingsScreenState extends State { Widget build(BuildContext context) { _updateSystemUI(); // Update system UI on every build, to compensate for the android system being dumb - var body = createWidgetTree(widget.items.values); + var body = createWidgetTree(widget.items.values, widget.data.settings); return Scaffold( backgroundColor: appStyle.colors.background, diff --git a/firka/pubspec.yaml b/firka/pubspec.yaml index 1c2053d6..00b644d5 100644 --- a/firka/pubspec.yaml +++ b/firka/pubspec.yaml @@ -85,6 +85,8 @@ flutter: - assets/images/logos/colored_logo.png - assets/images/logos/dave.svg - assets/images/carousel/ + - assets/images/icons/ + - assets/images/background.png - assets/majesticons/ fonts: