feat:增加删除功能
This commit is contained in:
@@ -167,7 +167,7 @@ class _RecordDailyState extends State<RecordDaily> {
|
||||
} else {
|
||||
switch (provider.type) {
|
||||
case RecordType.weight:
|
||||
provider.updateWeight(70);
|
||||
provider.updateWeight(AppConfig.initWeight);
|
||||
break;
|
||||
case RecordType.sport:
|
||||
provider.updateSportProject(AppConfig.sportProjectList[0]);
|
||||
@@ -189,13 +189,13 @@ class _RecordDailyState extends State<RecordDaily> {
|
||||
padding: EdgeInsets.all(20),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [RecordForm(type: type), _buildDialogButton()],
|
||||
children: [RecordForm(type: type), _buildDialogButton(type)],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDialogButton() {
|
||||
Widget _buildDialogButton(RecordType type) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
|
||||
return Row(
|
||||
@@ -211,6 +211,17 @@ class _RecordDailyState extends State<RecordDaily> {
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: GFButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
_deleteRecord(type);
|
||||
},
|
||||
color: Colors.red,
|
||||
text: "删除",
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: GFButton(
|
||||
onPressed: () {
|
||||
@@ -244,6 +255,25 @@ class _RecordDailyState extends State<RecordDaily> {
|
||||
}
|
||||
}
|
||||
|
||||
void _deleteRecord(RecordType type) async{
|
||||
final provider = context.read<HealthProvider>();
|
||||
|
||||
switch(type) {
|
||||
case RecordType.weight:
|
||||
provider.updateWeight(0);
|
||||
break;
|
||||
case RecordType.sport:
|
||||
provider.updateSportDuration(0);
|
||||
break;
|
||||
case RecordType.sleep:
|
||||
provider.updateSleepStartTime('');
|
||||
provider.updateSleepEndTime('');
|
||||
break;
|
||||
}
|
||||
|
||||
_saveRecord();
|
||||
}
|
||||
|
||||
void _saveRecord() async {
|
||||
final provider = context.read<HealthProvider>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user