import 'package:flutter/material.dart';
import 'package:riverpod/riverpod.dart';

final themeProvider = StateNotifierProvider<ThemeNotifier, ThemeMode>((ref) {
  return ThemeNotifier();
});

class ThemeNotifier extends StateNotifier<ThemeMode> {
  //这里应该根据用户的SP配置来设置不同的主题，先偷个懒这里我先写死跟随系统的主题
  ThemeNotifier() : super(ThemeMode.system);  //默认 system 主题

  //手动切换主题
  void toggleTheme() {
    if (state == ThemeMode.light) {
      state = ThemeMode.dark;
    } else if (state == ThemeMode.dark) {
      state = ThemeMode.light;
    } else {
      state = ThemeMode.light;
    }
  }
  //跟随系统主题
  void followSystemTheme() {
    state = ThemeMode.system;
  }
}
