Skip to content

Commit 433c921

Browse files
committed
Add showAlertDialog to Clear all data
1 parent a0dac7f commit 433c921

File tree

4 files changed

+65
-19
lines changed

4 files changed

+65
-19
lines changed

android/app/build.gradle

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,24 @@ if (flutterRoot == null) {
1313

1414
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
1515
if (flutterVersionCode == null) {
16-
flutterVersionCode = '1'
16+
flutterVersionCode = '2'
1717
}
1818

1919
def flutterVersionName = localProperties.getProperty('flutter.versionName')
2020
if (flutterVersionName == null) {
21-
flutterVersionName = '1.0'
21+
flutterVersionName = '2.0.0'
2222
}
2323

2424
apply plugin: 'com.android.application'
2525
apply plugin: 'kotlin-android'
2626
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2727

28+
def keystoreProperties = new Properties()
29+
def keystorePropertiesFile = rootProject.file('key.properties')
30+
if (keystorePropertiesFile.exists()) {
31+
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
32+
}
33+
2834
android {
2935
compileSdkVersion 30
3036

@@ -38,18 +44,25 @@ android {
3844

3945
defaultConfig {
4046
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
41-
applicationId "com.nintox.task_manager"
47+
applicationId "bornomala.todo"
4248
minSdkVersion 16
4349
targetSdkVersion 30
4450
versionCode flutterVersionCode.toInteger()
4551
versionName flutterVersionName
4652
}
4753

54+
55+
signingConfigs {
56+
release {
57+
keyAlias keystoreProperties['keyAlias']
58+
keyPassword keystoreProperties['keyPassword']
59+
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
60+
storePassword keystoreProperties['storePassword']
61+
}
62+
}
4863
buildTypes {
4964
release {
50-
// TODO: Add your own signing config for the release build.
51-
// Signing with the debug keys for now, so `flutter run --release` works.
52-
signingConfig signingConfigs.debug
65+
signingConfig signingConfigs.release
5366
}
5467
}
5568
}

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ buildscript {
66
}
77

88
dependencies {
9-
classpath 'com.android.tools.build:gradle:3.5.0'
9+
classpath 'com.android.tools.build:gradle:3.5.4'
1010
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1111
}
1212
}

lib/screens/settings_screen.dart

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,46 @@ class Settings extends StatefulWidget {
1010
_SettingsState createState() => _SettingsState();
1111
}
1212

13+
showAlertDialog(BuildContext context) async {
14+
15+
// set up the buttons
16+
// ignore: deprecated_member_use
17+
Widget cancelButton = FlatButton(
18+
child: Text("Cancel"),
19+
onPressed: () {Navigator.pop(context);},
20+
);
21+
// ignore: deprecated_member_use
22+
Widget continueButton = FlatButton(
23+
child: Text("OK"),
24+
onPressed: () {
25+
DatabaseHelper.instance.deleteAllTask();
26+
Navigator.push(
27+
context,
28+
MaterialPageRoute(
29+
builder: (_) => HomeScreen()));
30+
Toast.show("All data cleared", context,
31+
duration: Toast.LENGTH_LONG,
32+
gravity: Toast.BOTTOM);},
33+
);
34+
35+
// set up the AlertDialog
36+
AlertDialog alert = AlertDialog(
37+
content: Text("Would you like to clear all data? It cannot be undone."),
38+
actions: [
39+
cancelButton,
40+
continueButton,
41+
],
42+
);
43+
44+
// show the dialog
45+
showDialog(
46+
context: context,
47+
builder: (BuildContext context) {
48+
return alert;
49+
},
50+
);
51+
}
52+
1353
class _SettingsState extends State<Settings> {
1454
@override
1555
Widget build(BuildContext context) {
@@ -69,7 +109,7 @@ class _SettingsState extends State<Settings> {
69109
top: 5.0, left: 25.0, right: 20.0, bottom: 60.0),
70110
child: new Container(
71111
alignment: Alignment.center,
72-
child: new Text("Version: 1.0",
112+
child: new Text("Version: 2.0.0",
73113
style:
74114
new TextStyle(fontSize: 12.0, color: Colors.grey))),
75115
),
@@ -89,14 +129,7 @@ class _SettingsState extends State<Settings> {
89129
top: 30.0, left: 40.0, right: 20.0, bottom: 30.0),
90130
child: GestureDetector(
91131
onTap: () {
92-
DatabaseHelper.instance.deleteAllTask();
93-
Navigator.push(
94-
context,
95-
MaterialPageRoute(
96-
builder: (_) => HomeScreen()));
97-
Toast.show("All data cleared", context,
98-
duration: Toast.LENGTH_LONG,
99-
gravity: Toast.BOTTOM);
132+
showAlertDialog(context);
100133
},
101134
child: new Container(
102135
alignment: Alignment.center,
@@ -131,7 +164,7 @@ class _SettingsState extends State<Settings> {
131164
color: Colors.brown,
132165
backgroundColor: Colors.transparent),
133166
),
134-
onTap: () => launch('https://bornomala-tech.web.app/terms'),
167+
onTap: () => launch('https://bornomala-tech.web.app/policies'),
135168
),
136169
),
137170
),
@@ -149,7 +182,7 @@ class _SettingsState extends State<Settings> {
149182
backgroundColor: Colors.transparent),
150183
),
151184
onTap: () =>
152-
launch('https://bornomala-tech.web.app/privacy'),
185+
launch('https://bornomala-tech.web.app/policies'),
153186
),
154187
),
155188
),

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
1515
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
1616
# Read more about iOS versioning at
1717
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
18-
version: 1.0.0+1
18+
version: 2.0.0+2
1919

2020
environment:
2121
sdk: ">=2.7.0 <3.0.0"

0 commit comments

Comments
 (0)