feat: initial Cutdex application
Add the Flutter video editing application with project management, media import, timeline editing, preview, AI assistance, diagnostics and settings. Include shared UI and native host packages, platform runners, application tests and release tooling. Provide usage and contribution guides, the MIT license and third-party notices. Exclude local credentials, build outputs and validation data.
This commit is contained in:
commit
27e77fff39
718 files changed
+183958
No files matched your search
@@ -0,0 +1,97 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import '../../persistence/settings/language_settings_repository.dart';
|
||||
import '../../settings/language.dart';
|
||||
import '../../settings/settings_write_queue.dart';
|
||||
|
||||
export '../../settings/language.dart';
|
||||
|
||||
part 'language_settings.g.dart';
|
||||
|
||||
extension AppLanguagePresentation on AppLanguage {
|
||||
Locale? get locale => switch (this) {
|
||||
AppLanguage.system => null,
|
||||
AppLanguage.english => const Locale('en'),
|
||||
AppLanguage.simplifiedChinese => const Locale.fromSubtags(
|
||||
languageCode: 'zh',
|
||||
scriptCode: 'Hans',
|
||||
),
|
||||
AppLanguage.traditionalChinese => const Locale.fromSubtags(
|
||||
languageCode: 'zh',
|
||||
scriptCode: 'Hant',
|
||||
),
|
||||
AppLanguage.japanese => const Locale('ja'),
|
||||
AppLanguage.korean => const Locale('ko'),
|
||||
AppLanguage.french => const Locale('fr'),
|
||||
AppLanguage.german => const Locale('de'),
|
||||
AppLanguage.spanish => const Locale('es'),
|
||||
AppLanguage.portuguese => const Locale('pt'),
|
||||
AppLanguage.italian => const Locale('it'),
|
||||
AppLanguage.russian => const Locale('ru'),
|
||||
};
|
||||
|
||||
String get nativeName => switch (this) {
|
||||
AppLanguage.system => '',
|
||||
AppLanguage.english => 'English',
|
||||
AppLanguage.simplifiedChinese => '简体中文',
|
||||
AppLanguage.traditionalChinese => '繁體中文',
|
||||
AppLanguage.japanese => '日本語',
|
||||
AppLanguage.korean => '한국어',
|
||||
AppLanguage.french => 'Français',
|
||||
AppLanguage.german => 'Deutsch',
|
||||
AppLanguage.spanish => 'Español',
|
||||
AppLanguage.portuguese => 'Português',
|
||||
AppLanguage.italian => 'Italiano',
|
||||
AppLanguage.russian => 'Русский',
|
||||
};
|
||||
}
|
||||
|
||||
/// Select a supported language in device preference order, resolving Chinese
|
||||
/// scripts explicitly when the operating system supplies only a region.
|
||||
Locale resolveAppLocale(
|
||||
List<Locale>? preferredLocales,
|
||||
Iterable<Locale> supportedLocales,
|
||||
) {
|
||||
for (final preferred in preferredLocales ?? const <Locale>[]) {
|
||||
if (preferred.languageCode == 'zh') {
|
||||
final script =
|
||||
preferred.scriptCode ??
|
||||
(const {'TW', 'HK', 'MO'}.contains(preferred.countryCode)
|
||||
? 'Hant'
|
||||
: 'Hans');
|
||||
final match = supportedLocales
|
||||
.where(
|
||||
(locale) =>
|
||||
locale.languageCode == 'zh' && locale.scriptCode == script,
|
||||
)
|
||||
.firstOrNull;
|
||||
if (match != null) return match;
|
||||
}
|
||||
final match = supportedLocales
|
||||
.where((locale) => locale.languageCode == preferred.languageCode)
|
||||
.firstOrNull;
|
||||
if (match != null) return match;
|
||||
}
|
||||
return supportedLocales
|
||||
.where((locale) => locale.languageCode == 'en')
|
||||
.firstOrNull ??
|
||||
supportedLocales.first;
|
||||
}
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
class LanguageSettings extends _$LanguageSettings {
|
||||
final _writes = SettingsWriteQueue();
|
||||
|
||||
@override
|
||||
Future<AppLanguage> build() =>
|
||||
ref.watch(languageSettingsRepositoryProvider).load();
|
||||
|
||||
Future<void> setLanguage(AppLanguage language) => _writes.run(() async {
|
||||
if (!ref.mounted) return;
|
||||
await future;
|
||||
if (!ref.mounted) return;
|
||||
await ref.read(languageSettingsRepositoryProvider).save(language);
|
||||
if (ref.mounted) state = AsyncData(language);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user