-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.dart
345 lines (272 loc) · 8.97 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:quote/quotes.dart';
void main() => runApp( MaterialApp(
home:HomeScreen()
));
class HomeScreen extends StatefulWidget {
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
@override
int selectionTapCount = 0;
void _onDoubleTap() {
setState(() {
selectionTapCount += 1;
});
// Navigate to the quote screen
if (selectionTapCount == 2) {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => quote()),
).then((value) {
// Reset the selectionTapCount when coming back from the quote screen
if (value == true) {
setState(() {
selectionTapCount = 0;
});
}
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
fit: StackFit.expand,
children: [
Image(
image: NetworkImage(
'https://i.pinimg.com/originals/19/32/4a/19324a087a3ff2fcd50154d9979231c5.gif'),
fit: BoxFit.cover,
),
Opacity(
opacity: 0.9,
child: Container(
color: Colors.black,
),
),
Center(
child: Text(
' N O T E S ',
style: GoogleFonts.rajdhani().copyWith(
fontSize: 50,
fontWeight: FontWeight.bold,
fontStyle: FontStyle.italic,
color: Colors.grey,
letterSpacing: 2,
),
),
),
DoubleTapWidget(onDoubleTap: _onDoubleTap),
],
),
);
}
}
class quote extends StatefulWidget {
@override
State<quote> createState() => _quoteState();
}
class _quoteState extends State<quote> {
List<Quote> quotes =[
Quote(author:'باس',text: 'میں نے سمجھا تھا کہ تو ہے تو درخشاں ہے حیات '
' تیرا غم ہے تو غم زہر کا جھگڑا کیا ہے'
' تیری صورت سے ہے عالم میں بہاروں کو ثبات'
'تیری آنکھوں کے سوا دنیا میں رکھا ہی کیا ہے'
'تُو مل جائے تو تقدیر نگوں ہوجائے'
'یوں نہ تھا'
'میں نے فقط چاہا تھا یوں ہو جائے'
'اور بھی دکھ ہیں زمانے میں محبت کے سوا'
'راحتیں اور بھی ہیں وصل کی راحت کے سوا '),
Quote(author:'باس',text: 'لوگ پوچھتے پھرتے ہیں کہ کون ہے یہ آخر لو سنوں؟ لوگوں کے تلخ رویے کا ستایا ہوا شخص ہو میں گھر کے ہر فرد سے بیکار میں لڑ پڑتا ہو ۔'),
Quote(author:'باس',text: 'لوگ پوچھتے پھرتے ہیں کہ کون ہے یہ آخر لو سنوں؟ لوگوں کے تلخ رویے کا ستایا ہوا شخص ہو میں گھر کے ہر فرد سے بیکار میں لڑ پڑتا ہو ۔'),
];
int selectionTapCount = 0;
void deleteQuote(int index) {
setState(() {
quotes.removeAt(index);
});}
Widget quoteTemplate(Quote quote,VoidCallback onDelete){
return QuoteCard(quote:quote, delete:onDelete);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
//toolbarHeight: MediaQuery.of(context).size.height * 0.07, // 50% of screen height
flexibleSpace: Image(
image:NetworkImage('https://i.pinimg.com/originals/8e/1e/85/8e1e853313ace4ffcf50b56f22f844d4.gif')
,fit:BoxFit.cover,
// height: 100,
// width: 1000,
)
),
body: Stack(
fit: StackFit.expand,
children:[
Container(
width: double.infinity,
height: 512,
//Set your desired height for the image
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(
'https://i.pinimg.com/564x/00/f8/51/00f851b8b4d16616dba717ff5273c350.jpg'),
fit: BoxFit.cover,
colorFilter: ColorFilter.mode(Colors.black.withOpacity(0.5), BlendMode.dstATop),
),
)
,
),
ListView.builder(
itemCount: quotes.length,
itemBuilder: (context, index) {
return quoteTemplate(
quotes[index],
() =>deleteQuote(index),
);
},),
],
//DoubleTapWidget(onDoubleTap: onDoubleTap_),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
// Navigate back to the HomeScreen when the button is pressed
Navigator.push(
context,
MaterialPageRoute(builder: (context) => selection()),
);
},
child: Icon(Icons.dark_mode_outlined),
backgroundColor: Colors.black,
),
);
}
}
class QuoteCard extends StatelessWidget {
final Quote quote;
final void Function() delete;
QuoteCard({required this.quote,required this.delete });
@override
Widget build(BuildContext context) {
return Card(
color:Colors.transparent,
margin: EdgeInsets.fromLTRB(16,16 , 16, 0),
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children:<Widget> [
Align(
alignment: Alignment.topLeft, // Align text to the right
child: Text(
quote.text,
style: TextStyle(
fontSize: 18.0,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
),
SizedBox(height: 0),
Text(
quote.author,
style:TextStyle(
fontSize:14.0,
color:Colors.black,
fontWeight: FontWeight.bold,
)
),
SizedBox(height:2),
FloatingActionButton(
onPressed:delete,
tooltip:'Delete',
child: ColorFiltered(
colorFilter: ColorFilter.mode(Colors.black, BlendMode.srcIn), // Change the color to your desired color
child: Icon(Icons.delete),
),
backgroundColor:Colors.transparent,
elevation: 0,
),
],
),
),
);
}
}
class DoubleTapWidget extends StatefulWidget {
final Function() onDoubleTap;
DoubleTapWidget({required this.onDoubleTap});
@override
State<DoubleTapWidget> createState() => _DoubleTapWidgetState();
}
class _DoubleTapWidgetState extends State<DoubleTapWidget> {
int tapCount = 0;
void _onDoubleTap() {
setState(() {
tapCount += 1;
});
// Navigate to the next page
if (tapCount == 1) {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => quote()),
);
}
}
@override
Widget build(BuildContext context) {
return GestureDetector(
onDoubleTap: _onDoubleTap,
child: Container(
width: 200,
height: 200,
color: Colors.transparent,
child: Container(
width: 100,
height: 100,
color: Colors.transparent, // Just for visibility, you can remove this color
child: Text(
' $tapCount',
),
),
),
);
}
}
class selection extends StatefulWidget {
@override
State<selection> createState() => _selectionState();
}
class _selectionState extends State<selection> {
@override
Widget build(BuildContext context) {
return Scaffold(
/* appBar: AppBar(
backgroundColor:Colors.cyan,
),*/
body:Stack(
fit: StackFit.expand,
children:[
Image(
image:NetworkImage('https://i.pinimg.com/originals/8e/1e/85/8e1e853313ace4ffcf50b56f22f844d4.gif')
,fit:BoxFit.cover,
),
],
),
floatingActionButton: FloatingActionButton(
onPressed: () {
// Navigate back to the HomeScreen when the button is pressed
Navigator.push(
context,
MaterialPageRoute(builder: (context) => HomeScreen()),
);
},
child: Icon(Icons.dark_mode_outlined),
backgroundColor: Colors.black,
),
);
}
}