-
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.
refactor(frontend): Use TaggerPage to fix GetView issues
* This assures we don't end up without a controller instance (get loses it somehow) * Also added theme persistence
- Loading branch information
Showing
16 changed files
with
104 additions
and
75 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
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,45 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:shared_preferences/shared_preferences.dart'; | ||
|
||
const _themeModePref = 'THEME_MODE'; | ||
|
||
final taggerPreferences = _TaggerPreferences(); | ||
|
||
class _TaggerPreferences { | ||
SharedPreferences _sharedInstance; | ||
|
||
Future init() async { | ||
_sharedInstance = await SharedPreferences.getInstance(); | ||
} | ||
|
||
ThemeMode themeMode() { | ||
final mode = _sharedInstance.getString(_themeModePref); | ||
|
||
if (mode == 'dark') { | ||
return ThemeMode.dark; | ||
} | ||
|
||
if (mode == 'light') { | ||
return ThemeMode.light; | ||
} | ||
|
||
return ThemeMode.system; | ||
} | ||
|
||
Future setThemeMode(ThemeMode mode) async { | ||
String modeString; | ||
switch (mode) { | ||
case ThemeMode.system: | ||
modeString = 'system'; | ||
break; | ||
case ThemeMode.light: | ||
modeString = 'light'; | ||
break; | ||
case ThemeMode.dark: | ||
modeString = 'dark'; | ||
break; | ||
} | ||
|
||
await _sharedInstance.setString(_themeModePref, modeString); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
12 changes: 0 additions & 12 deletions
12
frontend/lib/ui/pages/repository_details/repository_details_bindings.dart
This file was deleted.
Oops, something went wrong.
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
7 changes: 5 additions & 2 deletions
7
frontend/lib/ui/pages/repository_details/widgets/tags_container.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 was deleted.
Oops, something went wrong.
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
9 changes: 0 additions & 9 deletions
9
frontend/lib/ui/pages/tag_repositories/tag_repositories_bindings.dart
This file was deleted.
Oops, something went wrong.
8 changes: 5 additions & 3 deletions
8
frontend/lib/ui/pages/tag_repositories/tag_repositories_page.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 was deleted.
Oops, something went wrong.
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,12 @@ | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:get/get.dart'; | ||
|
||
/// Similar to GetView but this one forces a controller instance to be present | ||
/// (get loses itself sometimes) | ||
abstract class TaggerPage<T> extends StatelessWidget { | ||
const TaggerPage({Key key}) : super(key: key); | ||
|
||
T provider(); | ||
|
||
T get controller => Get.put<T>(provider()); | ||
} |