loris/lib/business_logic/settings.dart

46 lines
1.2 KiB
Dart
Raw Normal View History

2022-06-30 15:34:09 +00:00
import 'package:shared_preferences/shared_preferences.dart';
import 'package:slothmu/business_logic/auth/oauth.dart';
2022-06-30 15:34:09 +00:00
enum Settings {
instanceUrl,
username,
}
void saveSetting(Settings setting, dynamic value) async {
final prefs = await SharedPreferences.getInstance();
}
Future<bool> saveInstanceUrl(String url) async {
final prefs = await SharedPreferences.getInstance();
2022-07-01 14:14:13 +00:00
return await prefs.setString("instance-url", url);
2022-06-30 15:34:09 +00:00
}
Future<String> loadInstanceUrl() async {
final prefs = await SharedPreferences.getInstance();
String? possibleReturn = prefs.getString("instance-url");
if (possibleReturn == null) {
return "example.com";
} else {
return possibleReturn;
}
}
Future<bool> saveUsername(String username) async {
final prefs = await SharedPreferences.getInstance();
2022-07-01 14:14:13 +00:00
return await prefs.setString("username", username);
}
Future<bool> saveAuthCode(String code) async {
final prefs = await SharedPreferences.getInstance();
return await prefs.setString("authcode", code);
}
Future<String> loadAuthCode() async {
final prefs = await SharedPreferences.getInstance();
String? code = prefs.getString("authcode");
if (code == null) {
return "";
}
return code;
2022-06-30 15:34:09 +00:00
}