Skip to content

Commit a5f1ac8

Browse files
committed
Finished Task list de tek yöne kayarak silme işlemi sağlandı.
1 parent 10532f2 commit a5f1ac8

File tree

3 files changed

+52
-63
lines changed

3 files changed

+52
-63
lines changed

android/app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ android {
6060
buildTypes {
6161
release {
6262
minifyEnabled true
63+
shrinkResources true
6364
signingConfig signingConfigs.release
6465
}
6566
}

lib/Pages/TaskList.dart

Lines changed: 50 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,7 @@ class _TaskListState extends State<TaskList> {
7777
TextStyle(color: Colors.blue[900], fontWeight: FontWeight.bold),
7878
),
7979
subtitle: task["Time"] != null ? Text(task["Time"]) : null,
80-
trailing: widget.isfinished
81-
? IconButton(
82-
icon: Icon(Icons.delete),
83-
onPressed: () async {
84-
await confirmDialog(task).then((value) {
85-
if (value)
86-
setState(() {
87-
database.deleteTask(task["ID"]);
88-
});
89-
});
90-
})
91-
: Icon(Icons.delete),
80+
trailing: Icon(Icons.delete),
9281
),
9382
);
9483
}
@@ -97,56 +86,55 @@ class _TaskListState extends State<TaskList> {
9786
return tasks.length != 0
9887
? ListView.separated(
9988
itemBuilder: (_, index) {
100-
return widget.isfinished
101-
? listItem(tasks[index])
102-
: Dismissible(
103-
confirmDismiss: (direction) async {
104-
if (direction == DismissDirection.endToStart) {
105-
final bool res = await confirmDialog(tasks[index]);
106-
return res;
107-
} else {
108-
Fluttertoast.showToast(
109-
msg: "Task Finished",
110-
toastLength: Toast.LENGTH_SHORT,
111-
gravity: ToastGravity.BOTTOM,
112-
timeInSecForIosWeb: 1,
113-
backgroundColor: Colors.green,
114-
textColor: Colors.white,
115-
fontSize: 16.0);
116-
return await database
117-
.addTask(tasks[index], isDone: true)
118-
.then((value) => value);
119-
}
120-
},
121-
secondaryBackground: Card(
122-
shape: RoundedRectangleBorder(
123-
borderRadius: BorderRadius.circular(20.0)),
124-
child: Center(
125-
child: Text(
126-
'Delete',
127-
style: TextStyle(
128-
color: Colors.white,
129-
fontWeight: FontWeight.bold),
130-
),
131-
),
132-
color: Colors.red,
133-
),
134-
background: Card(
135-
shape: RoundedRectangleBorder(
136-
borderRadius: BorderRadius.circular(20.0)),
137-
child: Center(
138-
child: Text(
139-
'Move To Finished',
140-
style: TextStyle(
141-
color: Colors.white,
142-
fontWeight: FontWeight.bold),
143-
),
144-
),
145-
color: Colors.green,
146-
),
147-
child: listItem(tasks[index]),
148-
key: UniqueKey(),
149-
);
89+
return Dismissible(
90+
direction: widget.isfinished
91+
? DismissDirection.endToStart
92+
: DismissDirection.horizontal,
93+
confirmDismiss: (direction) async {
94+
if (direction == DismissDirection.endToStart) {
95+
final bool res = await confirmDialog(tasks[index]);
96+
return res;
97+
} else {
98+
Fluttertoast.showToast(
99+
msg: "Task Finished",
100+
toastLength: Toast.LENGTH_SHORT,
101+
gravity: ToastGravity.BOTTOM,
102+
timeInSecForIosWeb: 1,
103+
backgroundColor: Colors.green,
104+
textColor: Colors.white,
105+
fontSize: 16.0);
106+
return await database
107+
.addTask(tasks[index], isDone: true)
108+
.then((value) => value);
109+
}
110+
},
111+
secondaryBackground: Card(
112+
shape: RoundedRectangleBorder(
113+
borderRadius: BorderRadius.circular(20.0)),
114+
child: Center(
115+
child: Text(
116+
'Delete',
117+
style: TextStyle(
118+
color: Colors.white, fontWeight: FontWeight.bold),
119+
),
120+
),
121+
color: Colors.red,
122+
),
123+
background: Card(
124+
shape: RoundedRectangleBorder(
125+
borderRadius: BorderRadius.circular(20.0)),
126+
child: Center(
127+
child: Text(
128+
'Move To Finished',
129+
style: TextStyle(
130+
color: Colors.white, fontWeight: FontWeight.bold),
131+
),
132+
),
133+
color: Colors.green,
134+
),
135+
child: listItem(tasks[index]),
136+
key: UniqueKey(),
137+
);
150138
},
151139
separatorBuilder: (_, index) => Divider(
152140
color: Colors.transparent,

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: A new Flutter application.
44
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
55

66

7-
version: 1.0.1+2
7+
version: 1.0.2+3
88

99
environment:
1010
sdk: ">=2.7.0 <3.0.0"

0 commit comments

Comments
 (0)