feat:增加删除功能
This commit is contained in:
@@ -1,3 +1,13 @@
|
|||||||
|
import java.util.Properties
|
||||||
|
import java.io.FileInputStream
|
||||||
|
|
||||||
|
// 从根路径加载密钥属性
|
||||||
|
val keystoreProperties = Properties()
|
||||||
|
val keystorePropertiesFile = rootProject.file("key.properties")
|
||||||
|
if (keystorePropertiesFile.exists()) {
|
||||||
|
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
|
||||||
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.application")
|
id("com.android.application")
|
||||||
id("kotlin-android")
|
id("kotlin-android")
|
||||||
@@ -30,11 +40,34 @@ android {
|
|||||||
versionName = flutter.versionName
|
versionName = flutter.versionName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
signingConfigs {
|
||||||
|
create("release") {
|
||||||
|
if (keystorePropertiesFile.exists()) {
|
||||||
|
keyAlias = keystoreProperties.getProperty("keyAlias")
|
||||||
|
keyPassword = keystoreProperties.getProperty("keyPassword")
|
||||||
|
storeFile = file(keystoreProperties.getProperty("storeFile"))
|
||||||
|
storePassword = keystoreProperties.getProperty("storePassword")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
debug {
|
||||||
|
signingConfig = if (keystorePropertiesFile.exists()) {
|
||||||
|
signingConfigs.getByName("release")
|
||||||
|
} else {
|
||||||
|
signingConfigs.getByName("debug")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
release {
|
release {
|
||||||
// TODO: Add your own signing config for the release build.
|
signingConfig = if (keystorePropertiesFile.exists()) {
|
||||||
// Signing with the debug keys for now, so `flutter run --release` works.
|
// 使用发布签名
|
||||||
signingConfig = signingConfigs.getByName("debug")
|
signingConfigs.getByName("release")
|
||||||
|
} else {
|
||||||
|
// 使用默认签名
|
||||||
|
signingConfigs.getByName("debug")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ void main() async {
|
|||||||
Hive.registerAdapter(HealthRecordAdapter());
|
Hive.registerAdapter(HealthRecordAdapter());
|
||||||
|
|
||||||
final healthsBox = await Hive.openBox<HealthRecord>('healths');
|
final healthsBox = await Hive.openBox<HealthRecord>('healths');
|
||||||
healthsBox.clear();
|
// healthsBox.clear();
|
||||||
// await Hive.deleteBoxFromDisk('healths');
|
// await Hive.deleteBoxFromDisk('healths');
|
||||||
|
|
||||||
runApp(
|
runApp(
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ class _RecordDailyState extends State<RecordDaily> {
|
|||||||
} else {
|
} else {
|
||||||
switch (provider.type) {
|
switch (provider.type) {
|
||||||
case RecordType.weight:
|
case RecordType.weight:
|
||||||
provider.updateWeight(70);
|
provider.updateWeight(AppConfig.initWeight);
|
||||||
break;
|
break;
|
||||||
case RecordType.sport:
|
case RecordType.sport:
|
||||||
provider.updateSportProject(AppConfig.sportProjectList[0]);
|
provider.updateSportProject(AppConfig.sportProjectList[0]);
|
||||||
@@ -189,13 +189,13 @@ class _RecordDailyState extends State<RecordDaily> {
|
|||||||
padding: EdgeInsets.all(20),
|
padding: EdgeInsets.all(20),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
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;
|
final colors = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
return Row(
|
return Row(
|
||||||
@@ -211,6 +211,17 @@ class _RecordDailyState extends State<RecordDaily> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
|
Expanded(
|
||||||
|
child: GFButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
_deleteRecord(type);
|
||||||
|
},
|
||||||
|
color: Colors.red,
|
||||||
|
text: "删除",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: GFButton(
|
child: GFButton(
|
||||||
onPressed: () {
|
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 {
|
void _saveRecord() async {
|
||||||
final provider = context.read<HealthProvider>();
|
final provider = context.read<HealthProvider>();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user