Skip to content

Commit a978fb5

Browse files
Merge pull request #1 from MuhammedThajudeen/newbranch
note delete feature bug fixes
2 parents a0d9897 + 8de1560 commit a978fb5

7 files changed

Lines changed: 110 additions & 97 deletions

File tree

devtools_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extensions:

lib/providers/delete_flag.dart

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ class deleteflag extends ChangeNotifier {
44
int _flag=0;
55
int get flag => _flag;
66

7-
List <int>_flaglist =[];
8-
List<int> get flaglist => _flaglist;
7+
// List <int>_flaglist =[];
8+
// List<int> get flaglist => _flaglist;
99

1010
List _notekey = [];
1111
List get notekey => _notekey;
@@ -14,25 +14,25 @@ class deleteflag extends ChangeNotifier {
1414
_flag = newflag;
1515
}
1616

17-
addflaglist (){
18-
_flaglist.add(1);
19-
notifyListeners();
20-
}
17+
// addflaglist (){
18+
// _flaglist.add(1);
19+
// notifyListeners();
20+
// }
2121

22-
deleteflaglist (){
23-
_flaglist.removeLast();
24-
notifyListeners();
25-
}
22+
// deleteflaglist (){
23+
// _flaglist.removeLast();
24+
// notifyListeners();
25+
// }
2626

2727
notekeylist(int key) {
2828
_notekey.contains(key) ? _notekey.remove(key) : _notekey.add(key);
2929
notifyListeners();
3030
}
3131

32-
clearFlagList() {
33-
_flaglist.clear();
34-
notifyListeners();
35-
}
32+
// clearFlagList() {
33+
// _flaglist.clear();
34+
// notifyListeners();
35+
// }
3636

3737
clearNoteKeyList() {
3838
_notekey.clear();

lib/screens/homescreen.dart

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
// ignore_for_file: prefer_const_constructors
21
import 'package:colornotes/models/note.dart';
32
import 'package:colornotes/providers/delete_flag.dart';
43
import 'package:colornotes/screens/noteeditscreen.dart';
5-
import 'package:colornotes/screens/noteviewscreen.dart';
64
import 'package:colornotes/style/appstyle.dart';
75
import 'package:colornotes/widgets/notecard.dart';
86
import 'package:flutter/material.dart';
97
import 'package:google_fonts/google_fonts.dart';
108
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
119
import 'package:hive_flutter/hive_flutter.dart';
12-
import 'package:intl/intl.dart';
1310
import 'package:provider/provider.dart';
1411

1512
class Homescreen extends StatefulWidget {
@@ -28,41 +25,52 @@ class _HomescreenState extends State<Homescreen> {
2825
actions: [
2926
IconButton(
3027
onPressed: () {
28+
final deleteFlagProvider =
29+
Provider.of<deleteflag>(context, listen: false);
3130
showDialog(
3231
context: context,
3332
builder: (BuildContext context) {
3433
return AlertDialog(
35-
title: Text('Delete the selected Notes?'),
34+
title: deleteFlagProvider.notekey.isEmpty
35+
? Text(
36+
'Delete all the Notes?',
37+
style: Appstyle.deletemsgtxtstyle,
38+
)
39+
: Text('Delete the selected Notes?',
40+
style: Appstyle.deletemsgtxtstyle),
3641
actions: [
3742
TextButton(
3843
onPressed: () {
3944
Navigator.pop(context);
4045
},
41-
child: Text('NO')),
46+
child: Text('NO',
47+
style: Appstyle.deletemsgoptionstyle)),
4248
TextButton(
43-
onPressed: () {
44-
final deleteFlagProvider =
45-
Provider.of<deleteflag>(context,
46-
listen: false);
47-
48-
// Retrieve the list of selected note keys
49-
final selectedNoteKeys =
50-
deleteFlagProvider.getSelectedNoteKeys();
51-
print('liss ${selectedNoteKeys}');
49+
onPressed: deleteFlagProvider.notekey.isEmpty
50+
? () {
51+
db.deleteAll(db.keys);
52+
Navigator.pop(context);
53+
}
54+
: () {
55+
// Retrieve the list of selected note keys
56+
final selectedNoteKeys =
57+
deleteFlagProvider
58+
.getSelectedNoteKeys();
5259

53-
// Delete the selected notes using their keys
54-
for (var key in selectedNoteKeys) {
55-
db.delete(key);
56-
}
60+
// Delete the selected notes using their keys
61+
for (var key in selectedNoteKeys) {
62+
db.delete(key);
63+
}
5764

58-
// Clear the flag list and note key list after deletion
59-
deleteFlagProvider.clearFlagList();
60-
deleteFlagProvider.clearNoteKeyList();
65+
// Clear the flag list and note key list after deletion
66+
// deleteFlagProvider.clearFlagList();
67+
deleteFlagProvider.clearNoteKeyList();
6168

62-
Navigator.pop(context);
63-
deleteFlagProvider.flaglist.clear();
64-
},
65-
child: Text('YES'))
69+
Navigator.pop(context);
70+
// deleteFlagProvider.flaglist.clear();
71+
},
72+
child: Text('YES',
73+
style: Appstyle.deletemsgoptionstyle))
6674
],
6775
);
6876
});
@@ -117,9 +125,9 @@ class _HomescreenState extends State<Homescreen> {
117125
builder: (BuildContext context, deleteflag value,
118126
Widget? child) {
119127
return Visibility(
120-
visible: value.flaglist.isNotEmpty,
128+
visible: value.notekey.isNotEmpty,
121129
child: Text(
122-
'(${value.flaglist.length})',
130+
'(${value.notekey.length})',
123131
style: GoogleFonts.roboto(
124132
color: Colors.white,
125133
fontWeight: FontWeight.bold,
@@ -152,7 +160,7 @@ class _HomescreenState extends State<Homescreen> {
152160
onPressed: () {
153161
final deleteFlagProvider =
154162
Provider.of<deleteflag>(context, listen: false);
155-
deleteFlagProvider.clearFlagList();
163+
// deleteFlagProvider.clearFlagList();
156164
deleteFlagProvider.clearNoteKeyList();
157165
Navigator.push(
158166
context, MaterialPageRoute(builder: (context) => NoteEdit()));

lib/screens/noteeditscreen.dart

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables, no_logic_in_create_state
2-
31
import 'dart:math';
4-
52
import 'package:colornotes/style/appstyle.dart';
63
import 'package:flutter/material.dart';
74
import 'package:colornotes/models/note.dart';
@@ -40,16 +37,16 @@ class _NoteEditState extends State<NoteEdit> {
4037
onPressed: () {
4138
handlebackbutton();
4239
},
43-
icon: Icon(Icons.arrow_back)),
40+
icon: const Icon(Icons.arrow_back)),
4441
elevation: 5,
4542
backgroundColor: Appstyle.cardcolor[colorindexx],
46-
iconTheme: IconThemeData(color: Colors.black),
43+
iconTheme: const IconThemeData(color: Colors.black),
4744
title: Text(
4845
'Add a new Note',
49-
style: TextStyle(color: Colors.black),
46+
style: Appstyle.notescreenheadingtextstyle,
5047
)),
5148
body: Padding(
52-
padding: EdgeInsets.all(16),
49+
padding: const EdgeInsets.all(16),
5350
child: Column(
5451
mainAxisSize: MainAxisSize.max,
5552
children: [
@@ -64,7 +61,7 @@ class _NoteEditState extends State<NoteEdit> {
6461
hintStyle: Appstyle.titletext,
6562
border: InputBorder.none),
6663
),
67-
SizedBox(
64+
const SizedBox(
6865
height: 6,
6966
),
7067
Expanded(

lib/screens/noteviewscreen.dart

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// ignore_for_file: prefer_const_constructors, no_logic_in_create_state
2-
31
import 'package:colornotes/style/appstyle.dart';
42
import 'package:flutter/material.dart';
53
import 'package:colornotes/models/note.dart';
@@ -54,41 +52,44 @@ class _NoteViewState extends State<NoteView> {
5452
context: context,
5553
builder: (BuildContext context) {
5654
return AlertDialog(
57-
title: Text('Are you sure want to delete?'),
55+
title: Text(
56+
'Are you sure want to delete?',
57+
style: Appstyle.deletemsgtxtstyle,
58+
),
5859
actions: [
5960
TextButton(
6061
onPressed: () {
6162
Navigator.pop(context);
6263
},
63-
child: Text('NO')),
64+
child: Text('NO',style: Appstyle.deletemsgoptionstyle)),
6465
TextButton(
6566
onPressed: () {
6667
db.delete(note.key);
6768
Navigator.pop(context);
6869
Navigator.pop(context);
6970
},
70-
child: Text('YES'))
71+
child: Text('YES',style: Appstyle.deletemsgoptionstyle))
7172
],
7273
);
7374
});
7475
},
75-
icon: Icon(Icons.delete))
76+
icon: const Icon(Icons.delete))
7677
],
7778
centerTitle: true,
7879
leading: IconButton(
7980
onPressed: () {
8081
handlebackbutton();
8182
},
82-
icon: Icon(Icons.arrow_back)),
83+
icon: const Icon(Icons.arrow_back)),
8384
elevation: 5,
8485
backgroundColor: Appstyle.cardcolor[note.colorIndex],
85-
iconTheme: IconThemeData(color: Colors.black),
86+
iconTheme: const IconThemeData(color: Colors.black),
8687
title: Text(
8788
'Your Note',
88-
style: TextStyle(color: Colors.black),
89+
style: Appstyle.notescreenheadingtextstyle,
8990
)),
9091
body: Padding(
91-
padding: EdgeInsets.all(16),
92+
padding: const EdgeInsets.all(16),
9293
child: Column(
9394
crossAxisAlignment: CrossAxisAlignment.start,
9495
children: [
@@ -102,14 +103,14 @@ class _NoteViewState extends State<NoteView> {
102103
controller: _titlecontroller,
103104
style: Appstyle.titletext,
104105
),
105-
SizedBox(
106+
const SizedBox(
106107
height: 2,
107108
),
108109
Text(
109110
'Edited ${DateFormat("dd MMM yyyy").format(note.datentime)}',
110-
style: TextStyle(fontSize: 13),
111+
style: const TextStyle(fontSize: 13),
111112
),
112-
SizedBox(height: 6),
113+
const SizedBox(height: 6),
113114
Expanded(
114115
child: TextField(
115116
maxLines: null,

lib/style/appstyle.dart

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// ignore_for_file: prefer_const_constructors
2-
31
import 'dart:math';
42

53
import 'package:flutter/material.dart';
@@ -14,27 +12,34 @@ class Appstyle {
1412
}
1513

1614
static List cardcolor = [
17-
Color(0xfff8c5d8),
18-
Color(0xfff7a7aa),
19-
Color(0xfffaf0bc),
20-
Color(0xfff5f6cc),
21-
Color(0xffd1e8cb),
22-
Color(0xffeaf3de),
23-
Color(0xffc5e7e9),
24-
Color(0xff88d5f1),
25-
Color(0xff76aedd),
26-
Color(0xffd5cfe7),
27-
Color(0xff9d93c7),
28-
Color(0xffc6a7d0),
29-
Color(0xffefdded),
30-
Color(0xffd7a5cb),
31-
Color(0xffe8c5dd),
32-
Color(0xff81d0d4),
15+
const Color(0xfff8c5d8),
16+
const Color(0xfff7a7aa),
17+
const Color(0xfffaf0bc),
18+
const Color(0xfff5f6cc),
19+
const Color(0xffd1e8cb),
20+
const Color(0xffeaf3de),
21+
const Color(0xffc5e7e9),
22+
const Color(0xff88d5f1),
23+
const Color(0xff76aedd),
24+
const Color(0xffd5cfe7),
25+
const Color(0xff9d93c7),
26+
const Color(0xffc6a7d0),
27+
const Color(0xffefdded),
28+
const Color(0xffd7a5cb),
29+
const Color(0xffe8c5dd),
30+
const Color(0xff81d0d4),
3331
];
3432

3533
static TextStyle maintext =
3634
GoogleFonts.dynaPuff(fontSize: 20, color: Colors.white);
3735
static TextStyle titletext =
3836
GoogleFonts.ubuntu(fontSize: 18, fontWeight: FontWeight.w600);
39-
static TextStyle contenttext = GoogleFonts.nunito(fontSize: 16);
37+
static TextStyle contenttext =
38+
GoogleFonts.nunito(fontSize: 16);
39+
static TextStyle notescreenheadingtextstyle =
40+
GoogleFonts.poppins(fontSize: 18,color: Colors.black,fontWeight: FontWeight.w600);
41+
static TextStyle deletemsgtxtstyle =
42+
GoogleFonts.poppins(fontSize: 17,color: Colors.black,fontWeight: FontWeight.w600);
43+
static TextStyle deletemsgoptionstyle =
44+
GoogleFonts.poppins(fontSize: 14,color: Colors.black,fontWeight: FontWeight.w600);
4045
}

0 commit comments

Comments
 (0)