Milan Jurkulak 1 سال پیش
والد
کامیت
4aa5a41482

+ 13 - 0
.github/copilot-instructions.md

@@ -0,0 +1,13 @@
+# GitHub Copilot Context
+
+This is the default Copilot prompt for this project.
+
+## Project Description
+
+Please describe your project here.
+
+## Guidelines
+
+- Guideline 1
+- Guideline 2
+- Guideline 3

+ 21 - 0
.github/git-commit-instructions.md

@@ -0,0 +1,21 @@
+## Commit message rules
+- Use the conventional commit format: `<type>(<scope>): <description>`
+- Types: feat, fix, docs, style, refactor, test, chore, perf
+- Keep the description concise (under 50 characters)
+- Use imperative mood (e.g., "add" not "added" or "adds")
+- Don't end with a period
+- Use lowercase for the first word unless it's a proper noun
+- Provide more details in the commit body if needed, separated by a blank line
+
+## Branch naming conventions
+- Use kebab-case (lowercase with hyphens)
+- Follow the pattern: `<type>/<issue-number>-<short-description>`
+- Types: feature, bugfix, hotfix, release, support
+- Example: `feature/123-add-dark-mode`
+
+## Pull request guidelines
+- Link related issues using keywords (Fixes #123, Closes #456)
+- Provide a clear description of changes
+- Add screenshots for UI changes
+- Ensure all CI checks pass before requesting review
+- Keep PRs focused and small when possible

+ 1 - 1
composeApp/build.gradle.kts

@@ -236,7 +236,7 @@ kotlin {
 composeResources {
     publicResClass = true
     packageOfResClass = "org.mjdev.desktop.resources"
-    generateResClass = auto
+    generateResClass = always
 }
 
 // android app config

+ 36 - 0
composeApp/src/androidMain/kotlin/org/mjdev/desktop/helpers/persistence/StorageProvider.kt

@@ -0,0 +1,36 @@
+package org.mjdev.desktop.helpers.persistence
+
+import android.content.ContextWrapper
+import android.app.Application
+import org.mjdev.desktop.BuildConfig
+
+@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
+actual object StorageProvider {
+    private val prefs by lazy {
+        ContextWrapper(Application()).getSharedPreferences(BuildConfig.APPLICATION_ID, 0)
+    }
+
+    actual val instance: KeyValueStorage = object : KeyValueStorage {
+        override fun put(
+            key: String,
+            value: String
+        ) {
+            prefs.edit().putString(key, value).apply()
+        }
+
+        override fun get(
+            key: String,
+            default: String?
+        ) = prefs.getString(key, default)
+
+        override fun remove(
+            key: String
+        ) {
+            prefs.edit().remove(key).apply()
+        }
+
+        override fun clear() {
+            prefs.edit().clear().apply()
+        }
+    }
+}

+ 8 - 0
composeApp/src/commonMain/kotlin/org/mjdev/desktop/helpers/persistence/KeyValueStorage.kt

@@ -0,0 +1,8 @@
+package org.mjdev.desktop.helpers.persistence
+
+interface KeyValueStorage {
+    fun put(key: String, value: String)
+    fun get(key: String, default: String? = null): String?
+    fun remove(key: String)
+    fun clear()
+}

+ 6 - 0
composeApp/src/commonMain/kotlin/org/mjdev/desktop/helpers/persistence/StorageProvider.kt

@@ -0,0 +1,6 @@
+package org.mjdev.desktop.helpers.persistence
+
+@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
+expect object StorageProvider {
+    val instance: KeyValueStorage
+}

+ 34 - 0
composeApp/src/desktopMain/kotlin/org/mjdev/desktop/helpers/persistence/StorageProvider.kt

@@ -0,0 +1,34 @@
+package org.mjdev.desktop.helpers.persistence
+
+import java.util.prefs.Preferences
+
+@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
+actual object StorageProvider {
+    private val prefs by lazy {
+        Preferences.userRoot().node("app_prefs") // todo
+    }
+
+    actual val instance: KeyValueStorage = object : KeyValueStorage {
+        override fun put(
+            key: String,
+            value: String
+        ) {
+            prefs.put(key, value)
+        }
+
+        override fun get(
+            key: String,
+            default: String?
+        ) = prefs.get(key, default)
+
+        override fun remove(
+            key: String
+        ) {
+            prefs.remove(key)
+        }
+
+        override fun clear() {
+            prefs.clear()
+        }
+    }
+}

+ 32 - 0
composeApp/src/wasmJsMain/kotlin/org/mjdev/desktop/helpers/persistence/StorageProvider.kt

@@ -0,0 +1,32 @@
+package org.mjdev.desktop.helpers.persistence
+
+@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
+actual object StorageProvider {
+    private val prefs by lazy {
+        HashMap<String, String>() // todo
+    }
+
+    actual val instance: KeyValueStorage = object : KeyValueStorage {
+        override fun put(
+            key: String,
+            value: String
+        ) {
+            prefs[key] = value
+        }
+
+        override fun get(
+            key: String,
+            default: String?
+        ) = prefs.get(key) ?: default
+
+        override fun remove(
+            key: String
+        ) {
+            prefs.remove(key)
+        }
+
+        override fun clear() {
+            prefs.clear()
+        }
+    }
+}