feat: initial commit for AeroTrack Flutter app
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class AppSettings {
|
||||
int crossDrugIntervalSeconds; // 两药间隔(默认 5分钟 = 300秒)
|
||||
int inhalationDurationSeconds; // 单次吸入/雾化时间(默认 15秒)
|
||||
int intraPuffIntervalSeconds; // 同药两喷间隔(默认 30秒)
|
||||
int morningReminderHour; // 早间提醒时间 (小时 0-23)
|
||||
int morningReminderMinute; // 早间提醒时间 (分钟 0-59)
|
||||
int eveningReminderHour; // 晚间提醒时间 (小时 0-23)
|
||||
int eveningReminderMinute; // 晚间提醒时间 (分钟 0-59)
|
||||
bool enableSound; // 蜂鸣/音效提示
|
||||
bool enableVibration; // 震动提示
|
||||
bool enableVoicePrompt; // 真人普通话语音播报 ("本次雾化已完成,请及时漱口洗脸")
|
||||
|
||||
AppSettings({
|
||||
this.crossDrugIntervalSeconds = 300, // 默认 5 分钟
|
||||
this.inhalationDurationSeconds = 15, // 默认 15 秒
|
||||
this.intraPuffIntervalSeconds = 30, // 默认 30 秒
|
||||
this.morningReminderHour = 8,
|
||||
this.morningReminderMinute = 0,
|
||||
this.eveningReminderHour = 20,
|
||||
this.eveningReminderMinute = 0,
|
||||
this.enableSound = true,
|
||||
this.enableVibration = true,
|
||||
this.enableVoicePrompt = true,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'crossDrugIntervalSeconds': crossDrugIntervalSeconds,
|
||||
'inhalationDurationSeconds': inhalationDurationSeconds,
|
||||
'intraPuffIntervalSeconds': intraPuffIntervalSeconds,
|
||||
'morningReminderHour': morningReminderHour,
|
||||
'morningReminderMinute': morningReminderMinute,
|
||||
'eveningReminderHour': eveningReminderHour,
|
||||
'eveningReminderMinute': eveningReminderMinute,
|
||||
'enableSound': enableSound,
|
||||
'enableVibration': enableVibration,
|
||||
'enableVoicePrompt': enableVoicePrompt,
|
||||
};
|
||||
}
|
||||
|
||||
factory AppSettings.fromMap(Map<String, dynamic> map) {
|
||||
return AppSettings(
|
||||
crossDrugIntervalSeconds: map['crossDrugIntervalSeconds'] as int? ?? 300,
|
||||
inhalationDurationSeconds: map['inhalationDurationSeconds'] as int? ?? 15,
|
||||
intraPuffIntervalSeconds: map['intraPuffIntervalSeconds'] as int? ?? 30,
|
||||
morningReminderHour: map['morningReminderHour'] as int? ?? 8,
|
||||
morningReminderMinute: map['morningReminderMinute'] as int? ?? 0,
|
||||
eveningReminderHour: map['eveningReminderHour'] as int? ?? 20,
|
||||
eveningReminderMinute: map['eveningReminderMinute'] as int? ?? 0,
|
||||
enableSound: map['enableSound'] as bool? ?? true,
|
||||
enableVibration: map['enableVibration'] as bool? ?? true,
|
||||
enableVoicePrompt: map['enableVoicePrompt'] as bool? ?? true,
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
factory AppSettings.fromJson(String source) =>
|
||||
AppSettings.fromMap(json.decode(source) as Map<String, dynamic>);
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class Canister {
|
||||
final String id;
|
||||
String name; // e.g. "辅舒酮 (丙酸氟替卡松)"
|
||||
final int totalDoses; // e.g. 60
|
||||
int remainingDoses; // e.g. 42
|
||||
DateTime openedAt; // 开瓶日期
|
||||
bool isEnabled; // 是否在当前方案中启用
|
||||
int puffsPerSession; // 每次常规吸几喷 (默认 2)
|
||||
int inhalationSeconds; // 单喷雾化吸入时长 (默认 15秒)
|
||||
final bool isSteroid; // 是否为激素(需提醒漱口洗脸)
|
||||
int sortOrder; // 用药先后顺序 (如舒张剂在前排1,激素在后排2)
|
||||
String? note;
|
||||
|
||||
Canister({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.totalDoses,
|
||||
required this.remainingDoses,
|
||||
required this.openedAt,
|
||||
this.isEnabled = true,
|
||||
this.puffsPerSession = 2,
|
||||
this.inhalationSeconds = 15,
|
||||
this.isSteroid = true,
|
||||
this.sortOrder = 1,
|
||||
this.note,
|
||||
});
|
||||
|
||||
bool get isLowDose => remainingDoses <= 10;
|
||||
bool get isDepleted => remainingDoses <= 0;
|
||||
|
||||
double get percentRemaining =>
|
||||
totalDoses > 0 ? (remainingDoses / totalDoses).clamp(0.0, 1.0) : 0.0;
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'totalDoses': totalDoses,
|
||||
'remainingDoses': remainingDoses,
|
||||
'openedAt': openedAt.toIso8601String(),
|
||||
'isEnabled': isEnabled,
|
||||
'puffsPerSession': puffsPerSession,
|
||||
'inhalationSeconds': inhalationSeconds,
|
||||
'isSteroid': isSteroid,
|
||||
'sortOrder': sortOrder,
|
||||
'note': note,
|
||||
};
|
||||
}
|
||||
|
||||
factory Canister.fromMap(Map<String, dynamic> map) {
|
||||
return Canister(
|
||||
id: map['id'] as String,
|
||||
name: map['name'] as String,
|
||||
totalDoses: map['totalDoses'] as int,
|
||||
remainingDoses: map['remainingDoses'] as int,
|
||||
openedAt: DateTime.parse(map['openedAt'] as String),
|
||||
isEnabled: map['isEnabled'] as bool? ?? true,
|
||||
puffsPerSession: map['puffsPerSession'] as int? ?? 2,
|
||||
inhalationSeconds: map['inhalationSeconds'] as int? ?? 15,
|
||||
isSteroid: map['isSteroid'] as bool? ?? true,
|
||||
sortOrder: map['sortOrder'] as int? ?? 1,
|
||||
note: map['note'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
factory Canister.fromJson(String source) =>
|
||||
Canister.fromMap(json.decode(source) as Map<String, dynamic>);
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class DoseRecord {
|
||||
final String id;
|
||||
final DateTime startTime;
|
||||
final DateTime endTime;
|
||||
final int flixotidePuffs; // 辅舒酮喷数
|
||||
final int ventolinPuffs; // 万托林喷数
|
||||
final bool rinsedMouth; // 是否漱口
|
||||
final bool washedFace; // 是否洗脸
|
||||
final bool isPrime; // 是否为试喷扣除
|
||||
final String? note;
|
||||
|
||||
DoseRecord({
|
||||
required this.id,
|
||||
required this.startTime,
|
||||
required this.endTime,
|
||||
this.flixotidePuffs = 0,
|
||||
this.ventolinPuffs = 0,
|
||||
this.rinsedMouth = true,
|
||||
this.washedFace = true,
|
||||
this.isPrime = false,
|
||||
this.note,
|
||||
});
|
||||
|
||||
Duration get duration => endTime.difference(startTime);
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'id': id,
|
||||
'startTime': startTime.toIso8601String(),
|
||||
'endTime': endTime.toIso8601String(),
|
||||
'flixotidePuffs': flixotidePuffs,
|
||||
'ventolinPuffs': ventolinPuffs,
|
||||
'rinsedMouth': rinsedMouth,
|
||||
'washedFace': washedFace,
|
||||
'isPrime': isPrime,
|
||||
'note': note,
|
||||
};
|
||||
}
|
||||
|
||||
factory DoseRecord.fromMap(Map<String, dynamic> map) {
|
||||
return DoseRecord(
|
||||
id: map['id'] as String,
|
||||
startTime: DateTime.parse(map['startTime'] as String),
|
||||
endTime: DateTime.parse(map['endTime'] as String),
|
||||
flixotidePuffs: map['flixotidePuffs'] as int? ?? 0,
|
||||
ventolinPuffs: map['ventolinPuffs'] as int? ?? 0,
|
||||
rinsedMouth: map['rinsedMouth'] as bool? ?? true,
|
||||
washedFace: map['washedFace'] as bool? ?? true,
|
||||
isPrime: map['isPrime'] as bool? ?? false,
|
||||
note: map['note'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
factory DoseRecord.fromJson(String source) =>
|
||||
DoseRecord.fromMap(json.decode(source) as Map<String, dynamic>);
|
||||
}
|
||||
Reference in New Issue
Block a user