-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from gennadyterekhov/issue-105
issue-105
- Loading branch information
Showing
69 changed files
with
471 additions
and
365 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 |
---|---|---|
|
@@ -45,3 +45,5 @@ app.*.map.json | |
/android/app/debug | ||
/android/app/profile | ||
/android/app/release | ||
|
||
README.local.md |
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,96 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:shared_preferences/shared_preferences.dart'; | ||
import 'package:the_elder_scrolls_alchemy_client/layers/business_logic/services/settings_manager.dart'; | ||
import 'package:the_elder_scrolls_alchemy_client/layers/data/resources/constant.dart'; | ||
import 'package:the_elder_scrolls_alchemy_client/layers/presentation/widgets/app_widget.dart'; | ||
|
||
class TheElderScrollsAlchemyClientApp extends StatefulWidget { | ||
TheElderScrollsAlchemyClientApp({ | ||
Key? key, | ||
required this.settingsManager, | ||
}) : super(key: key); | ||
|
||
SettingsManager settingsManager; | ||
|
||
@deprecated | ||
static Future<String> getSavedGameName() async { | ||
String? gameNameFromPreferences = await getGameNameFromPreferences(); | ||
if (gameNameFromPreferences == null) { | ||
return Constant.fallbackGameName; | ||
} | ||
return gameNameFromPreferences; | ||
} | ||
|
||
@deprecated | ||
static String getLocaleLanguageCode(BuildContext context) { | ||
return Localizations.localeOf(context).languageCode; | ||
} | ||
|
||
@deprecated | ||
static Future<String> getSafeLanguageCode() async { | ||
String? languageCodeFromPreferences = await getLanguageCodeFromPreferences(); | ||
if (languageCodeFromPreferences == null) { | ||
return Constant.fallbackLanguage; | ||
} | ||
return languageCodeFromPreferences; | ||
} | ||
|
||
@deprecated | ||
static Future<String?> getLanguageCodeFromPreferences() async { | ||
final prefs = await SharedPreferences.getInstance(); | ||
final String? languageCode = prefs.getString('languageCode'); | ||
|
||
return languageCode; | ||
} | ||
|
||
@deprecated | ||
static Future<String?> getGameNameFromPreferences() async { | ||
final prefs = await SharedPreferences.getInstance(); | ||
final String? gameName = prefs.getString('gameName'); | ||
|
||
return gameName; | ||
} | ||
|
||
@deprecated | ||
static void setLocaleLanguageCode(BuildContext context, String languageCode) async { | ||
_TheElderScrollsAlchemyClientAppState state = | ||
context.findAncestorStateOfType<_TheElderScrollsAlchemyClientAppState>()!; | ||
state.setLocaleLanguageCode(languageCode); | ||
final prefs = await SharedPreferences.getInstance(); | ||
await prefs.setString('languageCode', languageCode); | ||
} | ||
|
||
@deprecated | ||
static void setGameName(BuildContext context, String gameName) async { | ||
_TheElderScrollsAlchemyClientAppState state = | ||
context.findAncestorStateOfType<_TheElderScrollsAlchemyClientAppState>()!; | ||
state.setGameName(gameName); | ||
final prefs = await SharedPreferences.getInstance(); | ||
await prefs.setString('gameName', gameName); | ||
} | ||
|
||
@override | ||
_TheElderScrollsAlchemyClientAppState createState() => _TheElderScrollsAlchemyClientAppState(); | ||
} | ||
|
||
class _TheElderScrollsAlchemyClientAppState extends State<TheElderScrollsAlchemyClientApp> { | ||
setLocaleLanguageCode(String languageCode) { | ||
setState(() { | ||
// widget.languageCode = languageCode; | ||
}); | ||
} | ||
|
||
setGameName(String gameName) { | ||
setState(() { | ||
// widget.gameName = gameName; | ||
}); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return AppWidget( | ||
languageCode: widget.settingsManager.settings.gameName, | ||
gameName: widget.settingsManager.settings.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,30 @@ | ||
import 'package:flutter_simple_dependency_injection/injector.dart'; | ||
import 'package:the_elder_scrolls_alchemy_client/app.dart'; | ||
import 'package:the_elder_scrolls_alchemy_client/layers/business_logic/services/settings_manager.dart'; | ||
|
||
class DependencyInjectionContainer { | ||
Injector initialise(Injector injector) { | ||
injector.map<SettingsManager>((injector) => SettingsManager(), isSingleton: true); | ||
|
||
injector.map<TheElderScrollsAlchemyClientApp>( | ||
(injector) => TheElderScrollsAlchemyClientApp( | ||
settingsManager: injector.get<SettingsManager>(), | ||
), | ||
isSingleton: true, | ||
); | ||
|
||
// injector.map<Logger>((i) => Logger(), isSingleton: true); | ||
// injector.map<String>((i) => "https://api.com/", key: "apiUrl"); | ||
// injector.map<SomeService>( | ||
// (i) => SomeService(i.get<Logger>(), i.get<String>(key: "apiUrl"))); | ||
|
||
// // note that you can configure mapping in a fluent programming style too | ||
// injector.map<SomeType>((injector) => SomeType("0")) | ||
// ..map<SomeType>((injector) => SomeType("1"), key: "One") | ||
// ..map<SomeType>((injector) => SomeType("2"), key: "Two"); | ||
|
||
// injector.mapWithParams<SomeOtherType>((i, p) => SomeOtherType(p["id"])); | ||
|
||
return injector; | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,20 @@ | ||
import 'package:the_elder_scrolls_alchemy_client/layers/data/resources/constant.dart'; | ||
|
||
class Settings { | ||
Settings({ | ||
required this.gameName, | ||
required this.language, | ||
}); | ||
final String gameName; | ||
final String language; | ||
|
||
factory Settings.fromMap(Map<String, String> data) { | ||
final gameName = data.containsKey('gameName') ? data['gameName'] as String : Constant.fallbackGameName; | ||
final language = data.containsKey('language') ? data['language'] as String : Constant.fallbackLanguage; | ||
|
||
return Settings( | ||
gameName: gameName, | ||
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,10 @@ | ||
import 'package:the_elder_scrolls_alchemy_client/layers/business_logic/models/settings.dart'; | ||
import 'package:the_elder_scrolls_alchemy_client/layers/data/resources/constant.dart'; | ||
|
||
class SettingsManager { | ||
late Settings settings; | ||
|
||
SettingsManager() { | ||
this.settings = Settings(gameName: Constant.fallbackGameName, language: Constant.fallbackLanguage); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
lib/data/constant.dart → lib/layers/data/resources/constant.dart
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
18 changes: 9 additions & 9 deletions
18
lib/data/data_source.dart → lib/layers/data/resources/data_resource.dart
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
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
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
lib/data/l10n/search_indices.dart → ...ers/data/storage/l10n/search_indices.dart
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.