-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
1,034 additions
and
876 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"appTitle": "RustSend", | ||
"home": { | ||
"title": "Home Page" | ||
}, | ||
"setting": { | ||
"title": "Settings", | ||
"brightness": { | ||
"title": "Brightness", | ||
"subTitle": "Current mode: $mode", | ||
"themeMode": { | ||
"system": "Follow system", | ||
"light": "Light mode", | ||
"dark": "Dark mode" | ||
} | ||
}, | ||
"language": { | ||
"title": "Language", | ||
"subTitle": "Current language: $language" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"appTitle": "锈船", | ||
"home": { | ||
"title": "主页" | ||
}, | ||
"setting": { | ||
"title": "设置", | ||
"brightness": { | ||
"title": "明暗", | ||
"subTitle": "当前模式: $mode", | ||
"themeMode": { | ||
"system": "跟随系统", | ||
"light": "浅色模式", | ||
"dark": "深色模式" | ||
} | ||
}, | ||
"language": { | ||
"title": "语言", | ||
"subTitle": "当前语言: $language" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
targets: | ||
$default: | ||
builders: | ||
slang_build_runner: | ||
options: | ||
input_directory: assets/i18n | ||
output_directory: lib/i18n # defaulting to lib/gen if input is outside of lib/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
rust_input: rust/src/bridge/**/*.rs | ||
dart_output: lib/src/rust | ||
dart_output: lib/rust |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Language { | ||
final String name; | ||
final String localeName; | ||
|
||
const Language(this.name, this.localeName); | ||
} | ||
|
||
const Map<String, Language> supportLanguages = { | ||
"zh": Language("中文", "zh"), | ||
"en": Language("English", "en"), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:shared_preferences/shared_preferences.dart'; | ||
|
||
class ConfigStore { | ||
static ConfigStore? _instance; | ||
static SharedPreferences? _prefs; | ||
|
||
factory ConfigStore() { | ||
if (_instance == null) { | ||
throw Exception('AppSharedPrefs is not initialized. ' | ||
'Please call AppSharedPrefs.ensureInitialized before.'); | ||
} | ||
return _instance!; | ||
} | ||
|
||
const ConfigStore._(); | ||
|
||
static ensureInitialized() async { | ||
_prefs ??= await SharedPreferences.getInstance(); | ||
_instance ??= const ConfigStore._(); | ||
} | ||
|
||
static const _themeKey = 'theme'; | ||
static const _localeKey = 'locale'; | ||
|
||
ThemeMode themeMode() { | ||
final themeValue = _prefs!.getInt(_themeKey); | ||
if (themeValue == null) return ThemeMode.system; | ||
|
||
return ThemeMode.values[themeValue]; | ||
} | ||
|
||
Future<void> updateThemeMode(ThemeMode theme) async { | ||
await _prefs!.setInt(_themeKey, theme.index); | ||
} | ||
|
||
String locale() { | ||
final localeValue = _prefs!.getString(_localeKey) ?? Platform.localeName; | ||
return localeValue; | ||
} | ||
|
||
Future<void> updateLocale(String locale) async { | ||
await _prefs!.setString(_localeKey, locale); | ||
} | ||
} |
Oops, something went wrong.