Add theme persistence and comprehensive Android design guidelines
This commit adds persistent theme storage and comprehensive documentation for Android development. Theme Persistence: - Created ThemeStorage with platform-specific implementations (SharedPreferences/UserDefaults) - Updated ThemeManager.initialize() to load saved theme on app start - Integrated ThemeStorage initialization in MainActivity and MainViewController - Theme selection now persists across app restarts Documentation (CLAUDE.md): - Added comprehensive Android Design System section - Documented all 11 themes and theme management - Provided color system guidelines (use MaterialTheme.colorScheme) - Documented spacing system (AppSpacing/AppRadius constants) - Added standard component usage examples (StandardCard, FormTextField, etc.) - Included screen patterns (Scaffold, pull-to-refresh, lists) - Provided button and dialog patterns - Listed key design principles for Android development Build Status: - ✅ Android builds successfully - ✅ iOS builds successfully - ✅ Theme persistence works on both platforms 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -26,6 +26,9 @@ import com.example.mycrib.storage.TokenManager
|
||||
import com.example.mycrib.storage.TokenStorage
|
||||
import com.example.mycrib.storage.TaskCacheManager
|
||||
import com.example.mycrib.storage.TaskCacheStorage
|
||||
import com.example.mycrib.storage.ThemeStorage
|
||||
import com.example.mycrib.storage.ThemeStorageManager
|
||||
import com.example.mycrib.ui.theme.ThemeManager
|
||||
import com.example.mycrib.fcm.FCMManager
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@@ -42,6 +45,10 @@ class MainActivity : ComponentActivity(), SingletonImageLoader.Factory {
|
||||
// Initialize TaskCacheStorage for offline task caching
|
||||
TaskCacheStorage.initialize(TaskCacheManager.getInstance(applicationContext))
|
||||
|
||||
// Initialize ThemeStorage and ThemeManager
|
||||
ThemeStorage.initialize(ThemeStorageManager.getInstance(applicationContext))
|
||||
ThemeManager.initialize()
|
||||
|
||||
// Handle deep link from intent
|
||||
handleDeepLink(intent)
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.example.mycrib.storage
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
|
||||
/**
|
||||
* Android implementation of theme storage using SharedPreferences.
|
||||
*/
|
||||
actual class ThemeStorageManager(context: Context) {
|
||||
private val prefs: SharedPreferences = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
|
||||
|
||||
actual fun saveThemeId(themeId: String) {
|
||||
prefs.edit().putString(KEY_THEME_ID, themeId).apply()
|
||||
}
|
||||
|
||||
actual fun getThemeId(): String? {
|
||||
return prefs.getString(KEY_THEME_ID, null)
|
||||
}
|
||||
|
||||
actual fun clearThemeId() {
|
||||
prefs.edit().remove(KEY_THEME_ID).apply()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val PREFS_NAME = "mycrib_theme_prefs"
|
||||
private const val KEY_THEME_ID = "theme_id"
|
||||
|
||||
@Volatile
|
||||
private var instance: ThemeStorageManager? = null
|
||||
|
||||
fun getInstance(context: Context): ThemeStorageManager {
|
||||
return instance ?: synchronized(this) {
|
||||
instance ?: ThemeStorageManager(context.applicationContext).also { instance = it }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user