第一次提交
This commit is contained in:
68
lib/models/class_cookie_entry.dart
Normal file
68
lib/models/class_cookie_entry.dart
Normal file
@@ -0,0 +1,68 @@
|
||||
import 'dart:io';
|
||||
|
||||
class CookieEntry {
|
||||
final String value;
|
||||
final DateTime? expires;
|
||||
final String? path;
|
||||
final String? domain;
|
||||
|
||||
CookieEntry({
|
||||
required this.value,
|
||||
this.expires,
|
||||
this.path,
|
||||
this.domain,
|
||||
});
|
||||
|
||||
factory CookieEntry.fromSetCookie(String raw) {
|
||||
final parts = raw.split(';');
|
||||
final kv = parts[0].split('=');
|
||||
final name = kv[0].trim();
|
||||
final value = kv.length > 1 ? kv.sublist(1).join('=').trim() : '';
|
||||
|
||||
String? path;
|
||||
String? domain;
|
||||
DateTime? expires;
|
||||
|
||||
for (final part in parts.skip(1)) {
|
||||
final kv = part.trim().split('=');
|
||||
final key = kv[0].toLowerCase();
|
||||
final val = kv.length > 1 ? kv.sublist(1).join('=').trim() : '';
|
||||
switch (key) {
|
||||
case 'expires':
|
||||
try {
|
||||
expires = HttpDate.parse(val);
|
||||
} catch (_) {}
|
||||
break;
|
||||
case 'path':
|
||||
path = val;
|
||||
break;
|
||||
case 'domain':
|
||||
domain = val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return CookieEntry(
|
||||
value: value,
|
||||
expires: expires,
|
||||
path: path,
|
||||
domain: domain,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'value': value,
|
||||
'expires': expires?.toIso8601String(),
|
||||
'path': path,
|
||||
'domain': domain,
|
||||
};
|
||||
|
||||
static CookieEntry fromJson(Map<String, dynamic> json) => CookieEntry(
|
||||
value: json['value'],
|
||||
expires: json['expires'] != null ? DateTime.parse(json['expires']) : null,
|
||||
path: json['path'],
|
||||
domain: json['domain'],
|
||||
);
|
||||
|
||||
String toCookieString(String name) => '$name=$value';
|
||||
}
|
15
lib/models/class_destination_item.dart
Normal file
15
lib/models/class_destination_item.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class DestinationItem {
|
||||
final String label;
|
||||
final IconData icon;
|
||||
final Widget child;
|
||||
final String? title; // 可选标题
|
||||
|
||||
const DestinationItem({
|
||||
required this.label,
|
||||
required this.icon,
|
||||
required this.child,
|
||||
this.title,
|
||||
});
|
||||
}
|
22
lib/models/enum_theme.dart
Normal file
22
lib/models/enum_theme.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
enum ThemeModeType {
|
||||
system,
|
||||
light,
|
||||
dark;
|
||||
|
||||
ThemeMode toThemeMode() {
|
||||
switch (this) {
|
||||
case ThemeModeType.system:
|
||||
return ThemeMode.system;
|
||||
case ThemeModeType.light:
|
||||
return ThemeMode.light;
|
||||
case ThemeModeType.dark:
|
||||
return ThemeMode.dark;
|
||||
}
|
||||
}
|
||||
|
||||
static ThemeModeType fromIndex(int index) => ThemeModeType.values[index];
|
||||
}
|
||||
|
20
lib/models/func_animation_route.dart
Normal file
20
lib/models/func_animation_route.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../config.dart';
|
||||
import '../animations/slide.dart';
|
||||
|
||||
GoRoute animationRoute({
|
||||
required String path,
|
||||
required Widget child,
|
||||
}) {
|
||||
return GoRoute(
|
||||
path: path,
|
||||
pageBuilder: (context, state) => CustomTransitionPage(
|
||||
key: state.pageKey,
|
||||
child: child,
|
||||
transitionDuration: AppAnimationConfig.duration,
|
||||
transitionsBuilder: slideTransition,
|
||||
),
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user