feat:增加统计图表模块
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:flisp_app/utils/theme_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class AppProvider with ChangeNotifier {
|
||||
@@ -9,6 +10,9 @@ class AppProvider with ChangeNotifier {
|
||||
int _currentTab = 0;
|
||||
bool _isDarkMode = false;
|
||||
ThemeColor _currentTheme = defaultThemes[0];
|
||||
String _appVersion = '1.0.0';
|
||||
String _buildNumber = '1';
|
||||
|
||||
late SharedPreferences _prefs;
|
||||
bool _isInitialized = false;
|
||||
|
||||
@@ -20,6 +24,8 @@ class AppProvider with ChangeNotifier {
|
||||
Future<void> _initPreferences() async {
|
||||
_prefs = await SharedPreferences.getInstance();
|
||||
_loadPreferences();
|
||||
await _getVersionInfo();
|
||||
|
||||
_isInitialized = true;
|
||||
notifyListeners();
|
||||
}
|
||||
@@ -31,12 +37,18 @@ class AppProvider with ChangeNotifier {
|
||||
// 加载主题色
|
||||
final themeName = _prefs.getString(_themeKey);
|
||||
if (themeName != null) {
|
||||
// 根据主题名称查找对应的主题
|
||||
final savedTheme = defaultThemes.firstWhere(
|
||||
(theme) => theme.name == themeName,
|
||||
orElse: () => defaultThemes[0],
|
||||
);
|
||||
_currentTheme = savedTheme;
|
||||
_currentTheme = getThemeColor(themeName);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _getVersionInfo() async {
|
||||
try {
|
||||
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||
_appVersion = packageInfo.version;
|
||||
_buildNumber = packageInfo.buildNumber;
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
print('获取版本信息失败: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +72,8 @@ class AppProvider with ChangeNotifier {
|
||||
|
||||
bool get isInitialized => _isInitialized;
|
||||
|
||||
String get fullVersion => '$_appVersion+$_buildNumber';
|
||||
|
||||
void changeTab(int index) {
|
||||
_currentTab = index;
|
||||
notifyListeners();
|
||||
@@ -90,4 +104,4 @@ class AppProvider with ChangeNotifier {
|
||||
fontFamily: 'CustomFont',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user