From 3b89ba8e7992546d7b65320724081d9ffb43a500 Mon Sep 17 00:00:00 2001 From: Armand <4831c0@proton.me> Date: Fri, 29 Aug 2025 08:39:30 +0200 Subject: [PATCH] chore: dos2unix --- firka/android/app/proguard-rules.pro | 2 +- .../main/kotlin/app/firka/naplo/AppMain.kt | 196 +-- .../main/kotlin/app/firka/naplo/Extensions.kt | 130 +- .../app/firka/naplo/glance/LessonCard.kt | 220 +-- .../app/firka/naplo/glance/TimetableWidget.kt | 220 +-- .../naplo/glance/TimetableWidgetReceiver.kt | 12 +- .../kotlin/app/firka/naplo/model/Colors.kt | 72 +- .../kotlin/app/firka/naplo/model/Lesson.kt | 186 +-- .../kotlin/app/firka/naplo/model/NameUid.kt | 18 +- .../app/firka/naplo/model/NameUidDesc.kt | 20 +- .../kotlin/app/firka/naplo/model/Subject.kt | 22 +- .../src/main/res/mipmap-anydpi-v26/ic_ace.xml | 8 +- .../main/res/mipmap-anydpi-v26/ic_ace_f.xml | 8 +- .../res/mipmap-anydpi-v26/ic_ace_f_round.xml | 8 +- .../res/mipmap-anydpi-v26/ic_ace_round.xml | 8 +- .../src/main/res/mipmap-anydpi-v26/ic_bi.xml | 8 +- .../main/res/mipmap-anydpi-v26/ic_bi_f.xml | 8 +- .../res/mipmap-anydpi-v26/ic_bi_f_round.xml | 8 +- .../res/mipmap-anydpi-v26/ic_bi_round.xml | 8 +- .../main/res/mipmap-anydpi-v26/ic_cactus.xml | 8 +- .../res/mipmap-anydpi-v26/ic_cactus_round.xml | 8 +- .../src/main/res/mipmap-anydpi-v26/ic_cc.xml | 8 +- .../res/mipmap-anydpi-v26/ic_cc_round.xml | 8 +- .../main/res/mipmap-anydpi-v26/ic_enby.xml | 8 +- .../main/res/mipmap-anydpi-v26/ic_enby_f.xml | 8 +- .../res/mipmap-anydpi-v26/ic_enby_f_round.xml | 8 +- .../res/mipmap-anydpi-v26/ic_enby_round.xml | 8 +- .../main/res/mipmap-anydpi-v26/ic_fidesz.xml | 8 +- .../res/mipmap-anydpi-v26/ic_fidesz_round.xml | 8 +- .../main/res/mipmap-anydpi-v26/ic_filc.xml | 8 +- .../res/mipmap-anydpi-v26/ic_filc_round.xml | 8 +- .../main/res/mipmap-anydpi-v26/ic_filco.xml | 8 +- .../res/mipmap-anydpi-v26/ic_filco_round.xml | 8 +- .../main/res/mipmap-anydpi-v26/ic_galaxy.xml | 8 +- .../res/mipmap-anydpi-v26/ic_galaxy_round.xml | 8 +- .../src/main/res/mipmap-anydpi-v26/ic_gay.xml | 8 +- .../main/res/mipmap-anydpi-v26/ic_gay_f.xml | 8 +- .../res/mipmap-anydpi-v26/ic_gay_f_round.xml | 8 +- .../res/mipmap-anydpi-v26/ic_gay_round.xml | 8 +- .../main/res/mipmap-anydpi-v26/ic_kreta.xml | 8 +- .../res/mipmap-anydpi-v26/ic_kreta_round.xml | 8 +- .../main/res/mipmap-anydpi-v26/ic_lesb.xml | 8 +- .../main/res/mipmap-anydpi-v26/ic_lesb_f.xml | 8 +- .../res/mipmap-anydpi-v26/ic_lesb_f_round.xml | 8 +- .../res/mipmap-anydpi-v26/ic_lesb_round.xml | 8 +- .../main/res/mipmap-anydpi-v26/ic_lgbtq.xml | 8 +- .../main/res/mipmap-anydpi-v26/ic_lgbtq_f.xml | 8 +- .../mipmap-anydpi-v26/ic_lgbtq_f_round.xml | 8 +- .../res/mipmap-anydpi-v26/ic_lgbtq_round.xml | 8 +- .../main/res/mipmap-anydpi-v26/ic_lgbtqp.xml | 8 +- .../res/mipmap-anydpi-v26/ic_lgbtqp_f.xml | 8 +- .../mipmap-anydpi-v26/ic_lgbtqp_f_round.xml | 8 +- .../res/mipmap-anydpi-v26/ic_lgbtqp_round.xml | 8 +- .../main/res/mipmap-anydpi-v26/ic_mkkp.xml | 8 +- .../res/mipmap-anydpi-v26/ic_mkkp_round.xml | 8 +- .../main/res/mipmap-anydpi-v26/ic_modern.xml | 8 +- .../res/mipmap-anydpi-v26/ic_modern_round.xml | 8 +- .../src/main/res/mipmap-anydpi-v26/ic_o1g.xml | 8 +- .../res/mipmap-anydpi-v26/ic_o1g_round.xml | 8 +- .../main/res/mipmap-anydpi-v26/ic_paper.xml | 8 +- .../res/mipmap-anydpi-v26/ic_paper_round.xml | 8 +- .../main/res/mipmap-anydpi-v26/ic_pixel.xml | 8 +- .../res/mipmap-anydpi-v26/ic_pixel_round.xml | 8 +- .../res/mipmap-anydpi-v26/ic_pixelized.xml | 8 +- .../mipmap-anydpi-v26/ic_pixelized_round.xml | 8 +- .../main/res/mipmap-anydpi-v26/ic_refilc.xml | 8 +- .../res/mipmap-anydpi-v26/ic_refilc_round.xml | 8 +- .../main/res/mipmap-anydpi-v26/ic_refulc.xml | 8 +- .../res/mipmap-anydpi-v26/ic_refulc_round.xml | 8 +- .../main/res/mipmap-anydpi-v26/ic_repont.xml | 8 +- .../res/mipmap-anydpi-v26/ic_repont_round.xml | 8 +- .../main/res/mipmap-anydpi-v26/ic_trans.xml | 8 +- .../main/res/mipmap-anydpi-v26/ic_trans_f.xml | 8 +- .../mipmap-anydpi-v26/ic_trans_f_round.xml | 8 +- .../res/mipmap-anydpi-v26/ic_trans_round.xml | 8 +- .../res/mipmap-anydpi-v26/ic_void_icon.xml | 8 +- .../mipmap-anydpi-v26/ic_void_icon_round.xml | 8 +- .../main/res/mipmap-anydpi-v26/ic_xmas1.xml | 8 +- .../res/mipmap-anydpi-v26/ic_xmas1_round.xml | 8 +- .../main/res/mipmap-anydpi-v26/ic_xmas2.xml | 8 +- .../res/mipmap-anydpi-v26/ic_xmas2_round.xml | 8 +- .../main/res/mipmap-anydpi-v26/ic_xmas3.xml | 8 +- .../res/mipmap-anydpi-v26/ic_xmas3_round.xml | 8 +- .../app/src/main/res/xml/timetable_widget.xml | 12 +- .../helpers/cache_memory_image_provider.dart | 172 +- firka/lib/helpers/db/widget.dart | 142 +- firka/lib/helpers/debug_helper.dart | 34 +- firka/lib/helpers/firka_bundle.dart | 112 +- firka/lib/helpers/settings/setting.dart | 1472 ++++++++--------- .../screens/settings/settings_screen.dart | 1102 ++++++------ firka/lib/ui/widget/counter_digit.dart | 48 +- firka/lib/ui/widget/delayed_spinner.dart | 92 +- firka/lib/ui/widget/firka_icon.dart | 82 +- 93 files changed, 2471 insertions(+), 2471 deletions(-) diff --git a/firka/android/app/proguard-rules.pro b/firka/android/app/proguard-rules.pro index 1bf24361..5c661605 100644 --- a/firka/android/app/proguard-rules.pro +++ b/firka/android/app/proguard-rules.pro @@ -1,2 +1,2 @@ --keep class org.brotli.** { *; } +-keep class org.brotli.** { *; } -keep class app.firka.naplo.glance.** { *; } \ No newline at end of file diff --git a/firka/android/app/src/main/kotlin/app/firka/naplo/AppMain.kt b/firka/android/app/src/main/kotlin/app/firka/naplo/AppMain.kt index dc6672dd..2186be99 100644 --- a/firka/android/app/src/main/kotlin/app/firka/naplo/AppMain.kt +++ b/firka/android/app/src/main/kotlin/app/firka/naplo/AppMain.kt @@ -1,99 +1,99 @@ -package app.firka.naplo - -import android.annotation.SuppressLint -import android.app.Application -import android.os.Build -import android.util.Log -import org.brotli.dec.BrotliInputStream -import org.json.JSONObject -import java.io.File -import java.io.FileOutputStream -import java.security.MessageDigest -import java.util.zip.ZipFile - -class AppMain : Application() { - - private fun File.sha256(): String { - if (!exists()) return "0000000000000000000000000000000000000000000000000000000000000000" - - val md = MessageDigest.getInstance("SHA-256") - val digest = md.digest(this.readBytes()) - return digest.fold("") { str, it -> str + "%02x".format(it) } - } - - @SuppressLint("UnsafeDynamicallyLoadedCode") - override fun onCreate() { - super.onCreate() - - var useUncompressedLibs = false - - val abi = Build.SUPPORTED_ABIS[0] - - val apks = File(applicationInfo.nativeLibraryDir, "../..").absoluteFile - .listFiles()!! - .filter { file -> file.name.endsWith(".apk") } - .toList() - - var nativesApkN: ZipFile? = null - for (apk in apks) { - if (nativesApkN != null) break - - val zip = ZipFile(apk) - val entries = zip.entries() - - while (entries.hasMoreElements()) { - val entry = entries.nextElement() - - if (entry.name.endsWith("$abi/index.so")) { - zip.close() - nativesApkN = ZipFile(apk) - break - } - if (entry.name.endsWith("$abi/libflutter.so")) { - useUncompressedLibs = true - break - } - } - - zip.close() - } - - if (useUncompressedLibs) { - return; - } - - if (nativesApkN == null) { - throw Exception("Can't find native libraries") - } - val nativesApk: ZipFile = nativesApkN - - val compressedLibsIndex = nativesApk.getInputStream( - nativesApk.getEntry("lib/$abi/index.so") - ) - val compressedLibs = JSONObject(compressedLibsIndex.readBytes().toString(Charsets.UTF_8)) - - for (so in compressedLibs.keys()) { - val soFile = File(cacheDir, so) - - if (soFile.sha256() == compressedLibs.getString(so)) { - System.load(soFile.absolutePath) - return - } - - Log.d("AppMain", "Decompressing: $so") - val brInput = nativesApk.getInputStream( - nativesApk.getEntry("lib/$abi/${so.replace(".so", "-br.so")}") - ) - val soOutput = FileOutputStream(soFile) - - val brIn = BrotliInputStream(brInput) - brIn.copyTo(soOutput) - - brInput.close() - soOutput.close() - - System.load(soFile.absolutePath) - } - } - +package app.firka.naplo + +import android.annotation.SuppressLint +import android.app.Application +import android.os.Build +import android.util.Log +import org.brotli.dec.BrotliInputStream +import org.json.JSONObject +import java.io.File +import java.io.FileOutputStream +import java.security.MessageDigest +import java.util.zip.ZipFile + +class AppMain : Application() { + + private fun File.sha256(): String { + if (!exists()) return "0000000000000000000000000000000000000000000000000000000000000000" + + val md = MessageDigest.getInstance("SHA-256") + val digest = md.digest(this.readBytes()) + return digest.fold("") { str, it -> str + "%02x".format(it) } + } + + @SuppressLint("UnsafeDynamicallyLoadedCode") + override fun onCreate() { + super.onCreate() + + var useUncompressedLibs = false + + val abi = Build.SUPPORTED_ABIS[0] + + val apks = File(applicationInfo.nativeLibraryDir, "../..").absoluteFile + .listFiles()!! + .filter { file -> file.name.endsWith(".apk") } + .toList() + + var nativesApkN: ZipFile? = null + for (apk in apks) { + if (nativesApkN != null) break + + val zip = ZipFile(apk) + val entries = zip.entries() + + while (entries.hasMoreElements()) { + val entry = entries.nextElement() + + if (entry.name.endsWith("$abi/index.so")) { + zip.close() + nativesApkN = ZipFile(apk) + break + } + if (entry.name.endsWith("$abi/libflutter.so")) { + useUncompressedLibs = true + break + } + } + + zip.close() + } + + if (useUncompressedLibs) { + return; + } + + if (nativesApkN == null) { + throw Exception("Can't find native libraries") + } + val nativesApk: ZipFile = nativesApkN + + val compressedLibsIndex = nativesApk.getInputStream( + nativesApk.getEntry("lib/$abi/index.so") + ) + val compressedLibs = JSONObject(compressedLibsIndex.readBytes().toString(Charsets.UTF_8)) + + for (so in compressedLibs.keys()) { + val soFile = File(cacheDir, so) + + if (soFile.sha256() == compressedLibs.getString(so)) { + System.load(soFile.absolutePath) + return + } + + Log.d("AppMain", "Decompressing: $so") + val brInput = nativesApk.getInputStream( + nativesApk.getEntry("lib/$abi/${so.replace(".so", "-br.so")}") + ) + val soOutput = FileOutputStream(soFile) + + val brIn = BrotliInputStream(brInput) + brIn.copyTo(soOutput) + + brInput.close() + soOutput.close() + + System.load(soFile.absolutePath) + } + } + } \ No newline at end of file diff --git a/firka/android/app/src/main/kotlin/app/firka/naplo/Extensions.kt b/firka/android/app/src/main/kotlin/app/firka/naplo/Extensions.kt index 931bf226..bb63a60f 100644 --- a/firka/android/app/src/main/kotlin/app/firka/naplo/Extensions.kt +++ b/firka/android/app/src/main/kotlin/app/firka/naplo/Extensions.kt @@ -1,66 +1,66 @@ -package app.firka.naplo - -import app.firka.naplo.model.NameUid -import app.firka.naplo.model.NameUidDesc -import app.firka.naplo.model.Subject -import org.json.JSONObject - -fun JSONObject.getStringOrNull(key: String): String? { - return try { - if (has(key)) { - getString(key) - } else { - null - } - } catch (_: Exception) { - null - } -} - -fun JSONObject.getIntOrNull(key: String): Int? { - return try { - if (has(key)) { - getInt(key) - } else { - null - } - } catch (_: Exception) { - null - } -} - -fun JSONObject.getNameUidDescOrNull(key: String): NameUidDesc? { - try { - return if (has(key)) { - NameUidDesc(getJSONObject(key)) - } else { - null - } - } catch (_: Exception) { - return null - } -} - -fun JSONObject.getNameUidOrNull(key: String): NameUid? { - try { - return if (has(key)) { - NameUid(getJSONObject(key)) - } else { - null - } - } catch (_: Exception) { - return null - } -} - -fun JSONObject.getSubjectOrNull(key: String): Subject? { - return try { - if (has(key)) { - Subject(getJSONObject(key)) - } else { - null - } - } catch (_: Exception) { - null - } +package app.firka.naplo + +import app.firka.naplo.model.NameUid +import app.firka.naplo.model.NameUidDesc +import app.firka.naplo.model.Subject +import org.json.JSONObject + +fun JSONObject.getStringOrNull(key: String): String? { + return try { + if (has(key)) { + getString(key) + } else { + null + } + } catch (_: Exception) { + null + } +} + +fun JSONObject.getIntOrNull(key: String): Int? { + return try { + if (has(key)) { + getInt(key) + } else { + null + } + } catch (_: Exception) { + null + } +} + +fun JSONObject.getNameUidDescOrNull(key: String): NameUidDesc? { + try { + return if (has(key)) { + NameUidDesc(getJSONObject(key)) + } else { + null + } + } catch (_: Exception) { + return null + } +} + +fun JSONObject.getNameUidOrNull(key: String): NameUid? { + try { + return if (has(key)) { + NameUid(getJSONObject(key)) + } else { + null + } + } catch (_: Exception) { + return null + } +} + +fun JSONObject.getSubjectOrNull(key: String): Subject? { + return try { + if (has(key)) { + Subject(getJSONObject(key)) + } else { + null + } + } catch (_: Exception) { + null + } } \ No newline at end of file diff --git a/firka/android/app/src/main/kotlin/app/firka/naplo/glance/LessonCard.kt b/firka/android/app/src/main/kotlin/app/firka/naplo/glance/LessonCard.kt index 0900bdea..3f845cdd 100644 --- a/firka/android/app/src/main/kotlin/app/firka/naplo/glance/LessonCard.kt +++ b/firka/android/app/src/main/kotlin/app/firka/naplo/glance/LessonCard.kt @@ -1,111 +1,111 @@ -package app.firka.naplo.glance - -import androidx.compose.runtime.Composable -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import androidx.glance.GlanceModifier -import androidx.glance.appwidget.cornerRadius -import androidx.glance.background -import androidx.glance.color.ColorProvider -import androidx.glance.layout.Alignment -import androidx.glance.layout.Box -import androidx.glance.layout.Row -import androidx.glance.layout.Spacer -import androidx.glance.layout.fillMaxWidth -import androidx.glance.layout.padding -import androidx.glance.layout.width -import androidx.glance.text.FontWeight -import androidx.glance.text.Text -import androidx.glance.text.TextStyle -import app.firka.naplo.model.Colors -import app.firka.naplo.model.Lesson -import java.time.format.DateTimeFormatterBuilder - -val hhmm = DateTimeFormatterBuilder() - .appendPattern("HH:mm") - .toFormatter() - -@Composable -fun LessonCard(lesson: Lesson, colors: Colors, - modifier: GlanceModifier = GlanceModifier) { - Box(modifier = - modifier - .fillMaxWidth() - .padding(4.dp, 0.dp) - .cornerRadius(16.dp) - .background(colors.card) - ) { - var bgColor = colors.a15p - var fgColor = colors.textSecondary - - if (lesson.substituteTeacher == null) { - bgColor = colors.warning15p - fgColor = colors.warningText - } - - - Box(modifier = GlanceModifier.padding(12.dp)) { - Row { - Row(modifier = GlanceModifier.width(226.dp), verticalAlignment = Alignment.CenterVertically) { - if (lesson.lessonNumber != null) { - Box(modifier = GlanceModifier.cornerRadius(16.dp).background(bgColor)) { - Text( - lesson.lessonNumber.toString(), - style = TextStyle( - color = ColorProvider(fgColor, fgColor), - fontSize = 14.sp, - fontWeight = FontWeight.Bold - ), - modifier = GlanceModifier.padding(8.dp, 4.dp), - ) - } - Spacer(modifier = GlanceModifier.width(4.dp)) - } - // TODO: Add subject icons - Text( - lesson.name, - style = TextStyle( - color = ColorProvider(colors.textPrimary, colors.textPrimary), - fontSize = 14.sp, - fontWeight = FontWeight.Bold - ), - ) - } - - // Spacer(modifier = GlanceModifier.width(10.dp)) - - Row(verticalAlignment = Alignment.CenterVertically) { - Text( - lesson.start.format(hhmm), - style = TextStyle( - color = ColorProvider(colors.textPrimary, colors.textPrimary), - fontSize = 14.sp, - fontWeight = FontWeight.Bold - ), - ) - Spacer(modifier = GlanceModifier.width(8.dp)) - Box(modifier = GlanceModifier.cornerRadius(16.dp).background(colors.a15p)) { - var roomName = "N/A"; - if (lesson.roomName != null) { - roomName = lesson.roomName!!; - } - - if (roomName.length < 2) { - roomName = " $roomName" - } - - Text( - roomName, - style = TextStyle( - color = ColorProvider(colors.textSecondary, colors.textSecondary), - fontSize = 14.sp, - fontWeight = FontWeight.Bold - ), - modifier = GlanceModifier.padding(8.dp, 4.dp), - ) - } - } - } - } - } +package app.firka.naplo.glance + +import androidx.compose.runtime.Composable +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.glance.GlanceModifier +import androidx.glance.appwidget.cornerRadius +import androidx.glance.background +import androidx.glance.color.ColorProvider +import androidx.glance.layout.Alignment +import androidx.glance.layout.Box +import androidx.glance.layout.Row +import androidx.glance.layout.Spacer +import androidx.glance.layout.fillMaxWidth +import androidx.glance.layout.padding +import androidx.glance.layout.width +import androidx.glance.text.FontWeight +import androidx.glance.text.Text +import androidx.glance.text.TextStyle +import app.firka.naplo.model.Colors +import app.firka.naplo.model.Lesson +import java.time.format.DateTimeFormatterBuilder + +val hhmm = DateTimeFormatterBuilder() + .appendPattern("HH:mm") + .toFormatter() + +@Composable +fun LessonCard(lesson: Lesson, colors: Colors, + modifier: GlanceModifier = GlanceModifier) { + Box(modifier = + modifier + .fillMaxWidth() + .padding(4.dp, 0.dp) + .cornerRadius(16.dp) + .background(colors.card) + ) { + var bgColor = colors.a15p + var fgColor = colors.textSecondary + + if (lesson.substituteTeacher == null) { + bgColor = colors.warning15p + fgColor = colors.warningText + } + + + Box(modifier = GlanceModifier.padding(12.dp)) { + Row { + Row(modifier = GlanceModifier.width(226.dp), verticalAlignment = Alignment.CenterVertically) { + if (lesson.lessonNumber != null) { + Box(modifier = GlanceModifier.cornerRadius(16.dp).background(bgColor)) { + Text( + lesson.lessonNumber.toString(), + style = TextStyle( + color = ColorProvider(fgColor, fgColor), + fontSize = 14.sp, + fontWeight = FontWeight.Bold + ), + modifier = GlanceModifier.padding(8.dp, 4.dp), + ) + } + Spacer(modifier = GlanceModifier.width(4.dp)) + } + // TODO: Add subject icons + Text( + lesson.name, + style = TextStyle( + color = ColorProvider(colors.textPrimary, colors.textPrimary), + fontSize = 14.sp, + fontWeight = FontWeight.Bold + ), + ) + } + + // Spacer(modifier = GlanceModifier.width(10.dp)) + + Row(verticalAlignment = Alignment.CenterVertically) { + Text( + lesson.start.format(hhmm), + style = TextStyle( + color = ColorProvider(colors.textPrimary, colors.textPrimary), + fontSize = 14.sp, + fontWeight = FontWeight.Bold + ), + ) + Spacer(modifier = GlanceModifier.width(8.dp)) + Box(modifier = GlanceModifier.cornerRadius(16.dp).background(colors.a15p)) { + var roomName = "N/A"; + if (lesson.roomName != null) { + roomName = lesson.roomName!!; + } + + if (roomName.length < 2) { + roomName = " $roomName" + } + + Text( + roomName, + style = TextStyle( + color = ColorProvider(colors.textSecondary, colors.textSecondary), + fontSize = 14.sp, + fontWeight = FontWeight.Bold + ), + modifier = GlanceModifier.padding(8.dp, 4.dp), + ) + } + } + } + } + } } \ No newline at end of file diff --git a/firka/android/app/src/main/kotlin/app/firka/naplo/glance/TimetableWidget.kt b/firka/android/app/src/main/kotlin/app/firka/naplo/glance/TimetableWidget.kt index 53dc7055..6f68f1c7 100644 --- a/firka/android/app/src/main/kotlin/app/firka/naplo/glance/TimetableWidget.kt +++ b/firka/android/app/src/main/kotlin/app/firka/naplo/glance/TimetableWidget.kt @@ -1,111 +1,111 @@ -package app.firka.naplo.glance - -import HomeWidgetGlanceState -import HomeWidgetGlanceStateDefinition -import android.content.Context -import androidx.compose.runtime.Composable -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import androidx.glance.GlanceId -import androidx.glance.GlanceModifier -import androidx.glance.appwidget.GlanceAppWidget -import androidx.glance.appwidget.provideContent -import androidx.glance.background -import androidx.glance.color.ColorProvider -import androidx.glance.currentState -import androidx.glance.layout.Alignment -import androidx.glance.layout.Box -import androidx.glance.layout.Column -import androidx.glance.layout.Spacer -import androidx.glance.layout.fillMaxSize -import androidx.glance.layout.height -import androidx.glance.layout.padding -import androidx.glance.state.GlanceStateDefinition -import androidx.glance.text.FontWeight -import androidx.glance.text.Text -import androidx.glance.text.TextStyle -import app.firka.naplo.model.Colors -import app.firka.naplo.model.Lesson -import org.json.JSONObject -import java.io.File -import java.time.LocalDate -import java.time.LocalDateTime - -class TimetableWidget : GlanceAppWidget() { - - override val stateDefinition: GlanceStateDefinition<*>? - get() = HomeWidgetGlanceStateDefinition() - - override suspend fun provideGlance(context: Context, id: GlanceId) { - provideContent { - GlanceContent(context, currentState()) - } - } - - @Composable - private fun GlanceContent(context: Context, currentState: HomeWidgetGlanceState) { - val appFlutter = File(context.applicationContext.dataDir, "app_flutter") - val widgetStateFile = File(appFlutter, "widget_state.json") - - if (!widgetStateFile.exists()) { - Box(modifier = - GlanceModifier - .background(Color(0xFFFAFFF0)) - .padding(16.dp) - .fillMaxSize(), - contentAlignment = Alignment.Center, - ) { - Text( - "Widget használata előtt jelentkezz be", - style = TextStyle( - color = ColorProvider(Color(0xFF394C0A), Color(0xFF394C0A)), - fontSize = 12.sp, - fontWeight = FontWeight.Medium - ) - ) - } - - return - } - - val widgetState = JSONObject(widgetStateFile.readText(Charsets.UTF_8)) - val colors = Colors(widgetState) - - val tt = widgetState.getJSONArray("timetable") - var lessons = mutableListOf() - - for (i in 0.. lesson.start.isAfter(start) && lesson.end.isBefore(end) }.toMutableList() - - Box(modifier = - GlanceModifier - .background(colors.background) - .padding(16.dp) - .fillMaxSize() - ) { - Column { - Text( - "Mai órarend", - style = TextStyle( - color = ColorProvider(colors.textSecondary, colors.textSecondary), - fontSize = 12.sp, - fontWeight = FontWeight.Medium - ) - ) - Spacer(modifier = GlanceModifier.height(4.dp)) - for (lesson in lessons) { - LessonCard(lesson, colors) - Spacer(modifier = GlanceModifier.height(4.dp)) - } - } - } - } - +package app.firka.naplo.glance + +import HomeWidgetGlanceState +import HomeWidgetGlanceStateDefinition +import android.content.Context +import androidx.compose.runtime.Composable +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.glance.GlanceId +import androidx.glance.GlanceModifier +import androidx.glance.appwidget.GlanceAppWidget +import androidx.glance.appwidget.provideContent +import androidx.glance.background +import androidx.glance.color.ColorProvider +import androidx.glance.currentState +import androidx.glance.layout.Alignment +import androidx.glance.layout.Box +import androidx.glance.layout.Column +import androidx.glance.layout.Spacer +import androidx.glance.layout.fillMaxSize +import androidx.glance.layout.height +import androidx.glance.layout.padding +import androidx.glance.state.GlanceStateDefinition +import androidx.glance.text.FontWeight +import androidx.glance.text.Text +import androidx.glance.text.TextStyle +import app.firka.naplo.model.Colors +import app.firka.naplo.model.Lesson +import org.json.JSONObject +import java.io.File +import java.time.LocalDate +import java.time.LocalDateTime + +class TimetableWidget : GlanceAppWidget() { + + override val stateDefinition: GlanceStateDefinition<*>? + get() = HomeWidgetGlanceStateDefinition() + + override suspend fun provideGlance(context: Context, id: GlanceId) { + provideContent { + GlanceContent(context, currentState()) + } + } + + @Composable + private fun GlanceContent(context: Context, currentState: HomeWidgetGlanceState) { + val appFlutter = File(context.applicationContext.dataDir, "app_flutter") + val widgetStateFile = File(appFlutter, "widget_state.json") + + if (!widgetStateFile.exists()) { + Box(modifier = + GlanceModifier + .background(Color(0xFFFAFFF0)) + .padding(16.dp) + .fillMaxSize(), + contentAlignment = Alignment.Center, + ) { + Text( + "Widget használata előtt jelentkezz be", + style = TextStyle( + color = ColorProvider(Color(0xFF394C0A), Color(0xFF394C0A)), + fontSize = 12.sp, + fontWeight = FontWeight.Medium + ) + ) + } + + return + } + + val widgetState = JSONObject(widgetStateFile.readText(Charsets.UTF_8)) + val colors = Colors(widgetState) + + val tt = widgetState.getJSONArray("timetable") + var lessons = mutableListOf() + + for (i in 0.. lesson.start.isAfter(start) && lesson.end.isBefore(end) }.toMutableList() + + Box(modifier = + GlanceModifier + .background(colors.background) + .padding(16.dp) + .fillMaxSize() + ) { + Column { + Text( + "Mai órarend", + style = TextStyle( + color = ColorProvider(colors.textSecondary, colors.textSecondary), + fontSize = 12.sp, + fontWeight = FontWeight.Medium + ) + ) + Spacer(modifier = GlanceModifier.height(4.dp)) + for (lesson in lessons) { + LessonCard(lesson, colors) + Spacer(modifier = GlanceModifier.height(4.dp)) + } + } + } + } + } \ No newline at end of file diff --git a/firka/android/app/src/main/kotlin/app/firka/naplo/glance/TimetableWidgetReceiver.kt b/firka/android/app/src/main/kotlin/app/firka/naplo/glance/TimetableWidgetReceiver.kt index 3f300eec..79d272e6 100644 --- a/firka/android/app/src/main/kotlin/app/firka/naplo/glance/TimetableWidgetReceiver.kt +++ b/firka/android/app/src/main/kotlin/app/firka/naplo/glance/TimetableWidgetReceiver.kt @@ -1,7 +1,7 @@ -package app.firka.naplo.glance - -import HomeWidgetGlanceWidgetReceiver - -class TimetableWidgetReceiver : HomeWidgetGlanceWidgetReceiver() { - override val glanceAppWidget = TimetableWidget() +package app.firka.naplo.glance + +import HomeWidgetGlanceWidgetReceiver + +class TimetableWidgetReceiver : HomeWidgetGlanceWidgetReceiver() { + override val glanceAppWidget = TimetableWidget() } \ No newline at end of file diff --git a/firka/android/app/src/main/kotlin/app/firka/naplo/model/Colors.kt b/firka/android/app/src/main/kotlin/app/firka/naplo/model/Colors.kt index 556a0aa0..cd4cddf0 100644 --- a/firka/android/app/src/main/kotlin/app/firka/naplo/model/Colors.kt +++ b/firka/android/app/src/main/kotlin/app/firka/naplo/model/Colors.kt @@ -1,37 +1,37 @@ -package app.firka.naplo.model - -import androidx.compose.ui.graphics.Color -import org.json.JSONObject - -class Colors(widgetState: JSONObject) { - var background: Color = Color(widgetState.getJSONObject("colors").getInt("background")) - var backgroundAmoled: Color = - Color(widgetState.getJSONObject("colors").getInt("backgroundAmoled")) - var background0p: Color = Color(widgetState.getJSONObject("colors").getInt("background0p")) - var success: Color = Color(widgetState.getJSONObject("colors").getInt("success")) - var textPrimary: Color = Color(widgetState.getJSONObject("colors").getInt("textPrimary")) - var textSecondary: Color = Color(widgetState.getJSONObject("colors").getInt("textSecondary")) - var textTertiary: Color = Color(widgetState.getJSONObject("colors").getInt("textTertiary")) - var card: Color = Color(widgetState.getJSONObject("colors").getInt("card")) - var cardTranslucent: Color = - Color(widgetState.getJSONObject("colors").getInt("cardTranslucent")) - var buttonSecondaryFill: Color = - Color(widgetState.getJSONObject("colors").getInt("buttonSecondaryFill")) - var accent: Color = Color(widgetState.getJSONObject("colors").getInt("accent")) - var secondary: Color = Color(widgetState.getJSONObject("colors").getInt("secondary")) - var shadowColor: Color = Color(widgetState.getJSONObject("colors").getInt("shadowColor")) - var a15p: Color = Color(widgetState.getJSONObject("colors").getInt("a15p")) - var warningAccent: Color = Color(widgetState.getJSONObject("colors").getInt("warningAccent")) - var warningText: Color = Color(widgetState.getJSONObject("colors").getInt("warningText")) - var warning15p: Color = Color(widgetState.getJSONObject("colors").getInt("warning15p")) - var warningCard: Color = Color(widgetState.getJSONObject("colors").getInt("warningCard")) - var errorAccent: Color = Color(widgetState.getJSONObject("colors").getInt("errorAccent")) - var errorText: Color = Color(widgetState.getJSONObject("colors").getInt("errorText")) - var error15p: Color = Color(widgetState.getJSONObject("colors").getInt("error15p")) - var errorCard: Color = Color(widgetState.getJSONObject("colors").getInt("errorCard")) - var grade5: Color = Color(widgetState.getJSONObject("colors").getInt("grade5")) - var grade4: Color = Color(widgetState.getJSONObject("colors").getInt("grade4")) - var grade3: Color = Color(widgetState.getJSONObject("colors").getInt("grade3")) - var grade2: Color = Color(widgetState.getJSONObject("colors").getInt("grade2")) - var grade1: Color = Color(widgetState.getJSONObject("colors").getInt("grade1")) +package app.firka.naplo.model + +import androidx.compose.ui.graphics.Color +import org.json.JSONObject + +class Colors(widgetState: JSONObject) { + var background: Color = Color(widgetState.getJSONObject("colors").getInt("background")) + var backgroundAmoled: Color = + Color(widgetState.getJSONObject("colors").getInt("backgroundAmoled")) + var background0p: Color = Color(widgetState.getJSONObject("colors").getInt("background0p")) + var success: Color = Color(widgetState.getJSONObject("colors").getInt("success")) + var textPrimary: Color = Color(widgetState.getJSONObject("colors").getInt("textPrimary")) + var textSecondary: Color = Color(widgetState.getJSONObject("colors").getInt("textSecondary")) + var textTertiary: Color = Color(widgetState.getJSONObject("colors").getInt("textTertiary")) + var card: Color = Color(widgetState.getJSONObject("colors").getInt("card")) + var cardTranslucent: Color = + Color(widgetState.getJSONObject("colors").getInt("cardTranslucent")) + var buttonSecondaryFill: Color = + Color(widgetState.getJSONObject("colors").getInt("buttonSecondaryFill")) + var accent: Color = Color(widgetState.getJSONObject("colors").getInt("accent")) + var secondary: Color = Color(widgetState.getJSONObject("colors").getInt("secondary")) + var shadowColor: Color = Color(widgetState.getJSONObject("colors").getInt("shadowColor")) + var a15p: Color = Color(widgetState.getJSONObject("colors").getInt("a15p")) + var warningAccent: Color = Color(widgetState.getJSONObject("colors").getInt("warningAccent")) + var warningText: Color = Color(widgetState.getJSONObject("colors").getInt("warningText")) + var warning15p: Color = Color(widgetState.getJSONObject("colors").getInt("warning15p")) + var warningCard: Color = Color(widgetState.getJSONObject("colors").getInt("warningCard")) + var errorAccent: Color = Color(widgetState.getJSONObject("colors").getInt("errorAccent")) + var errorText: Color = Color(widgetState.getJSONObject("colors").getInt("errorText")) + var error15p: Color = Color(widgetState.getJSONObject("colors").getInt("error15p")) + var errorCard: Color = Color(widgetState.getJSONObject("colors").getInt("errorCard")) + var grade5: Color = Color(widgetState.getJSONObject("colors").getInt("grade5")) + var grade4: Color = Color(widgetState.getJSONObject("colors").getInt("grade4")) + var grade3: Color = Color(widgetState.getJSONObject("colors").getInt("grade3")) + var grade2: Color = Color(widgetState.getJSONObject("colors").getInt("grade2")) + var grade1: Color = Color(widgetState.getJSONObject("colors").getInt("grade1")) } \ No newline at end of file diff --git a/firka/android/app/src/main/kotlin/app/firka/naplo/model/Lesson.kt b/firka/android/app/src/main/kotlin/app/firka/naplo/model/Lesson.kt index 55274a98..20967938 100644 --- a/firka/android/app/src/main/kotlin/app/firka/naplo/model/Lesson.kt +++ b/firka/android/app/src/main/kotlin/app/firka/naplo/model/Lesson.kt @@ -1,94 +1,94 @@ -package app.firka.naplo.model - -import app.firka.naplo.getIntOrNull -import app.firka.naplo.getNameUidDescOrNull -import app.firka.naplo.getNameUidOrNull -import app.firka.naplo.getStringOrNull -import app.firka.naplo.getSubjectOrNull -import org.json.JSONObject -import java.time.LocalDateTime -import java.time.format.DateTimeFormatterBuilder - -class Lesson { - val formatter = DateTimeFormatterBuilder() - .appendPattern("yyyy-MM-dd'T'HH:mm:ss.SSS") - .optionalStart() - .appendLiteral('Z') - .optionalEnd() - .toFormatter() - - constructor(data: JSONObject) { - uid = data.getString("Uid") - date = data.getString("Datum") - start = LocalDateTime.parse(data.getString("KezdetIdopont"), formatter) - end = LocalDateTime.parse(data.getString("VegIdopont"), formatter) - name = data.getString("Nev") - lessonNumber = data.getIntOrNull("Oraszam") - lessonSeqNumber = data.getIntOrNull("OraEvesSorszama") - classGroup = data.getNameUidOrNull("OsztalyCsoport") - teacher = data.getStringOrNull("TanarNeve") - subject = data.getSubjectOrNull("Tantargy") - theme = data.getStringOrNull("Tema") - roomName = data.getStringOrNull("TeremNeve") - type = NameUidDesc(data.getJSONObject("Tipus")) - studentPresence = data.getNameUidDescOrNull("TanuloJelenlet") - state = NameUidDesc(data.getJSONObject("Allapot")) - substituteTeacher = data.getStringOrNull("HelyettesTanarNeve") - homeworkUid = data.getStringOrNull("HaziFeladatUid") - taskGroupUid = data.getStringOrNull("FeladatGroupUid") - languageTaskGroupUid = data.getStringOrNull("NyelviFeladatGroupUid") - assessmentUid = data.getStringOrNull("BejelentettSzamonkeresUid") - canStudentEditHomework = data.getBoolean("IsTanuloHaziFeladatEnabled") - isHomeworkComplete = data.getBoolean("IsHaziFeladatMegoldva") - if (data.has("Csatolmanyok")) { - val rawAttachments = data.getJSONArray("Csatolmanyok") - - for (i in 0..() - var isDigitalLesson: Boolean - var digitalDeviceList: String? - var digitalPlatformType: String? - var digitalSupportDeviceTypeList = mutableListOf() - var createdAt: LocalDateTime - var lastModifiedAt: LocalDateTime +package app.firka.naplo.model + +import app.firka.naplo.getIntOrNull +import app.firka.naplo.getNameUidDescOrNull +import app.firka.naplo.getNameUidOrNull +import app.firka.naplo.getStringOrNull +import app.firka.naplo.getSubjectOrNull +import org.json.JSONObject +import java.time.LocalDateTime +import java.time.format.DateTimeFormatterBuilder + +class Lesson { + val formatter = DateTimeFormatterBuilder() + .appendPattern("yyyy-MM-dd'T'HH:mm:ss.SSS") + .optionalStart() + .appendLiteral('Z') + .optionalEnd() + .toFormatter() + + constructor(data: JSONObject) { + uid = data.getString("Uid") + date = data.getString("Datum") + start = LocalDateTime.parse(data.getString("KezdetIdopont"), formatter) + end = LocalDateTime.parse(data.getString("VegIdopont"), formatter) + name = data.getString("Nev") + lessonNumber = data.getIntOrNull("Oraszam") + lessonSeqNumber = data.getIntOrNull("OraEvesSorszama") + classGroup = data.getNameUidOrNull("OsztalyCsoport") + teacher = data.getStringOrNull("TanarNeve") + subject = data.getSubjectOrNull("Tantargy") + theme = data.getStringOrNull("Tema") + roomName = data.getStringOrNull("TeremNeve") + type = NameUidDesc(data.getJSONObject("Tipus")) + studentPresence = data.getNameUidDescOrNull("TanuloJelenlet") + state = NameUidDesc(data.getJSONObject("Allapot")) + substituteTeacher = data.getStringOrNull("HelyettesTanarNeve") + homeworkUid = data.getStringOrNull("HaziFeladatUid") + taskGroupUid = data.getStringOrNull("FeladatGroupUid") + languageTaskGroupUid = data.getStringOrNull("NyelviFeladatGroupUid") + assessmentUid = data.getStringOrNull("BejelentettSzamonkeresUid") + canStudentEditHomework = data.getBoolean("IsTanuloHaziFeladatEnabled") + isHomeworkComplete = data.getBoolean("IsHaziFeladatMegoldva") + if (data.has("Csatolmanyok")) { + val rawAttachments = data.getJSONArray("Csatolmanyok") + + for (i in 0..() + var isDigitalLesson: Boolean + var digitalDeviceList: String? + var digitalPlatformType: String? + var digitalSupportDeviceTypeList = mutableListOf() + var createdAt: LocalDateTime + var lastModifiedAt: LocalDateTime } \ No newline at end of file diff --git a/firka/android/app/src/main/kotlin/app/firka/naplo/model/NameUid.kt b/firka/android/app/src/main/kotlin/app/firka/naplo/model/NameUid.kt index 48e076ee..5e22c88e 100644 --- a/firka/android/app/src/main/kotlin/app/firka/naplo/model/NameUid.kt +++ b/firka/android/app/src/main/kotlin/app/firka/naplo/model/NameUid.kt @@ -1,9 +1,9 @@ -package app.firka.naplo.model - -import app.firka.naplo.getStringOrNull -import org.json.JSONObject - -class NameUid(data: JSONObject) { - var uid: String = data.getString("Uid") - var name: String? = data.getStringOrNull("Nev") -} +package app.firka.naplo.model + +import app.firka.naplo.getStringOrNull +import org.json.JSONObject + +class NameUid(data: JSONObject) { + var uid: String = data.getString("Uid") + var name: String? = data.getStringOrNull("Nev") +} diff --git a/firka/android/app/src/main/kotlin/app/firka/naplo/model/NameUidDesc.kt b/firka/android/app/src/main/kotlin/app/firka/naplo/model/NameUidDesc.kt index cab69c3a..2a7a14e2 100644 --- a/firka/android/app/src/main/kotlin/app/firka/naplo/model/NameUidDesc.kt +++ b/firka/android/app/src/main/kotlin/app/firka/naplo/model/NameUidDesc.kt @@ -1,10 +1,10 @@ -package app.firka.naplo.model - -import app.firka.naplo.getStringOrNull -import org.json.JSONObject - -class NameUidDesc(data: JSONObject) { - var uid: String = data.getString("Uid") - var name: String? = data.getStringOrNull("Nev") - var description: String? = data.getStringOrNull("Leiras") -} +package app.firka.naplo.model + +import app.firka.naplo.getStringOrNull +import org.json.JSONObject + +class NameUidDesc(data: JSONObject) { + var uid: String = data.getString("Uid") + var name: String? = data.getStringOrNull("Nev") + var description: String? = data.getStringOrNull("Leiras") +} diff --git a/firka/android/app/src/main/kotlin/app/firka/naplo/model/Subject.kt b/firka/android/app/src/main/kotlin/app/firka/naplo/model/Subject.kt index b56609b6..4f92bf72 100644 --- a/firka/android/app/src/main/kotlin/app/firka/naplo/model/Subject.kt +++ b/firka/android/app/src/main/kotlin/app/firka/naplo/model/Subject.kt @@ -1,12 +1,12 @@ -package app.firka.naplo.model - -import app.firka.naplo.getNameUidDescOrNull -import app.firka.naplo.getStringOrNull -import org.json.JSONObject - -class Subject(data: JSONObject) { - var uid: String? = data.getStringOrNull("Uid") - var name: String? = data.getStringOrNull("Nev") - var category: NameUidDesc? = data.getNameUidDescOrNull("Kategoria") - var sortIndex: Int = data.getInt("SortIndex") +package app.firka.naplo.model + +import app.firka.naplo.getNameUidDescOrNull +import app.firka.naplo.getStringOrNull +import org.json.JSONObject + +class Subject(data: JSONObject) { + var uid: String? = data.getStringOrNull("Uid") + var name: String? = data.getStringOrNull("Nev") + var category: NameUidDesc? = data.getNameUidDescOrNull("Kategoria") + var sortIndex: Int = data.getInt("SortIndex") } \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_ace.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_ace.xml index 9f2eff71..95fe1619 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_ace.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_ace.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_ace_f.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_ace_f.xml index 97af3184..b625ade0 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_ace_f.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_ace_f.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_ace_f_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_ace_f_round.xml index 97af3184..b625ade0 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_ace_f_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_ace_f_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_ace_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_ace_round.xml index 9f2eff71..95fe1619 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_ace_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_ace_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_bi.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_bi.xml index 38aa50f4..56b15c32 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_bi.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_bi.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_bi_f.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_bi_f.xml index 3a9fbb09..11176f9d 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_bi_f.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_bi_f.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_bi_f_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_bi_f_round.xml index 3a9fbb09..11176f9d 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_bi_f_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_bi_f_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_bi_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_bi_round.xml index 38aa50f4..56b15c32 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_bi_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_bi_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_cactus.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_cactus.xml index f5ea7966..b4a15a49 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_cactus.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_cactus.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_cactus_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_cactus_round.xml index f5ea7966..b4a15a49 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_cactus_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_cactus_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_cc.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_cc.xml index 49f840f0..aff72c17 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_cc.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_cc.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_cc_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_cc_round.xml index 49f840f0..aff72c17 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_cc_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_cc_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_enby.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_enby.xml index 60ded5c8..119e983e 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_enby.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_enby.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_enby_f.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_enby_f.xml index 97f38af6..393a31c5 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_enby_f.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_enby_f.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_enby_f_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_enby_f_round.xml index 97f38af6..393a31c5 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_enby_f_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_enby_f_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_enby_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_enby_round.xml index 60ded5c8..119e983e 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_enby_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_enby_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_fidesz.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_fidesz.xml index cd04ebf4..5164f704 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_fidesz.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_fidesz.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_fidesz_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_fidesz_round.xml index cd04ebf4..5164f704 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_fidesz_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_fidesz_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_filc.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_filc.xml index 47c7536b..6abf483c 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_filc.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_filc.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_filc_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_filc_round.xml index 47c7536b..6abf483c 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_filc_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_filc_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_filco.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_filco.xml index d5b4baba..8dfbe04c 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_filco.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_filco.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_filco_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_filco_round.xml index d5b4baba..8dfbe04c 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_filco_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_filco_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_galaxy.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_galaxy.xml index baae35fb..e9374293 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_galaxy.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_galaxy.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_galaxy_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_galaxy_round.xml index baae35fb..e9374293 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_galaxy_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_galaxy_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_gay.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_gay.xml index f2fe74be..5c434980 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_gay.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_gay.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_gay_f.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_gay_f.xml index eb9f886a..1bd24e39 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_gay_f.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_gay_f.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_gay_f_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_gay_f_round.xml index eb9f886a..1bd24e39 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_gay_f_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_gay_f_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_gay_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_gay_round.xml index f2fe74be..5c434980 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_gay_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_gay_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_kreta.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_kreta.xml index 052fe0c0..8b10f787 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_kreta.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_kreta.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_kreta_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_kreta_round.xml index 052fe0c0..8b10f787 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_kreta_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_kreta_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lesb.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lesb.xml index 252be418..fb81a0c6 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lesb.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lesb.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lesb_f.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lesb_f.xml index 296011a0..ab124959 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lesb_f.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lesb_f.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lesb_f_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lesb_f_round.xml index 296011a0..ab124959 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lesb_f_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lesb_f_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lesb_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lesb_round.xml index 252be418..fb81a0c6 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lesb_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lesb_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtq.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtq.xml index 21b0038c..cc566d64 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtq.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtq.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtq_f.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtq_f.xml index 3c9c462f..1b837218 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtq_f.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtq_f.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtq_f_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtq_f_round.xml index 3c9c462f..1b837218 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtq_f_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtq_f_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtq_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtq_round.xml index 21b0038c..cc566d64 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtq_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtq_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtqp.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtqp.xml index 7fb9d1ca..82df8981 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtqp.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtqp.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtqp_f.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtqp_f.xml index d18e1510..dff5ae80 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtqp_f.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtqp_f.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtqp_f_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtqp_f_round.xml index d18e1510..dff5ae80 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtqp_f_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtqp_f_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtqp_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtqp_round.xml index 7fb9d1ca..82df8981 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtqp_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_lgbtqp_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_mkkp.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_mkkp.xml index 06a46097..c988a281 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_mkkp.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_mkkp.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_mkkp_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_mkkp_round.xml index 06a46097..c988a281 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_mkkp_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_mkkp_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_modern.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_modern.xml index 66cc1961..f428867d 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_modern.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_modern.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_modern_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_modern_round.xml index 66cc1961..f428867d 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_modern_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_modern_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_o1g.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_o1g.xml index 8f136cbb..1a0ebab0 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_o1g.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_o1g.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_o1g_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_o1g_round.xml index 8f136cbb..1a0ebab0 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_o1g_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_o1g_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_paper.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_paper.xml index 700dbcc5..15a76ee7 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_paper.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_paper.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_paper_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_paper_round.xml index 700dbcc5..15a76ee7 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_paper_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_paper_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_pixel.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_pixel.xml index 7f3d5c0e..e33051ef 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_pixel.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_pixel.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_pixel_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_pixel_round.xml index 7f3d5c0e..e33051ef 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_pixel_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_pixel_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_pixelized.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_pixelized.xml index 188855ad..c45823b5 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_pixelized.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_pixelized.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_pixelized_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_pixelized_round.xml index 188855ad..c45823b5 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_pixelized_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_pixelized_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_refilc.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_refilc.xml index db346c74..c333f077 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_refilc.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_refilc.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_refilc_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_refilc_round.xml index db346c74..c333f077 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_refilc_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_refilc_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_refulc.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_refulc.xml index 683bc993..fe7aa942 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_refulc.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_refulc.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_refulc_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_refulc_round.xml index 683bc993..fe7aa942 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_refulc_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_refulc_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_repont.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_repont.xml index 8e8552ca..2e4f0da9 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_repont.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_repont.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_repont_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_repont_round.xml index 8e8552ca..2e4f0da9 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_repont_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_repont_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_trans.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_trans.xml index e86f84d0..37c0d0b4 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_trans.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_trans.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_trans_f.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_trans_f.xml index 5346cc0e..e715bd1f 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_trans_f.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_trans_f.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_trans_f_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_trans_f_round.xml index 5346cc0e..e715bd1f 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_trans_f_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_trans_f_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_trans_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_trans_round.xml index e86f84d0..37c0d0b4 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_trans_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_trans_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_void_icon.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_void_icon.xml index 40057056..dcbc5b20 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_void_icon.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_void_icon.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_void_icon_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_void_icon_round.xml index 40057056..dcbc5b20 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_void_icon_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_void_icon_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_xmas1.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_xmas1.xml index 750f984e..12755bf0 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_xmas1.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_xmas1.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_xmas1_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_xmas1_round.xml index 750f984e..12755bf0 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_xmas1_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_xmas1_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_xmas2.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_xmas2.xml index fd8437f6..7afa6bd5 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_xmas2.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_xmas2.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_xmas2_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_xmas2_round.xml index fd8437f6..7afa6bd5 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_xmas2_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_xmas2_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_xmas3.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_xmas3.xml index 1b7ad686..d2711022 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_xmas3.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_xmas3.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_xmas3_round.xml b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_xmas3_round.xml index 1b7ad686..d2711022 100644 --- a/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_xmas3_round.xml +++ b/firka/android/app/src/main/res/mipmap-anydpi-v26/ic_xmas3_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/firka/android/app/src/main/res/xml/timetable_widget.xml b/firka/android/app/src/main/res/xml/timetable_widget.xml index 9c37aa33..b86a1ad0 100644 --- a/firka/android/app/src/main/res/xml/timetable_widget.xml +++ b/firka/android/app/src/main/res/xml/timetable_widget.xml @@ -1,7 +1,7 @@ - + \ No newline at end of file diff --git a/firka/lib/helpers/cache_memory_image_provider.dart b/firka/lib/helpers/cache_memory_image_provider.dart index 52ef7d6a..323c4ebe 100644 --- a/firka/lib/helpers/cache_memory_image_provider.dart +++ b/firka/lib/helpers/cache_memory_image_provider.dart @@ -1,86 +1,86 @@ -import 'dart:ui'; -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; - -// Taken from https://gist.github.com/darmawan01/9be266df44594ea59f07032e325ffa3b -// and adapted to use assets - -final _globalImageCache = {}; - -Future precacheAsset(AssetBundle bundle, String asset) async { - if (!_globalImageCache.containsKey(asset)) { - final data = await bundle.load(asset); - _globalImageCache[asset] = data.buffer.asUint8List(); - } -} - -Future precacheAssets(AssetBundle bundle, List assets) async { - for (final asset in assets) { - await precacheAsset(bundle, asset); - } -} - -Future _cacheLoad(AssetBundle bundle, String asset) async { - if (!_globalImageCache.containsKey(asset)) { - final data = await bundle.load(asset); - _globalImageCache[asset] = data.buffer.asUint8List(); - } - - return Future.value(_globalImageCache[asset]!); -} - -class CacheMemoryImageProvider extends ImageProvider { - final AssetBundle bundle; - final String path; - Uint8List? _img; - - CacheMemoryImageProvider(this.bundle, this.path); - - @override - ImageStreamCompleter loadImage( - CacheMemoryImageProvider key, ImageDecoderCallback decode) { - return MultiFrameImageStreamCompleter( - codec: _loadAsync(decode), - scale: 1.0, - debugLabel: path, - informationCollector: () sync* { - yield ErrorDescription('Tag: $path'); - }, - ); - } - - Future _loadAsync(ImageDecoderCallback decode) async { - _img ??= await _cacheLoad(bundle, path); - - // the DefaultCacheManager() encapsulation, it get cache from local storage. - final Uint8List bytes = _img!; - - if (bytes.lengthInBytes == 0) { - // The file may become available later. - PaintingBinding.instance.imageCache.evict(this); - throw StateError('$path is empty and cannot be loaded as an image.'); - } - final buffer = await ImmutableBuffer.fromUint8List(bytes); - - return await decode(buffer); - } - - @override - Future obtainKey(ImageConfiguration configuration) { - return SynchronousFuture(this); - } - - @override - bool operator ==(Object other) { - if (other.runtimeType != runtimeType) return false; - bool res = other is CacheMemoryImageProvider && other.path == path; - return res; - } - - @override - int get hashCode => path.hashCode; - - @override - String toString() => - '${objectRuntimeType(this, 'CacheImageProvider')}("$path")'; -} +import 'dart:ui'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; + +// Taken from https://gist.github.com/darmawan01/9be266df44594ea59f07032e325ffa3b +// and adapted to use assets + +final _globalImageCache = {}; + +Future precacheAsset(AssetBundle bundle, String asset) async { + if (!_globalImageCache.containsKey(asset)) { + final data = await bundle.load(asset); + _globalImageCache[asset] = data.buffer.asUint8List(); + } +} + +Future precacheAssets(AssetBundle bundle, List assets) async { + for (final asset in assets) { + await precacheAsset(bundle, asset); + } +} + +Future _cacheLoad(AssetBundle bundle, String asset) async { + if (!_globalImageCache.containsKey(asset)) { + final data = await bundle.load(asset); + _globalImageCache[asset] = data.buffer.asUint8List(); + } + + return Future.value(_globalImageCache[asset]!); +} + +class CacheMemoryImageProvider extends ImageProvider { + final AssetBundle bundle; + final String path; + Uint8List? _img; + + CacheMemoryImageProvider(this.bundle, this.path); + + @override + ImageStreamCompleter loadImage( + CacheMemoryImageProvider key, ImageDecoderCallback decode) { + return MultiFrameImageStreamCompleter( + codec: _loadAsync(decode), + scale: 1.0, + debugLabel: path, + informationCollector: () sync* { + yield ErrorDescription('Tag: $path'); + }, + ); + } + + Future _loadAsync(ImageDecoderCallback decode) async { + _img ??= await _cacheLoad(bundle, path); + + // the DefaultCacheManager() encapsulation, it get cache from local storage. + final Uint8List bytes = _img!; + + if (bytes.lengthInBytes == 0) { + // The file may become available later. + PaintingBinding.instance.imageCache.evict(this); + throw StateError('$path is empty and cannot be loaded as an image.'); + } + final buffer = await ImmutableBuffer.fromUint8List(bytes); + + return await decode(buffer); + } + + @override + Future obtainKey(ImageConfiguration configuration) { + return SynchronousFuture(this); + } + + @override + bool operator ==(Object other) { + if (other.runtimeType != runtimeType) return false; + bool res = other is CacheMemoryImageProvider && other.path == path; + return res; + } + + @override + int get hashCode => path.hashCode; + + @override + String toString() => + '${objectRuntimeType(this, 'CacheImageProvider')}("$path")'; +} diff --git a/firka/lib/helpers/db/widget.dart b/firka/lib/helpers/db/widget.dart index eda88882..8b9e561e 100644 --- a/firka/lib/helpers/db/widget.dart +++ b/firka/lib/helpers/db/widget.dart @@ -1,71 +1,71 @@ -import 'dart:convert'; -import 'dart:io'; - -import 'package:firka/helpers/api/client/kreta_client.dart'; -import 'package:firka/helpers/api/model/timetable.dart'; -import 'package:firka/helpers/debug_helper.dart'; -import 'package:path/path.dart' as p; -import 'package:path_provider/path_provider.dart'; - -import '../../ui/model/style.dart'; - -class WidgetCacheHelper { - static Map toJson(FirkaStyle style, List timetable) { - List> timetableJson = []; - - for (var lesson in timetable) { - timetableJson.add(lesson.toJson()); - } - - return { - 'colors': { - 'background': style.colors.background.toARGB32(), - 'backgroundAmoled': style.colors.backgroundAmoled.toARGB32(), - 'background0p': style.colors.background0p.toARGB32(), - 'success': style.colors.success.toARGB32(), - 'textPrimary': style.colors.textPrimary.toARGB32(), - 'textSecondary': style.colors.textSecondary.toARGB32(), - 'textTertiary': style.colors.textTertiary.toARGB32(), - 'card': style.colors.card.toARGB32(), - 'cardTranslucent': style.colors.cardTranslucent.toARGB32(), - 'buttonSecondaryFill': style.colors.buttonSecondaryFill.toARGB32(), - 'accent': style.colors.accent.toARGB32(), - 'secondary': style.colors.secondary.toARGB32(), - 'shadowColor': style.colors.shadowColor.toARGB32(), - 'a15p': style.colors.a15p.toARGB32(), - 'warningAccent': style.colors.warningAccent.toARGB32(), - 'warningText': style.colors.warningText.toARGB32(), - 'warning15p': style.colors.warning15p.toARGB32(), - 'warningCard': style.colors.warningCard.toARGB32(), - 'errorAccent': style.colors.errorAccent.toARGB32(), - 'errorText': style.colors.errorText.toARGB32(), - 'error15p': style.colors.error15p.toARGB32(), - 'errorCard': style.colors.errorCard.toARGB32(), - 'grade5': style.colors.grade5.toARGB32(), - 'grade4': style.colors.grade4.toARGB32(), - 'grade3': style.colors.grade3.toARGB32(), - 'grade2': style.colors.grade2.toARGB32(), - 'grade1': style.colors.grade1.toARGB32(), - }, - 'timetable': timetableJson, - }; - } - - static Future updateWidgetCache( - FirkaStyle style, KretaClient client) async { - final dataDir = await getApplicationDocumentsDirectory(); - - final now = timeNow(); - - final start = now.subtract(Duration(days: 7)); - final end = now.add(Duration(days: 14)); - final lessons = await client.getTimeTable(start, end); - - final widgetFile = File(p.join(dataDir.path, "widget_state.json")); - - if (lessons.response != null) { - widgetFile.writeAsString( - jsonEncode(WidgetCacheHelper.toJson(style, lessons.response!))); - } - } -} +import 'dart:convert'; +import 'dart:io'; + +import 'package:firka/helpers/api/client/kreta_client.dart'; +import 'package:firka/helpers/api/model/timetable.dart'; +import 'package:firka/helpers/debug_helper.dart'; +import 'package:path/path.dart' as p; +import 'package:path_provider/path_provider.dart'; + +import '../../ui/model/style.dart'; + +class WidgetCacheHelper { + static Map toJson(FirkaStyle style, List timetable) { + List> timetableJson = []; + + for (var lesson in timetable) { + timetableJson.add(lesson.toJson()); + } + + return { + 'colors': { + 'background': style.colors.background.toARGB32(), + 'backgroundAmoled': style.colors.backgroundAmoled.toARGB32(), + 'background0p': style.colors.background0p.toARGB32(), + 'success': style.colors.success.toARGB32(), + 'textPrimary': style.colors.textPrimary.toARGB32(), + 'textSecondary': style.colors.textSecondary.toARGB32(), + 'textTertiary': style.colors.textTertiary.toARGB32(), + 'card': style.colors.card.toARGB32(), + 'cardTranslucent': style.colors.cardTranslucent.toARGB32(), + 'buttonSecondaryFill': style.colors.buttonSecondaryFill.toARGB32(), + 'accent': style.colors.accent.toARGB32(), + 'secondary': style.colors.secondary.toARGB32(), + 'shadowColor': style.colors.shadowColor.toARGB32(), + 'a15p': style.colors.a15p.toARGB32(), + 'warningAccent': style.colors.warningAccent.toARGB32(), + 'warningText': style.colors.warningText.toARGB32(), + 'warning15p': style.colors.warning15p.toARGB32(), + 'warningCard': style.colors.warningCard.toARGB32(), + 'errorAccent': style.colors.errorAccent.toARGB32(), + 'errorText': style.colors.errorText.toARGB32(), + 'error15p': style.colors.error15p.toARGB32(), + 'errorCard': style.colors.errorCard.toARGB32(), + 'grade5': style.colors.grade5.toARGB32(), + 'grade4': style.colors.grade4.toARGB32(), + 'grade3': style.colors.grade3.toARGB32(), + 'grade2': style.colors.grade2.toARGB32(), + 'grade1': style.colors.grade1.toARGB32(), + }, + 'timetable': timetableJson, + }; + } + + static Future updateWidgetCache( + FirkaStyle style, KretaClient client) async { + final dataDir = await getApplicationDocumentsDirectory(); + + final now = timeNow(); + + final start = now.subtract(Duration(days: 7)); + final end = now.add(Duration(days: 14)); + final lessons = await client.getTimeTable(start, end); + + final widgetFile = File(p.join(dataDir.path, "widget_state.json")); + + if (lessons.response != null) { + widgetFile.writeAsString( + jsonEncode(WidgetCacheHelper.toJson(style, lessons.response!))); + } + } +} diff --git a/firka/lib/helpers/debug_helper.dart b/firka/lib/helpers/debug_helper.dart index d0c04a0d..027d8e83 100644 --- a/firka/lib/helpers/debug_helper.dart +++ b/firka/lib/helpers/debug_helper.dart @@ -1,17 +1,17 @@ -DateTime? debugFakeTime; -DateTime? debugSetAt; -var debugTimeAdvance = false; - -DateTime timeNow() { - if (debugFakeTime != null) { - if (debugTimeAdvance && debugSetAt != null) { - var diff = DateTime.now().difference(debugSetAt!); - - return debugFakeTime!.add(diff); - } else { - return debugFakeTime!; - } - } else { - return DateTime.now(); - } -} +DateTime? debugFakeTime; +DateTime? debugSetAt; +var debugTimeAdvance = false; + +DateTime timeNow() { + if (debugFakeTime != null) { + if (debugTimeAdvance && debugSetAt != null) { + var diff = DateTime.now().difference(debugSetAt!); + + return debugFakeTime!.add(diff); + } else { + return debugFakeTime!; + } + } else { + return DateTime.now(); + } +} diff --git a/firka/lib/helpers/firka_bundle.dart b/firka/lib/helpers/firka_bundle.dart index e4151760..89e10e5c 100644 --- a/firka/lib/helpers/firka_bundle.dart +++ b/firka/lib/helpers/firka_bundle.dart @@ -1,56 +1,56 @@ -import 'dart:async'; -import 'dart:io'; -import 'dart:convert'; - -import 'package:brotli/brotli.dart'; -import 'package:flutter/foundation.dart'; -import 'package:flutter/services.dart'; - -class FirkaBundle extends CachingAssetBundle { - // final bool _compressedBundle = !kDebugMode && Platform.isAndroid; - final bool _compressedBundle = false; - - Map? index; - - Future> loadIndex() async { - var indexBrotli = await rootBundle.load("assets/firka.i"); - var indexStr = brotli.decodeToString(indexBrotli.buffer.asInt8List()); - - return Future.value(jsonDecode(indexStr)); - } - - ByteData decode(Codec, List> codec, ByteData data) { - var dec = codec.decode(data.buffer.asInt8List()); - var b = ByteData(dec.length); - var l = b.buffer.asInt8List(); - - for (var i = 0; i < dec.length; i++) { - l[i] = dec[i]; - } - - return b; - } - - @override - Future load(String key) async { - if (!_compressedBundle) { - return rootBundle.load(key); - } else { - index ??= await loadIndex(); - - final gzip = GZipCodec(); - - debugPrint("assets/flutter_assets/$key"); - switch (index!["assets/flutter_assets/$key"]!) { - case "b": // brotli - return decode(brotli, await rootBundle.load(key)); - case "g": // gzip - return decode(gzip, await rootBundle.load(key)); - case "r": // raw - return rootBundle.load(key); - default: - throw "Unknown file format: ${index![key]!}"; - } - } - } -} +import 'dart:async'; +import 'dart:io'; +import 'dart:convert'; + +import 'package:brotli/brotli.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; + +class FirkaBundle extends CachingAssetBundle { + // final bool _compressedBundle = !kDebugMode && Platform.isAndroid; + final bool _compressedBundle = false; + + Map? index; + + Future> loadIndex() async { + var indexBrotli = await rootBundle.load("assets/firka.i"); + var indexStr = brotli.decodeToString(indexBrotli.buffer.asInt8List()); + + return Future.value(jsonDecode(indexStr)); + } + + ByteData decode(Codec, List> codec, ByteData data) { + var dec = codec.decode(data.buffer.asInt8List()); + var b = ByteData(dec.length); + var l = b.buffer.asInt8List(); + + for (var i = 0; i < dec.length; i++) { + l[i] = dec[i]; + } + + return b; + } + + @override + Future load(String key) async { + if (!_compressedBundle) { + return rootBundle.load(key); + } else { + index ??= await loadIndex(); + + final gzip = GZipCodec(); + + debugPrint("assets/flutter_assets/$key"); + switch (index!["assets/flutter_assets/$key"]!) { + case "b": // brotli + return decode(brotli, await rootBundle.load(key)); + case "g": // gzip + return decode(gzip, await rootBundle.load(key)); + case "r": // raw + return rootBundle.load(key); + default: + throw "Unknown file format: ${index![key]!}"; + } + } + } +} diff --git a/firka/lib/helpers/settings/setting.dart b/firka/lib/helpers/settings/setting.dart index 623814ee..68de6ea2 100644 --- a/firka/lib/helpers/settings/setting.dart +++ b/firka/lib/helpers/settings/setting.dart @@ -1,736 +1,736 @@ -import 'dart:collection'; -import 'dart:core'; -import 'dart:io'; - -import 'package:firka/helpers/db/models/app_settings_model.dart'; -import 'package:firka/l10n/app_localizations.dart'; -import 'package:firka/ui/widget/firka_icon.dart'; -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:isar/isar.dart'; -import 'package:majesticons_flutter/majesticons_flutter.dart'; - -import '../../main.dart'; -import '../../ui/phone/screens/home/home_screen.dart'; -import '../firka_bundle.dart'; -// import 'package:restart_app/restart_app.dart'; - -const bellRing = 1001; -const rounding1 = 1002; -const rounding2 = 1003; -const rounding3 = 1004; -const rounding4 = 1005; -const classAvgOnGraph = 1006; -const leftHandedMode = 1007; -const language = 1008; -const appIcon = 1009; -const child_protection = 1010; - -bool always() { - return true; -} - -bool never() { - return false; -} - -bool isAndroid() { - return Platform.isAndroid; -} - -bool isDebug() { - return kDebugMode; -} - -class SettingsStore { - LinkedHashMap items = LinkedHashMap.of({}); - - Map appIcons = {}; - - SettingsStore(AppLocalizations l10n) { - items["settings"] = SettingsGroup( - 0, - LinkedHashMap.of({ - "settings_header": SettingsHeader(0, l10n.s_settings, always), - "settings_padding": SettingsPadding(0, 20, always), - "application": SettingsSubGroup( - 0, - FirkaIconType.majesticons, - Majesticon.settingsCogSolid, - l10n.s_a, - LinkedHashMap.of({ - // TODO: Make a back arrow widget - "settings_header": SettingsHeader(0, l10n.s_ag, always), - "settings_padding": SettingsPadding(0, 23, always), - - "bell_delay": SettingsDouble(bellRing, null, null, - l10n.s_ag_bell_delay, 0, 0, 120, 0, always), - "rounding": SettingsSubGroup( - 0, - null, - null, - l10n.s_ag_rounding, - LinkedHashMap.of({ - "1": SettingsDouble(rounding1, null, null, l10n.s_ag_r1, - 0.1, 0.5, 0.99, 2, always), - "2": SettingsDouble(rounding2, null, null, l10n.s_ag_r2, - 0.1, 0.5, 0.99, 2, always), - "3": SettingsDouble(rounding3, null, null, l10n.s_ag_r3, - 0.1, 0.5, 0.99, 2, always), - "4": SettingsDouble(rounding4, null, null, l10n.s_ag_r4, - 0.1, 0.5, 0.99, 2, always), - }), - always), - "class_avg_on_graph": SettingsBoolean(classAvgOnGraph, null, - null, l10n.s_ag_class_avg_on_graph, true, never), - "navbar": SettingsSubGroup( - 0, - null, // TODO: icon - null, - l10n.s_ag_navbar, - LinkedHashMap.of({}), - never), - "left_handed_mode": SettingsBoolean(leftHandedMode, null, null, - l10n.s_ag_left_handed_mode, false, never), - "language_header": - SettingsHeaderSmall(0, l10n.s_ag_language_header, always), - "language": SettingsItemsRadio( - language, - null, - null, - [ - l10n.s_ag_language_auto, - l10n.s_ag_language_hu, - l10n.s_ag_language_en, - l10n.s_ag_language_de - ], - 0, - always, () async { - Navigator.of(navigatorKey.currentContext!) - .popUntil((route) => false); - - initLang(initData); - initData.settings = SettingsStore(initData.l10n); - await initData.settings.load(initData.isar.appSettingsModels); - - Navigator.push( - navigatorKey.currentContext!, - MaterialPageRoute( - builder: (context) => DefaultAssetBundle( - bundle: FirkaBundle(), - child: HomeScreen( - initData, - false, - key: ValueKey('homeScreen'), - ))), - ); - }) - }), - always), - "customization": SettingsSubGroup( - 0, - FirkaIconType.majesticons, - Majesticon.flower2Solid, - l10n.s_c, - LinkedHashMap.of({ - "icon_header": - SettingsHeaderSmall(0, l10n.s_c_icon_header, always), - "icon_preview": SettingsAppIconPreview(0, always), - "icon_picker": SettingsSubGroup( - 0, - null, - null, - l10n.s_c_replace_icon, - LinkedHashMap.of({ - "icon_header": - SettingsHeader(0, l10n.s_ci_icon_header, always), - "warning_header": - SettingsHeader(0, l10n.s_ci_warning_header, isDebug), - "icon_subtitle": - SettingsSubtitle(0, l10n.s_ci_icon_subtitle, always), - "settings_padding": SettingsPadding(0, 24, always), - "icon_preview": SettingsAppIconPreview(0, always), - "settings_padding2": SettingsPadding(0, 24, always), - "child_protection": SettingsBoolean( - child_protection, - FirkaIconType.majesticons, - Majesticon.shieldSolid, - l10n.s_ci_child_protection, - true, - never), - "icon_picker": SettingsAppIconPicker( - 0, - "original", - { - l10n.s_ci_icon_g1: [ - "original", - "refilc", - "filc", - "galaxy", - "cactus", - "refulc", - "pixel" - ], - l10n.s_ci_icon_g2: [ - "modern", - "paper", - "filco", - "o1g" - ], - l10n.s_ci_icon_g3: [ - "kreta", - "cc", - "repont", - "void_icon", - "pixelized", - "fidesz", - "mkkp" - ], - l10n.s_ci_icon_g4: ["xmas1", "xmas2", "xmas3"], - l10n.s_ci_icon_g5: [ - "lgbtq", - "lgbtqp", - "trans", - "enby", - "ace", - "gay", - "lesb", - "bi" - ], - l10n.s_ci_icon_g6: [ - "lgbtq_f", - "lgbtqp_f", - "trans_f", - "enby_f", - "ace_f", - "gay_f", - "lesb_f", - "bi_f" - ] - }, - always), - }), - isAndroid), - }), - always), - "notifications": SettingsSubGroup(0, FirkaIconType.majesticons, - Majesticon.bellSolid, "Értesítések", LinkedHashMap.of({}), never), - "extras": SettingsSubGroup( - 0, - FirkaIconType.majesticons, - Majesticon.lightningBoltSolid, - "Extrák", - LinkedHashMap.of({}), - never), - "settings_other_padding": SettingsPadding(0, 20, never), - "settings_other_header": SettingsHeaderSmall(0, "Egyéb", never), - }), - always); - - appIcons = { - "ace": l10n.ic_ace, - "ace_f": l10n.ic_ace_f, - "bi": l10n.ic_bi, - "bi_f": l10n.ic_bi_f, - "cactus": l10n.ic_cactus, - "cc": l10n.ic_cc, - "enby": l10n.ic_enby, - "enby_f": l10n.ic_enby_f, - "fidesz": l10n.ic_fidesz, - "filc": l10n.ic_filc, - "filco": l10n.ic_filco, - "galaxy": l10n.ic_galaxy, - "gay": l10n.ic_gay, - "gay_f": l10n.ic_gay_f, - "kreta": l10n.ic_kreta, - "lesb": l10n.ic_lesb, - "lesb_f": l10n.ic_lesb_f, - "lgbtq": l10n.ic_lgbtq, - "lgbtq_f": l10n.ic_lgbtq_f, - "lgbtqp": l10n.ic_lgbtqp, - "lgbtqp_f": l10n.ic_lgbtqp_f, - "mkkp": l10n.ic_mkkp, - "modern": l10n.ic_modern, - "o1g": l10n.ic_o1g, - "original": l10n.ic_original, - "paper": l10n.ic_paper, - "pixel": l10n.ic_pixel, - "pixelized": l10n.ic_pixelized, - "refilc": l10n.ic_refilc, - "refulc": l10n.ic_refulc, - "repont": l10n.ic_repont, - "trans": l10n.ic_trans, - "trans_f": l10n.ic_trans_f, - "void_icon": l10n.ic_void_icon, - "xmas1": l10n.ic_xmas1, - "xmas2": l10n.ic_xmas2, - "xmas3": l10n.ic_xmas3 - }; - } - - LinkedHashMap group(String key) { - return (items[key] as SettingsGroup).children; - } - - Future save(IsarCollection model) async { - for (var item in items.values) { - await item.save(model); - } - } - - Future load(IsarCollection model) async { - for (var item in items.values) { - await item.load(model); - } - } -} - -extension SettingExt on LinkedHashMap { - LinkedHashMap group(String key) { - return (this[key] as SettingsGroup).children; - } - - LinkedHashMap subGroup(String key) { - return (this[key] as SettingsSubGroup).children; - } - - String string(String key) { - return (this[key] as SettingsString).value; - } - - void setString(String key, String value) { - (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; - } - - void setDbl(String key, double value) { - (this[key] as SettingsDouble).value = value; - } - - bool boolean(String key) { - return (this[key] as SettingsBoolean).value; - } - - void setBoolean(String key, bool value) { - (this[key] as SettingsBoolean).value = value; - } -} - -class SettingsItem { - Id key; - FirkaIconType? iconType; - Object? iconData; - bool Function() visibilityProvider; - Future Function() postUpdate = () async {}; - - SettingsItem(this.key, this.iconType, this.iconData, this.visibilityProvider); - - Future save(IsarCollection model) async {} - - Future load(IsarCollection model) async {} -} - -class SettingsGroup implements SettingsItem { - @override - Id key; - @override - FirkaIconType? iconType; - @override - Object? iconData; - @override - bool Function() visibilityProvider; - @override - Future Function() postUpdate = () async {}; - LinkedHashMap children; - - SettingsGroup(this.key, this.children, this.visibilityProvider); - - @override - Future load(IsarCollection model) async { - for (var item in children.values) { - await item.load(model); - } - } - - @override - Future save(IsarCollection model) async { - for (var item in children.values) { - await item.save(model); - } - - await postUpdate(); - } -} - -class SettingsSubGroup implements SettingsItem { - @override - Id key; - @override - FirkaIconType? iconType; - @override - Object? iconData; - @override - bool Function() visibilityProvider; - @override - Future Function() postUpdate = () async {}; - String title; - LinkedHashMap children; - - SettingsSubGroup(this.key, this.iconType, this.iconData, this.title, - this.children, this.visibilityProvider); - - @override - Future load(IsarCollection model) async { - for (var item in children.values) { - await item.load(model); - } - } - - @override - Future save(IsarCollection model) async { - for (var item in children.values) { - await item.save(model); - } - - await postUpdate(); - } -} - -class SettingsPadding implements SettingsItem { - @override - Id key; - @override - FirkaIconType? iconType; - @override - Object? iconData; - @override - bool Function() visibilityProvider; - @override - Future Function() postUpdate = () async {}; - double padding; - - SettingsPadding(this.key, this.padding, this.visibilityProvider); - - @override - Future load(IsarCollection model) async {} - - @override - Future save(IsarCollection model) async {} -} - -class SettingsHeader implements SettingsItem { - @override - Id key; - @override - FirkaIconType? iconType; - @override - Object? iconData; - @override - bool Function() visibilityProvider; - @override - Future Function() postUpdate = () async {}; - String title; - - SettingsHeader(this.key, this.title, this.visibilityProvider); - - @override - Future load(IsarCollection model) async {} - - @override - Future save(IsarCollection model) async {} -} - -class SettingsHeaderSmall implements SettingsItem { - @override - Id key; - @override - FirkaIconType? iconType; - @override - Object? iconData; - @override - bool Function() visibilityProvider; - @override - Future Function() postUpdate = () async {}; - String title; - - SettingsHeaderSmall(this.key, this.title, this.visibilityProvider); - - @override - Future load(IsarCollection model) async {} - - @override - Future save(IsarCollection model) async {} -} - -class SettingsSubtitle implements SettingsItem { - @override - Id key; - @override - FirkaIconType? iconType; - @override - Object? iconData; - @override - bool Function() visibilityProvider; - @override - Future Function() postUpdate = () async {}; - String title; - - SettingsSubtitle(this.key, this.title, this.visibilityProvider); - - @override - Future load(IsarCollection model) async {} - - @override - Future save(IsarCollection model) async {} -} - -class SettingsAppIconPreview implements SettingsItem { - @override - Id key; - @override - FirkaIconType? iconType; - @override - Object? iconData; - @override - bool Function() visibilityProvider; - @override - Future Function() postUpdate = () async {}; - 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; - @override - Future Function() postUpdate = () async {}; - 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; - @override - FirkaIconType? iconType; - @override - Object? iconData; - @override - bool Function() visibilityProvider; - @override - Future Function() postUpdate = () async {}; - String title; - bool value = false; - bool defaultValue; - - SettingsBoolean(this.key, this.iconType, this.iconData, this.title, - this.defaultValue, this.visibilityProvider); - - @override - Future load(IsarCollection model) async { - var v = await model.get(key); - if (v == null || v.valueBool == null) { - value = defaultValue; - } else { - value = v.valueBool!; - } - } - - @override - Future save(IsarCollection model) async { - var v = AppSettingsModel(); - v.id = key; - v.valueBool = value; - - await model.put(v); - await postUpdate(); - } -} - -class SettingsItemsRadio implements SettingsItem { - @override - Id key; - @override - FirkaIconType? iconType; - @override - Object? iconData; - @override - bool Function() visibilityProvider; - @override - Future Function() postUpdate; - List values; - int activeIndex = 0; - int defaultIndex; - - SettingsItemsRadio(this.key, this.iconType, this.iconData, this.values, - this.defaultIndex, this.visibilityProvider, this.postUpdate); - - @override - Future load(IsarCollection model) async { - var v = await model.get(key); - if (v == null || v.valueIndex == null) { - activeIndex = defaultIndex; - } else { - activeIndex = v.valueIndex!; - } - } - - @override - Future save(IsarCollection model) async { - var v = AppSettingsModel(); - v.id = key; - v.valueIndex = activeIndex; - - await model.put(v); - await postUpdate(); - } -} - -class SettingsDouble implements SettingsItem { - @override - Id key; - @override - FirkaIconType? iconType; - @override - Object? iconData; - @override - bool Function() visibilityProvider; - @override - Future Function() postUpdate = () async {}; - String title; - double value = 0; - double minValue = 0.0; - double defaultValue; - double maxValue = 0.0; - int precision; - - SettingsDouble( - this.key, - this.iconType, - this.iconData, - this.title, - this.minValue, - this.defaultValue, - this.maxValue, - this.precision, - this.visibilityProvider); - - double toRoundedDouble() { - return double.parse(toRoundedString()); - } - - String toRoundedString() { - return precision == 0 - ? value.toString().split(".")[0] - : value.toStringAsPrecision(precision) == "0.0" - ? "0" - : value.toStringAsPrecision(precision); - } - - @override - Future load(IsarCollection model) async { - var v = await model.get(key); - if (v == null || v.valueDouble == null) { - value = defaultValue; - } else { - value = v.valueDouble!; - } - } - - @override - Future save(IsarCollection model) async { - var v = AppSettingsModel(); - v.id = key; - v.valueDouble = value; - - await model.put(v); - await postUpdate(); - } -} - -class SettingsString implements SettingsItem { - @override - Id key; - @override - FirkaIconType? iconType; - @override - Object? iconData; - @override - bool Function() visibilityProvider; - @override - Future Function() postUpdate = () async {}; - String title; - String value = ""; - String defaultValue; - - SettingsString(this.key, this.iconType, this.iconData, this.title, - this.defaultValue, this.visibilityProvider); - - @override - Future load(IsarCollection model) async { - var v = await model.get(key); - if (v == null || v.valueString == null) { - value = defaultValue; - } else { - value = v.valueString!; - } - } - - @override - Future save(IsarCollection model) async { - var v = AppSettingsModel(); - v.id = key; - v.valueString = value; - - await model.put(v); - await postUpdate(); - } -} +import 'dart:collection'; +import 'dart:core'; +import 'dart:io'; + +import 'package:firka/helpers/db/models/app_settings_model.dart'; +import 'package:firka/l10n/app_localizations.dart'; +import 'package:firka/ui/widget/firka_icon.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:isar/isar.dart'; +import 'package:majesticons_flutter/majesticons_flutter.dart'; + +import '../../main.dart'; +import '../../ui/phone/screens/home/home_screen.dart'; +import '../firka_bundle.dart'; +// import 'package:restart_app/restart_app.dart'; + +const bellRing = 1001; +const rounding1 = 1002; +const rounding2 = 1003; +const rounding3 = 1004; +const rounding4 = 1005; +const classAvgOnGraph = 1006; +const leftHandedMode = 1007; +const language = 1008; +const appIcon = 1009; +const child_protection = 1010; + +bool always() { + return true; +} + +bool never() { + return false; +} + +bool isAndroid() { + return Platform.isAndroid; +} + +bool isDebug() { + return kDebugMode; +} + +class SettingsStore { + LinkedHashMap items = LinkedHashMap.of({}); + + Map appIcons = {}; + + SettingsStore(AppLocalizations l10n) { + items["settings"] = SettingsGroup( + 0, + LinkedHashMap.of({ + "settings_header": SettingsHeader(0, l10n.s_settings, always), + "settings_padding": SettingsPadding(0, 20, always), + "application": SettingsSubGroup( + 0, + FirkaIconType.majesticons, + Majesticon.settingsCogSolid, + l10n.s_a, + LinkedHashMap.of({ + // TODO: Make a back arrow widget + "settings_header": SettingsHeader(0, l10n.s_ag, always), + "settings_padding": SettingsPadding(0, 23, always), + + "bell_delay": SettingsDouble(bellRing, null, null, + l10n.s_ag_bell_delay, 0, 0, 120, 0, always), + "rounding": SettingsSubGroup( + 0, + null, + null, + l10n.s_ag_rounding, + LinkedHashMap.of({ + "1": SettingsDouble(rounding1, null, null, l10n.s_ag_r1, + 0.1, 0.5, 0.99, 2, always), + "2": SettingsDouble(rounding2, null, null, l10n.s_ag_r2, + 0.1, 0.5, 0.99, 2, always), + "3": SettingsDouble(rounding3, null, null, l10n.s_ag_r3, + 0.1, 0.5, 0.99, 2, always), + "4": SettingsDouble(rounding4, null, null, l10n.s_ag_r4, + 0.1, 0.5, 0.99, 2, always), + }), + always), + "class_avg_on_graph": SettingsBoolean(classAvgOnGraph, null, + null, l10n.s_ag_class_avg_on_graph, true, never), + "navbar": SettingsSubGroup( + 0, + null, // TODO: icon + null, + l10n.s_ag_navbar, + LinkedHashMap.of({}), + never), + "left_handed_mode": SettingsBoolean(leftHandedMode, null, null, + l10n.s_ag_left_handed_mode, false, never), + "language_header": + SettingsHeaderSmall(0, l10n.s_ag_language_header, always), + "language": SettingsItemsRadio( + language, + null, + null, + [ + l10n.s_ag_language_auto, + l10n.s_ag_language_hu, + l10n.s_ag_language_en, + l10n.s_ag_language_de + ], + 0, + always, () async { + Navigator.of(navigatorKey.currentContext!) + .popUntil((route) => false); + + initLang(initData); + initData.settings = SettingsStore(initData.l10n); + await initData.settings.load(initData.isar.appSettingsModels); + + Navigator.push( + navigatorKey.currentContext!, + MaterialPageRoute( + builder: (context) => DefaultAssetBundle( + bundle: FirkaBundle(), + child: HomeScreen( + initData, + false, + key: ValueKey('homeScreen'), + ))), + ); + }) + }), + always), + "customization": SettingsSubGroup( + 0, + FirkaIconType.majesticons, + Majesticon.flower2Solid, + l10n.s_c, + LinkedHashMap.of({ + "icon_header": + SettingsHeaderSmall(0, l10n.s_c_icon_header, always), + "icon_preview": SettingsAppIconPreview(0, always), + "icon_picker": SettingsSubGroup( + 0, + null, + null, + l10n.s_c_replace_icon, + LinkedHashMap.of({ + "icon_header": + SettingsHeader(0, l10n.s_ci_icon_header, always), + "warning_header": + SettingsHeader(0, l10n.s_ci_warning_header, isDebug), + "icon_subtitle": + SettingsSubtitle(0, l10n.s_ci_icon_subtitle, always), + "settings_padding": SettingsPadding(0, 24, always), + "icon_preview": SettingsAppIconPreview(0, always), + "settings_padding2": SettingsPadding(0, 24, always), + "child_protection": SettingsBoolean( + child_protection, + FirkaIconType.majesticons, + Majesticon.shieldSolid, + l10n.s_ci_child_protection, + true, + never), + "icon_picker": SettingsAppIconPicker( + 0, + "original", + { + l10n.s_ci_icon_g1: [ + "original", + "refilc", + "filc", + "galaxy", + "cactus", + "refulc", + "pixel" + ], + l10n.s_ci_icon_g2: [ + "modern", + "paper", + "filco", + "o1g" + ], + l10n.s_ci_icon_g3: [ + "kreta", + "cc", + "repont", + "void_icon", + "pixelized", + "fidesz", + "mkkp" + ], + l10n.s_ci_icon_g4: ["xmas1", "xmas2", "xmas3"], + l10n.s_ci_icon_g5: [ + "lgbtq", + "lgbtqp", + "trans", + "enby", + "ace", + "gay", + "lesb", + "bi" + ], + l10n.s_ci_icon_g6: [ + "lgbtq_f", + "lgbtqp_f", + "trans_f", + "enby_f", + "ace_f", + "gay_f", + "lesb_f", + "bi_f" + ] + }, + always), + }), + isAndroid), + }), + always), + "notifications": SettingsSubGroup(0, FirkaIconType.majesticons, + Majesticon.bellSolid, "Értesítések", LinkedHashMap.of({}), never), + "extras": SettingsSubGroup( + 0, + FirkaIconType.majesticons, + Majesticon.lightningBoltSolid, + "Extrák", + LinkedHashMap.of({}), + never), + "settings_other_padding": SettingsPadding(0, 20, never), + "settings_other_header": SettingsHeaderSmall(0, "Egyéb", never), + }), + always); + + appIcons = { + "ace": l10n.ic_ace, + "ace_f": l10n.ic_ace_f, + "bi": l10n.ic_bi, + "bi_f": l10n.ic_bi_f, + "cactus": l10n.ic_cactus, + "cc": l10n.ic_cc, + "enby": l10n.ic_enby, + "enby_f": l10n.ic_enby_f, + "fidesz": l10n.ic_fidesz, + "filc": l10n.ic_filc, + "filco": l10n.ic_filco, + "galaxy": l10n.ic_galaxy, + "gay": l10n.ic_gay, + "gay_f": l10n.ic_gay_f, + "kreta": l10n.ic_kreta, + "lesb": l10n.ic_lesb, + "lesb_f": l10n.ic_lesb_f, + "lgbtq": l10n.ic_lgbtq, + "lgbtq_f": l10n.ic_lgbtq_f, + "lgbtqp": l10n.ic_lgbtqp, + "lgbtqp_f": l10n.ic_lgbtqp_f, + "mkkp": l10n.ic_mkkp, + "modern": l10n.ic_modern, + "o1g": l10n.ic_o1g, + "original": l10n.ic_original, + "paper": l10n.ic_paper, + "pixel": l10n.ic_pixel, + "pixelized": l10n.ic_pixelized, + "refilc": l10n.ic_refilc, + "refulc": l10n.ic_refulc, + "repont": l10n.ic_repont, + "trans": l10n.ic_trans, + "trans_f": l10n.ic_trans_f, + "void_icon": l10n.ic_void_icon, + "xmas1": l10n.ic_xmas1, + "xmas2": l10n.ic_xmas2, + "xmas3": l10n.ic_xmas3 + }; + } + + LinkedHashMap group(String key) { + return (items[key] as SettingsGroup).children; + } + + Future save(IsarCollection model) async { + for (var item in items.values) { + await item.save(model); + } + } + + Future load(IsarCollection model) async { + for (var item in items.values) { + await item.load(model); + } + } +} + +extension SettingExt on LinkedHashMap { + LinkedHashMap group(String key) { + return (this[key] as SettingsGroup).children; + } + + LinkedHashMap subGroup(String key) { + return (this[key] as SettingsSubGroup).children; + } + + String string(String key) { + return (this[key] as SettingsString).value; + } + + void setString(String key, String value) { + (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; + } + + void setDbl(String key, double value) { + (this[key] as SettingsDouble).value = value; + } + + bool boolean(String key) { + return (this[key] as SettingsBoolean).value; + } + + void setBoolean(String key, bool value) { + (this[key] as SettingsBoolean).value = value; + } +} + +class SettingsItem { + Id key; + FirkaIconType? iconType; + Object? iconData; + bool Function() visibilityProvider; + Future Function() postUpdate = () async {}; + + SettingsItem(this.key, this.iconType, this.iconData, this.visibilityProvider); + + Future save(IsarCollection model) async {} + + Future load(IsarCollection model) async {} +} + +class SettingsGroup implements SettingsItem { + @override + Id key; + @override + FirkaIconType? iconType; + @override + Object? iconData; + @override + bool Function() visibilityProvider; + @override + Future Function() postUpdate = () async {}; + LinkedHashMap children; + + SettingsGroup(this.key, this.children, this.visibilityProvider); + + @override + Future load(IsarCollection model) async { + for (var item in children.values) { + await item.load(model); + } + } + + @override + Future save(IsarCollection model) async { + for (var item in children.values) { + await item.save(model); + } + + await postUpdate(); + } +} + +class SettingsSubGroup implements SettingsItem { + @override + Id key; + @override + FirkaIconType? iconType; + @override + Object? iconData; + @override + bool Function() visibilityProvider; + @override + Future Function() postUpdate = () async {}; + String title; + LinkedHashMap children; + + SettingsSubGroup(this.key, this.iconType, this.iconData, this.title, + this.children, this.visibilityProvider); + + @override + Future load(IsarCollection model) async { + for (var item in children.values) { + await item.load(model); + } + } + + @override + Future save(IsarCollection model) async { + for (var item in children.values) { + await item.save(model); + } + + await postUpdate(); + } +} + +class SettingsPadding implements SettingsItem { + @override + Id key; + @override + FirkaIconType? iconType; + @override + Object? iconData; + @override + bool Function() visibilityProvider; + @override + Future Function() postUpdate = () async {}; + double padding; + + SettingsPadding(this.key, this.padding, this.visibilityProvider); + + @override + Future load(IsarCollection model) async {} + + @override + Future save(IsarCollection model) async {} +} + +class SettingsHeader implements SettingsItem { + @override + Id key; + @override + FirkaIconType? iconType; + @override + Object? iconData; + @override + bool Function() visibilityProvider; + @override + Future Function() postUpdate = () async {}; + String title; + + SettingsHeader(this.key, this.title, this.visibilityProvider); + + @override + Future load(IsarCollection model) async {} + + @override + Future save(IsarCollection model) async {} +} + +class SettingsHeaderSmall implements SettingsItem { + @override + Id key; + @override + FirkaIconType? iconType; + @override + Object? iconData; + @override + bool Function() visibilityProvider; + @override + Future Function() postUpdate = () async {}; + String title; + + SettingsHeaderSmall(this.key, this.title, this.visibilityProvider); + + @override + Future load(IsarCollection model) async {} + + @override + Future save(IsarCollection model) async {} +} + +class SettingsSubtitle implements SettingsItem { + @override + Id key; + @override + FirkaIconType? iconType; + @override + Object? iconData; + @override + bool Function() visibilityProvider; + @override + Future Function() postUpdate = () async {}; + String title; + + SettingsSubtitle(this.key, this.title, this.visibilityProvider); + + @override + Future load(IsarCollection model) async {} + + @override + Future save(IsarCollection model) async {} +} + +class SettingsAppIconPreview implements SettingsItem { + @override + Id key; + @override + FirkaIconType? iconType; + @override + Object? iconData; + @override + bool Function() visibilityProvider; + @override + Future Function() postUpdate = () async {}; + 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; + @override + Future Function() postUpdate = () async {}; + 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; + @override + FirkaIconType? iconType; + @override + Object? iconData; + @override + bool Function() visibilityProvider; + @override + Future Function() postUpdate = () async {}; + String title; + bool value = false; + bool defaultValue; + + SettingsBoolean(this.key, this.iconType, this.iconData, this.title, + this.defaultValue, this.visibilityProvider); + + @override + Future load(IsarCollection model) async { + var v = await model.get(key); + if (v == null || v.valueBool == null) { + value = defaultValue; + } else { + value = v.valueBool!; + } + } + + @override + Future save(IsarCollection model) async { + var v = AppSettingsModel(); + v.id = key; + v.valueBool = value; + + await model.put(v); + await postUpdate(); + } +} + +class SettingsItemsRadio implements SettingsItem { + @override + Id key; + @override + FirkaIconType? iconType; + @override + Object? iconData; + @override + bool Function() visibilityProvider; + @override + Future Function() postUpdate; + List values; + int activeIndex = 0; + int defaultIndex; + + SettingsItemsRadio(this.key, this.iconType, this.iconData, this.values, + this.defaultIndex, this.visibilityProvider, this.postUpdate); + + @override + Future load(IsarCollection model) async { + var v = await model.get(key); + if (v == null || v.valueIndex == null) { + activeIndex = defaultIndex; + } else { + activeIndex = v.valueIndex!; + } + } + + @override + Future save(IsarCollection model) async { + var v = AppSettingsModel(); + v.id = key; + v.valueIndex = activeIndex; + + await model.put(v); + await postUpdate(); + } +} + +class SettingsDouble implements SettingsItem { + @override + Id key; + @override + FirkaIconType? iconType; + @override + Object? iconData; + @override + bool Function() visibilityProvider; + @override + Future Function() postUpdate = () async {}; + String title; + double value = 0; + double minValue = 0.0; + double defaultValue; + double maxValue = 0.0; + int precision; + + SettingsDouble( + this.key, + this.iconType, + this.iconData, + this.title, + this.minValue, + this.defaultValue, + this.maxValue, + this.precision, + this.visibilityProvider); + + double toRoundedDouble() { + return double.parse(toRoundedString()); + } + + String toRoundedString() { + return precision == 0 + ? value.toString().split(".")[0] + : value.toStringAsPrecision(precision) == "0.0" + ? "0" + : value.toStringAsPrecision(precision); + } + + @override + Future load(IsarCollection model) async { + var v = await model.get(key); + if (v == null || v.valueDouble == null) { + value = defaultValue; + } else { + value = v.valueDouble!; + } + } + + @override + Future save(IsarCollection model) async { + var v = AppSettingsModel(); + v.id = key; + v.valueDouble = value; + + await model.put(v); + await postUpdate(); + } +} + +class SettingsString implements SettingsItem { + @override + Id key; + @override + FirkaIconType? iconType; + @override + Object? iconData; + @override + bool Function() visibilityProvider; + @override + Future Function() postUpdate = () async {}; + String title; + String value = ""; + String defaultValue; + + SettingsString(this.key, this.iconType, this.iconData, this.title, + this.defaultValue, this.visibilityProvider); + + @override + Future load(IsarCollection model) async { + var v = await model.get(key); + if (v == null || v.valueString == null) { + value = defaultValue; + } else { + value = v.valueString!; + } + } + + @override + Future save(IsarCollection model) async { + var v = AppSettingsModel(); + v.id = key; + v.valueString = value; + + await model.put(v); + await postUpdate(); + } +} diff --git a/firka/lib/ui/phone/screens/settings/settings_screen.dart b/firka/lib/ui/phone/screens/settings/settings_screen.dart index ac9b1ba9..42624076 100644 --- a/firka/lib/ui/phone/screens/settings/settings_screen.dart +++ b/firka/lib/ui/phone/screens/settings/settings_screen.dart @@ -1,551 +1,551 @@ -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'; -import 'package:firka/ui/widget/firka_icon.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; - -import '../../../../helpers/firka_bundle.dart'; -import '../../../../helpers/settings/setting.dart'; - -class SettingsScreen extends StatefulWidget { - final AppInitialization data; - final LinkedHashMap items; - - const SettingsScreen(this.data, this.items, {super.key}); - - @override - State createState() => _SettingsScreenState(); -} - -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() { - SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( - statusBarBrightness: Brightness.light, - statusBarIconBrightness: Brightness.dark, - statusBarColor: Colors.transparent, - systemNavigationBarColor: appStyle.colors.background, - systemNavigationBarIconBrightness: Brightness.dark, - systemNavigationBarDividerColor: Colors.transparent, - )); - } - - List createWidgetTree( - Iterable items, SettingsStore settings, - {bool forceRender = false}) { - var widgets = List.empty(growable: true); - - for (var item in items) { - if (!forceRender && !item.visibilityProvider()) continue; - if (item is SettingsGroup) { - 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( - item.title, - style: - appStyle.fonts.H_14px.apply(color: appStyle.colors.textPrimary), - )); - - continue; - } - if (item is SettingsSubGroup) { - List cardWidgets = []; - - if (item.iconType != null && item.iconData != null) { - cardWidgets.add(FirkaIconWidget( - item.iconType!, - item.iconData!, - color: appStyle.colors.accent, - )); - cardWidgets.add(SizedBox(width: 8)); - } - - cardWidgets.add(Text(item.title, - style: appStyle.fonts.B_14SB - .apply(color: appStyle.colors.textPrimary))); - - widgets.add(GestureDetector( - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => DefaultAssetBundle( - bundle: FirkaBundle(), - child: SettingsScreen(widget.data, item.children)))); - }, - child: FirkaCard(left: cardWidgets), - )); - - continue; - } - - if (item is SettingsDouble) { - var v = item.toRoundedString(); - - widgets.add(GestureDetector( - child: FirkaCard(left: [ - Text(item.title, - style: appStyle.fonts.B_16SB - .apply(color: appStyle.colors.textPrimary)) - ], right: [ - Text(v == "0.0" ? "0" : v, - style: appStyle.fonts.B_14R - .apply(color: appStyle.colors.textPrimary)) - ]), - onTap: () async { - showSetDoubleSheet(context, item, widget.data, setState); - }, - )); - - continue; - } - if (item is SettingsBoolean) { - widgets.add(FirkaCard( - left: [ - Text(item.title, - style: appStyle.fonts.B_16SB - .apply(color: appStyle.colors.textPrimary)) - ], - right: [ - Switch( - value: item.value, - // activeColor: appStyle.colors.accent, - thumbColor: WidgetStateProperty.fromMap({ - WidgetState.selected: appStyle.colors.buttonSecondaryFill, - WidgetState.any: appStyle.colors.accent - }), - trackColor: WidgetStateProperty.fromMap({ - WidgetState.selected: appStyle.colors.accent, - WidgetState.any: appStyle.colors.a10p - }), - trackOutlineColor: WidgetStateProperty.fromMap({ - WidgetState.selected: appStyle.colors.accent, - WidgetState.any: appStyle.colors.a15p - }), - onChanged: (v) async { - setState(() { - item.value = v; - }); - - await widget.data.isar.writeTxn(() async { - await item.save(widget.data.isar.appSettingsModels); - }); - }) - ], - )); - - continue; - } - if (item is SettingsItemsRadio) { - for (var i = 0; i < item.values.length; i++) { - var k = item.values[i]; - - if (item.values[item.activeIndex] == k) { - widgets.add(FirkaCard(left: [ - Text(k, - style: appStyle.fonts.B_16R - .apply(color: appStyle.colors.textPrimary)) - ], right: [ - Checkbox( - value: true, - fillColor: WidgetStateProperty.resolveWith( - (Set states) { - return appStyle.colors.secondary; - }), - onChanged: (_) async { - setState(() { - item.activeIndex = i; - }); - - await widget.data.isar.writeTxn(() async { - await item.save(widget.data.isar.appSettingsModels); - }); - debugPrint('Settings saved'); - }) - ])); - } else { - widgets.add(GestureDetector( - child: FirkaCard(left: [ - Text(k, - style: appStyle.fonts.B_16R - .apply(color: appStyle.colors.textPrimary)) - ], right: [ - SizedBox(height: 48), - ]), - onTap: () async { - setState(() { - item.activeIndex = i; - }); - - await widget.data.isar.writeTxn(() async { - await item.save(widget.data.isar.appSettingsModels); - }); - }, - )); - } - } - - 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( - settings.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) { - if (widget.data.settings - .group("settings") - .subGroup("customization") - .subGroup("icon_picker") - .boolean("child_protection")) { - if (group == widget.data.l10n.s_ci_icon_g5) { - continue; - } - } else { - if (group == widget.data.l10n.s_ci_icon_g6) { - continue; - } - } - 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, - ), - ), - ), - ) - : ClipRRect( - borderRadius: - const BorderRadius.all(Radius.circular(16.0)), - child: Image.asset( - "assets/images/icons/$icon.png", - width: 54, - height: 54, - ), - ), - onTap: () { - if (settingAppIcon) return; - - setState(() { - activeIcon = icon; - }); - }, - ), - Text( - settings.appIcons[icon]!, - style: appStyle.fonts.B_12R, - textAlign: TextAlign.center, - ), - ], - )); - } - - pWidgets.add(Text( - group, - style: - appStyle.fonts.H_14px.apply(color: appStyle.colors.textPrimary), - )); - - if (group == widget.data.l10n.s_ci_icon_g5 || - group == widget.data.l10n.s_ci_icon_g6) { - var settingsWidgets = createWidgetTree([ - widget.data.settings - .group("settings") - .subGroup("customization") - .subGroup("icon_picker")["child_protection"] - as SettingsBoolean - ], settings, forceRender: true); - - pWidgets.add(SizedBox(height: 12)); - for (var w in settingsWidgets) { - pWidgets.add(w); - } - } - - 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: widget.data.l10n.cancel, - bgColor: appStyle.colors.buttonSecondaryFill, - fontStyle: appStyle.fonts.B_14R - .apply(color: appStyle.colors.textSecondary)), - onTap: () { - Navigator.pop(context); - }, - ), - GestureDetector( - child: FirkaButton( - text: widget.data.l10n.save, - 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": settings.appIcons.keys - .where((e) => e != "original") - .join(",") - }); - }, - ) - ], - )); - - continue; - } - } - - return widgets; - } - - @override - 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, widget.data.settings); - - return Scaffold( - backgroundColor: appStyle.colors.background, - body: SafeArea( - child: SizedBox( - height: MediaQuery.of(context).size.height, - child: Stack( - children: [ - Padding( - padding: EdgeInsetsGeometry.all(20), - child: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: body)), - ) - ], - ), - ), - ), - ); - } -} - -void showSetDoubleSheet(BuildContext context, SettingsDouble setting, - AppInitialization data, void Function(VoidCallback fn) setStateOuter) { - showModalBottomSheet( - context: context, - elevation: 100, - isScrollControlled: true, - enableDrag: true, - backgroundColor: Colors.transparent, - barrierColor: appStyle.colors.a15p, - constraints: BoxConstraints( - maxHeight: MediaQuery.of(context).size.height * 0.13, - ), - builder: (BuildContext context) { - return StatefulBuilder( - builder: (BuildContext context, setState) => Stack( - children: [ - Positioned.fill( - child: GestureDetector( - onTap: () => Navigator.pop(context), - behavior: HitTestBehavior.opaque, - child: Container(color: Colors.transparent), - ), - ), - Align( - alignment: Alignment.bottomCenter, - child: Container( - decoration: BoxDecoration( - color: appStyle.colors.card, - borderRadius: - BorderRadius.vertical(top: Radius.circular(16)), - ), - child: Padding( - padding: const EdgeInsets.only( - left: 18.0, right: 16.0, bottom: 30.0, top: 20.0), - child: Column( - children: [ - Center( - child: Text( - setting.title, - style: appStyle.fonts.B_14R, - )), - Padding( - padding: const EdgeInsets.symmetric( - vertical: 0, horizontal: 40), - child: Row( - mainAxisSize: MainAxisSize.max, - children: [ - Expanded( - // TODO: Make a firka slider - child: Slider( - min: setting.minValue, - value: setting.value, - max: setting.maxValue, - thumbColor: appStyle.colors.accent, - activeColor: appStyle.colors.secondary, - inactiveColor: appStyle.colors.a15p, - onChanged: (v) async { - setState(() { - setting.value = v; - setting.value = - setting.toRoundedDouble(); - }); - - await data.isar.writeTxn(() async { - await setting.save( - data.isar.appSettingsModels); - - setStateOuter(() {}); - }); - }), - ), - Text(setting.toRoundedString(), - style: appStyle.fonts.B_14R.apply( - color: appStyle.colors.textPrimary)) - ], - ), - ), - ], - ), - ), - ), - ), - ], - )); - }, - ); -} +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'; +import 'package:firka/ui/widget/firka_icon.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +import '../../../../helpers/firka_bundle.dart'; +import '../../../../helpers/settings/setting.dart'; + +class SettingsScreen extends StatefulWidget { + final AppInitialization data; + final LinkedHashMap items; + + const SettingsScreen(this.data, this.items, {super.key}); + + @override + State createState() => _SettingsScreenState(); +} + +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() { + SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( + statusBarBrightness: Brightness.light, + statusBarIconBrightness: Brightness.dark, + statusBarColor: Colors.transparent, + systemNavigationBarColor: appStyle.colors.background, + systemNavigationBarIconBrightness: Brightness.dark, + systemNavigationBarDividerColor: Colors.transparent, + )); + } + + List createWidgetTree( + Iterable items, SettingsStore settings, + {bool forceRender = false}) { + var widgets = List.empty(growable: true); + + for (var item in items) { + if (!forceRender && !item.visibilityProvider()) continue; + if (item is SettingsGroup) { + 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( + item.title, + style: + appStyle.fonts.H_14px.apply(color: appStyle.colors.textPrimary), + )); + + continue; + } + if (item is SettingsSubGroup) { + List cardWidgets = []; + + if (item.iconType != null && item.iconData != null) { + cardWidgets.add(FirkaIconWidget( + item.iconType!, + item.iconData!, + color: appStyle.colors.accent, + )); + cardWidgets.add(SizedBox(width: 8)); + } + + cardWidgets.add(Text(item.title, + style: appStyle.fonts.B_14SB + .apply(color: appStyle.colors.textPrimary))); + + widgets.add(GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => DefaultAssetBundle( + bundle: FirkaBundle(), + child: SettingsScreen(widget.data, item.children)))); + }, + child: FirkaCard(left: cardWidgets), + )); + + continue; + } + + if (item is SettingsDouble) { + var v = item.toRoundedString(); + + widgets.add(GestureDetector( + child: FirkaCard(left: [ + Text(item.title, + style: appStyle.fonts.B_16SB + .apply(color: appStyle.colors.textPrimary)) + ], right: [ + Text(v == "0.0" ? "0" : v, + style: appStyle.fonts.B_14R + .apply(color: appStyle.colors.textPrimary)) + ]), + onTap: () async { + showSetDoubleSheet(context, item, widget.data, setState); + }, + )); + + continue; + } + if (item is SettingsBoolean) { + widgets.add(FirkaCard( + left: [ + Text(item.title, + style: appStyle.fonts.B_16SB + .apply(color: appStyle.colors.textPrimary)) + ], + right: [ + Switch( + value: item.value, + // activeColor: appStyle.colors.accent, + thumbColor: WidgetStateProperty.fromMap({ + WidgetState.selected: appStyle.colors.buttonSecondaryFill, + WidgetState.any: appStyle.colors.accent + }), + trackColor: WidgetStateProperty.fromMap({ + WidgetState.selected: appStyle.colors.accent, + WidgetState.any: appStyle.colors.a10p + }), + trackOutlineColor: WidgetStateProperty.fromMap({ + WidgetState.selected: appStyle.colors.accent, + WidgetState.any: appStyle.colors.a15p + }), + onChanged: (v) async { + setState(() { + item.value = v; + }); + + await widget.data.isar.writeTxn(() async { + await item.save(widget.data.isar.appSettingsModels); + }); + }) + ], + )); + + continue; + } + if (item is SettingsItemsRadio) { + for (var i = 0; i < item.values.length; i++) { + var k = item.values[i]; + + if (item.values[item.activeIndex] == k) { + widgets.add(FirkaCard(left: [ + Text(k, + style: appStyle.fonts.B_16R + .apply(color: appStyle.colors.textPrimary)) + ], right: [ + Checkbox( + value: true, + fillColor: WidgetStateProperty.resolveWith( + (Set states) { + return appStyle.colors.secondary; + }), + onChanged: (_) async { + setState(() { + item.activeIndex = i; + }); + + await widget.data.isar.writeTxn(() async { + await item.save(widget.data.isar.appSettingsModels); + }); + debugPrint('Settings saved'); + }) + ])); + } else { + widgets.add(GestureDetector( + child: FirkaCard(left: [ + Text(k, + style: appStyle.fonts.B_16R + .apply(color: appStyle.colors.textPrimary)) + ], right: [ + SizedBox(height: 48), + ]), + onTap: () async { + setState(() { + item.activeIndex = i; + }); + + await widget.data.isar.writeTxn(() async { + await item.save(widget.data.isar.appSettingsModels); + }); + }, + )); + } + } + + 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( + settings.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) { + if (widget.data.settings + .group("settings") + .subGroup("customization") + .subGroup("icon_picker") + .boolean("child_protection")) { + if (group == widget.data.l10n.s_ci_icon_g5) { + continue; + } + } else { + if (group == widget.data.l10n.s_ci_icon_g6) { + continue; + } + } + 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, + ), + ), + ), + ) + : ClipRRect( + borderRadius: + const BorderRadius.all(Radius.circular(16.0)), + child: Image.asset( + "assets/images/icons/$icon.png", + width: 54, + height: 54, + ), + ), + onTap: () { + if (settingAppIcon) return; + + setState(() { + activeIcon = icon; + }); + }, + ), + Text( + settings.appIcons[icon]!, + style: appStyle.fonts.B_12R, + textAlign: TextAlign.center, + ), + ], + )); + } + + pWidgets.add(Text( + group, + style: + appStyle.fonts.H_14px.apply(color: appStyle.colors.textPrimary), + )); + + if (group == widget.data.l10n.s_ci_icon_g5 || + group == widget.data.l10n.s_ci_icon_g6) { + var settingsWidgets = createWidgetTree([ + widget.data.settings + .group("settings") + .subGroup("customization") + .subGroup("icon_picker")["child_protection"] + as SettingsBoolean + ], settings, forceRender: true); + + pWidgets.add(SizedBox(height: 12)); + for (var w in settingsWidgets) { + pWidgets.add(w); + } + } + + 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: widget.data.l10n.cancel, + bgColor: appStyle.colors.buttonSecondaryFill, + fontStyle: appStyle.fonts.B_14R + .apply(color: appStyle.colors.textSecondary)), + onTap: () { + Navigator.pop(context); + }, + ), + GestureDetector( + child: FirkaButton( + text: widget.data.l10n.save, + 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": settings.appIcons.keys + .where((e) => e != "original") + .join(",") + }); + }, + ) + ], + )); + + continue; + } + } + + return widgets; + } + + @override + 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, widget.data.settings); + + return Scaffold( + backgroundColor: appStyle.colors.background, + body: SafeArea( + child: SizedBox( + height: MediaQuery.of(context).size.height, + child: Stack( + children: [ + Padding( + padding: EdgeInsetsGeometry.all(20), + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: body)), + ) + ], + ), + ), + ), + ); + } +} + +void showSetDoubleSheet(BuildContext context, SettingsDouble setting, + AppInitialization data, void Function(VoidCallback fn) setStateOuter) { + showModalBottomSheet( + context: context, + elevation: 100, + isScrollControlled: true, + enableDrag: true, + backgroundColor: Colors.transparent, + barrierColor: appStyle.colors.a15p, + constraints: BoxConstraints( + maxHeight: MediaQuery.of(context).size.height * 0.13, + ), + builder: (BuildContext context) { + return StatefulBuilder( + builder: (BuildContext context, setState) => Stack( + children: [ + Positioned.fill( + child: GestureDetector( + onTap: () => Navigator.pop(context), + behavior: HitTestBehavior.opaque, + child: Container(color: Colors.transparent), + ), + ), + Align( + alignment: Alignment.bottomCenter, + child: Container( + decoration: BoxDecoration( + color: appStyle.colors.card, + borderRadius: + BorderRadius.vertical(top: Radius.circular(16)), + ), + child: Padding( + padding: const EdgeInsets.only( + left: 18.0, right: 16.0, bottom: 30.0, top: 20.0), + child: Column( + children: [ + Center( + child: Text( + setting.title, + style: appStyle.fonts.B_14R, + )), + Padding( + padding: const EdgeInsets.symmetric( + vertical: 0, horizontal: 40), + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + Expanded( + // TODO: Make a firka slider + child: Slider( + min: setting.minValue, + value: setting.value, + max: setting.maxValue, + thumbColor: appStyle.colors.accent, + activeColor: appStyle.colors.secondary, + inactiveColor: appStyle.colors.a15p, + onChanged: (v) async { + setState(() { + setting.value = v; + setting.value = + setting.toRoundedDouble(); + }); + + await data.isar.writeTxn(() async { + await setting.save( + data.isar.appSettingsModels); + + setStateOuter(() {}); + }); + }), + ), + Text(setting.toRoundedString(), + style: appStyle.fonts.B_14R.apply( + color: appStyle.colors.textPrimary)) + ], + ), + ), + ], + ), + ), + ), + ), + ], + )); + }, + ); +} diff --git a/firka/lib/ui/widget/counter_digit.dart b/firka/lib/ui/widget/counter_digit.dart index 9c13f35d..e6e77a53 100644 --- a/firka/lib/ui/widget/counter_digit.dart +++ b/firka/lib/ui/widget/counter_digit.dart @@ -1,24 +1,24 @@ -import 'package:firka/ui/model/style.dart'; -import 'package:flutter/material.dart'; - -class CounterDigitWidget extends StatelessWidget { - final String c; - final TextStyle? style; - - const CounterDigitWidget(this.c, this.style, {super.key}); - - @override - Widget build(BuildContext context) { - return Card( - shadowColor: Colors.transparent, - color: appStyle.colors.buttonSecondaryFill, - child: Padding( - padding: EdgeInsets.only(left: 8, right: 8, top: 4, bottom: 4), - child: Text( - c, - style: style, - ), - ), - ); - } -} +import 'package:firka/ui/model/style.dart'; +import 'package:flutter/material.dart'; + +class CounterDigitWidget extends StatelessWidget { + final String c; + final TextStyle? style; + + const CounterDigitWidget(this.c, this.style, {super.key}); + + @override + Widget build(BuildContext context) { + return Card( + shadowColor: Colors.transparent, + color: appStyle.colors.buttonSecondaryFill, + child: Padding( + padding: EdgeInsets.only(left: 8, right: 8, top: 4, bottom: 4), + child: Text( + c, + style: style, + ), + ), + ); + } +} diff --git a/firka/lib/ui/widget/delayed_spinner.dart b/firka/lib/ui/widget/delayed_spinner.dart index aac5a574..9eccfc93 100644 --- a/firka/lib/ui/widget/delayed_spinner.dart +++ b/firka/lib/ui/widget/delayed_spinner.dart @@ -1,46 +1,46 @@ -import 'dart:async'; - -import 'package:flutter/material.dart'; - -import '../model/style.dart'; - -class DelayedSpinnerWidget extends StatefulWidget { - const DelayedSpinnerWidget({super.key}); - - @override - State createState() => _DelayedSpinner(); -} - -class _DelayedSpinner extends State { - Timer? timer; - bool showSpinner = false; - - @override - void initState() { - super.initState(); - - timer = Timer(Duration(milliseconds: 50), () { - setState(() { - showSpinner = true; - }); - }); - } - - @override - Widget build(BuildContext context) { - if (showSpinner) { - return CircularProgressIndicator( - color: appStyle.colors.accent, - ); - } else { - return SizedBox(); - } - } - - @override - void dispose() { - super.dispose(); - - timer?.cancel(); - } -} +import 'dart:async'; + +import 'package:flutter/material.dart'; + +import '../model/style.dart'; + +class DelayedSpinnerWidget extends StatefulWidget { + const DelayedSpinnerWidget({super.key}); + + @override + State createState() => _DelayedSpinner(); +} + +class _DelayedSpinner extends State { + Timer? timer; + bool showSpinner = false; + + @override + void initState() { + super.initState(); + + timer = Timer(Duration(milliseconds: 50), () { + setState(() { + showSpinner = true; + }); + }); + } + + @override + Widget build(BuildContext context) { + if (showSpinner) { + return CircularProgressIndicator( + color: appStyle.colors.accent, + ); + } else { + return SizedBox(); + } + } + + @override + void dispose() { + super.dispose(); + + timer?.cancel(); + } +} diff --git a/firka/lib/ui/widget/firka_icon.dart b/firka/lib/ui/widget/firka_icon.dart index 2bab7597..beffbbe4 100644 --- a/firka/lib/ui/widget/firka_icon.dart +++ b/firka/lib/ui/widget/firka_icon.dart @@ -1,41 +1,41 @@ -import 'dart:typed_data'; - -import 'package:flutter/material.dart'; -import 'package:flutter_svg/svg.dart'; -import 'package:majesticons_flutter/majesticons_flutter.dart'; - -enum FirkaIconType { - icons, - majesticons, - majesticonsLocal, -} - -class FirkaIconWidget extends StatelessWidget { - final FirkaIconType iconType; - final Object iconData; - final Color color; - final double? size; - - const FirkaIconWidget(this.iconType, this.iconData, - {super.key, this.color = Colors.white, this.size}); - - @override - Widget build(BuildContext context) { - switch (iconType) { - case FirkaIconType.icons: - return SvgPicture.asset( - 'assets/icons/${iconData as String}.svg', - color: color, - height: size, - ); - case FirkaIconType.majesticons: - return Majesticon(iconData as Uint8List, color: color, size: size); - case FirkaIconType.majesticonsLocal: - return SvgPicture.asset( - 'assets/majesticons/${iconData as String}.svg', - color: color, - height: size, - ); - } - } -} +import 'dart:typed_data'; + +import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:majesticons_flutter/majesticons_flutter.dart'; + +enum FirkaIconType { + icons, + majesticons, + majesticonsLocal, +} + +class FirkaIconWidget extends StatelessWidget { + final FirkaIconType iconType; + final Object iconData; + final Color color; + final double? size; + + const FirkaIconWidget(this.iconType, this.iconData, + {super.key, this.color = Colors.white, this.size}); + + @override + Widget build(BuildContext context) { + switch (iconType) { + case FirkaIconType.icons: + return SvgPicture.asset( + 'assets/icons/${iconData as String}.svg', + color: color, + height: size, + ); + case FirkaIconType.majesticons: + return Majesticon(iconData as Uint8List, color: color, size: size); + case FirkaIconType.majesticonsLocal: + return SvgPicture.asset( + 'assets/majesticons/${iconData as String}.svg', + color: color, + height: size, + ); + } + } +}