Files
FlClash/lib/models/app.dart
T

47 lines
1.4 KiB
Dart
Raw Normal View History

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';
2025-06-07 01:48:34 +08:00
import 'package:flutter/services.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';
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
2025-07-31 17:09:18 +08:00
abstract class AppState with _$AppState {
2025-02-09 18:39:38 +08:00
const factory AppState({
@Default(false) bool isInit,
2025-05-02 02:24:12 +08:00
@Default(false) bool backBlock,
2025-02-09 18:39:38 +08:00
@Default(PageLabel.dashboard) PageLabel pageLabel,
@Default([]) List<Package> packages,
@Default(0) int sortNum,
2025-03-12 17:15:31 +08:00
required Size viewSize,
2025-07-31 17:09:18 +08:00
@Default(0) double sideWidth,
2025-02-09 18:39:38 +08:00
@Default({}) DelayMap delayMap,
@Default([]) List<Group> groups,
@Default(0) int checkIpNum,
2025-06-07 01:48:34 +08:00
required Brightness brightness,
2025-02-09 18:39:38 +08:00
int? runTime,
@Default([]) List<ExternalProvider> providers,
String? localIp,
2025-06-07 01:48:34 +08:00
required FixedList<TrackerInfo> 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,
2025-05-02 02:24:12 +08:00
@Default(false) bool realTunEnable,
2025-06-07 01:48:34 +08:00
@Default(false) bool loading,
required SystemUiOverlayStyle systemUiOverlayStyle,
2025-07-31 17:09:18 +08:00
@Default(CoreStatus.connecting) CoreStatus coreStatus,
2025-02-09 18:39:38 +08:00
}) = _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 {
2025-04-09 16:46:14 +08:00
ViewMode get viewMode => utils.getViewMode(viewSize.width);
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
}