2024-05-20 15:15:09 +08:00
|
|
|
import 'package:fl_clash/common/common.dart';
|
2024-04-30 23:38:49 +08:00
|
|
|
import 'package:fl_clash/enum/enum.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
2025-02-09 18:39:38 +08:00
|
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
2024-12-03 21:47:12 +08:00
|
|
|
|
2024-09-08 21:21:21 +08:00
|
|
|
import 'common.dart';
|
2024-12-03 21:47:12 +08:00
|
|
|
import 'core.dart';
|
2024-04-30 23:38:49 +08:00
|
|
|
|
2025-02-09 18:39:38 +08:00
|
|
|
part 'generated/app.freezed.dart';
|
2024-05-10 10:11:27 +08:00
|
|
|
|
2025-02-09 18:39:38 +08:00
|
|
|
typedef DelayMap = Map<String, Map<String, int?>>;
|
2024-04-30 23:38:49 +08:00
|
|
|
|
2025-02-09 18:39:38 +08:00
|
|
|
@freezed
|
|
|
|
|
class AppState with _$AppState {
|
|
|
|
|
const factory AppState({
|
|
|
|
|
@Default(false) bool isInit,
|
|
|
|
|
@Default(PageLabel.dashboard) PageLabel pageLabel,
|
|
|
|
|
@Default([]) List<Package> packages,
|
|
|
|
|
@Default(ColorSchemes()) ColorSchemes colorSchemes,
|
|
|
|
|
@Default(0) int sortNum,
|
|
|
|
|
required double viewWidth,
|
|
|
|
|
@Default({}) DelayMap delayMap,
|
|
|
|
|
@Default([]) List<Group> groups,
|
|
|
|
|
@Default(0) int checkIpNum,
|
|
|
|
|
Brightness? brightness,
|
|
|
|
|
int? runTime,
|
|
|
|
|
@Default([]) List<ExternalProvider> providers,
|
|
|
|
|
String? localIp,
|
|
|
|
|
required FixedList<Connection> requests,
|
2024-09-08 21:21:21 +08:00
|
|
|
required int version,
|
2025-02-09 18:39:38 +08:00
|
|
|
required FixedList<Log> logs,
|
|
|
|
|
required FixedList<Traffic> traffics,
|
|
|
|
|
required Traffic totalTraffic,
|
|
|
|
|
}) = _AppState;
|
2024-04-30 23:38:49 +08:00
|
|
|
}
|
2024-09-18 10:27:53 +08:00
|
|
|
|
2025-02-09 18:39:38 +08:00
|
|
|
extension AppStateExt on AppState {
|
|
|
|
|
ViewMode get viewMode => other.getViewMode(viewWidth);
|
2024-12-09 01:40:39 +08:00
|
|
|
|
2025-02-09 18:39:38 +08:00
|
|
|
bool get isStart => runTime != null;
|
2024-09-18 10:27:53 +08:00
|
|
|
}
|