@@ -9,6 +9,7 @@ import 'package:lottie/lottie.dart';
9
9
import 'package:text_to_image_gen/Pages/settings_page.dart' ;
10
10
import 'package:text_to_image_gen/bloc/image_cubit.dart' ;
11
11
import 'package:path/path.dart' as xp;
12
+ import 'package:text_to_image_gen/utils/app_language.dart' ;
12
13
13
14
import '../bloc/app_directory_cubit.dart' ;
14
15
import '../utils/strings.dart' ;
@@ -61,7 +62,8 @@ class _HomePageState extends State<HomePage> {
61
62
await file.writeAsBytes (canvas).whenComplete (() {
62
63
ScaffoldMessenger .of (context).showSnackBar (
63
64
SnackBar (
64
- content: Text ('Image was Downloaded in $filePath ' ),
65
+ content:
66
+ Text ('${translation (context ).imageWasSaved } : $filePath ' ),
65
67
elevation: 10 ,
66
68
),
67
69
);
@@ -127,6 +129,9 @@ class _HomePageState extends State<HomePage> {
127
129
FocusScope .of (context).unfocus ();
128
130
}
129
131
scaffoldKey.currentState? .openDrawer ();
132
+ if (FocusScope .of (context).hasFocus) {
133
+ FocusScope .of (context).unfocus ();
134
+ }
130
135
},
131
136
child: Icon (
132
137
Iconsax .element_plus,
@@ -173,8 +178,10 @@ class _HomePageState extends State<HomePage> {
173
178
autofocus: false ,
174
179
controller: _textEditingController,
175
180
decoration: InputDecoration (
176
- hintText: "Enter Anything in Your Mind" ,
177
- labelText: "Enter Anything in Your Mind" ,
181
+ hintText:
182
+ translation (context).putAnythingInYourMind,
183
+ labelText:
184
+ translation (context).putAnythingInYourMind,
178
185
border: const OutlineInputBorder (),
179
186
suffixIcon: IconButton (
180
187
onPressed: () {
@@ -237,7 +244,7 @@ class _HomePageState extends State<HomePage> {
237
244
padding: EdgeInsets .symmetric (vertical: 14.0 ),
238
245
child: Icon (
239
246
Icons .gesture,
240
- size: 30 ,
247
+ size: 32 ,
241
248
),
242
249
),
243
250
),
@@ -250,18 +257,28 @@ class _HomePageState extends State<HomePage> {
250
257
builder: (context, state) {
251
258
if (state is ImageLoading ) {
252
259
return Center (
253
- child: SizedBox (
254
- height: 300 ,
255
- width: 300 ,
256
- child: Padding (
257
- padding: const EdgeInsets .all (100 ),
258
- child: Lottie .asset (
259
- 'assets/animations/loading.json' ,
260
- frameRate: FrameRate (120 ),
261
- repeat: true ,
262
- animate: true ,
260
+ child: Column (
261
+ mainAxisAlignment: MainAxisAlignment .center,
262
+ crossAxisAlignment: CrossAxisAlignment .center,
263
+ children: [
264
+ SizedBox (
265
+ height: 300 ,
266
+ width: 300 ,
267
+ child: Padding (
268
+ padding: const EdgeInsets .all (100 ),
269
+ child: Lottie .asset (
270
+ 'assets/animations/loading.json' ,
271
+ frameRate: FrameRate (120 ),
272
+ repeat: true ,
273
+ animate: true ,
274
+ ),
275
+ ),
263
276
),
264
- ),
277
+ Text (
278
+ translation (context).loading,
279
+ style: const TextStyle (fontSize: 18 ),
280
+ )
281
+ ],
265
282
),
266
283
);
267
284
}
@@ -329,7 +346,7 @@ class _HomePageState extends State<HomePage> {
329
346
),
330
347
child: Center (
331
348
child: Text (
332
- 'Download' ,
349
+ translation (context).download ,
333
350
style: TextStyle (
334
351
color: Theme .of (context)
335
352
.colorScheme
@@ -356,16 +373,6 @@ class _HomePageState extends State<HomePage> {
356
373
mainAxisAlignment: MainAxisAlignment .spaceEvenly,
357
374
crossAxisAlignment: CrossAxisAlignment .center,
358
375
children: [
359
- SizedBox (
360
- width:
361
- MediaQuery .of (context).size.height * 0.7 ,
362
- child: FadeInImage (
363
- placeholder: const AssetImage (
364
- 'assets/images/Ai.webp' ),
365
- image: MemoryImage (image),
366
- fit: BoxFit .contain,
367
- ),
368
- ),
369
376
Padding (
370
377
padding: const EdgeInsets .all (10 ),
371
378
child: InkWell (
@@ -407,7 +414,7 @@ class _HomePageState extends State<HomePage> {
407
414
),
408
415
child: Center (
409
416
child: Text (
410
- 'Download' ,
417
+ translation (context).download ,
411
418
style: TextStyle (
412
419
color: Theme .of (context)
413
420
.colorScheme
@@ -424,6 +431,16 @@ class _HomePageState extends State<HomePage> {
424
431
),
425
432
),
426
433
),
434
+ SizedBox (
435
+ width:
436
+ MediaQuery .of (context).size.height * 0.7 ,
437
+ child: FadeInImage (
438
+ placeholder: const AssetImage (
439
+ 'assets/images/Ai.webp' ),
440
+ image: MemoryImage (image),
441
+ fit: BoxFit .contain,
442
+ ),
443
+ ),
427
444
],
428
445
),
429
446
);
@@ -437,16 +454,6 @@ class _HomePageState extends State<HomePage> {
437
454
mainAxisAlignment: MainAxisAlignment .spaceEvenly,
438
455
crossAxisAlignment: CrossAxisAlignment .center,
439
456
children: [
440
- SizedBox (
441
- width:
442
- MediaQuery .of (context).size.height * 0.7 ,
443
- child: FadeInImage (
444
- placeholder: const AssetImage (
445
- 'assets/images/Ai.webp' ),
446
- image: MemoryImage (image),
447
- fit: BoxFit .contain,
448
- ),
449
- ),
450
457
Padding (
451
458
padding: const EdgeInsets .all (10 ),
452
459
child: InkWell (
@@ -488,7 +495,7 @@ class _HomePageState extends State<HomePage> {
488
495
),
489
496
child: Center (
490
497
child: Text (
491
- 'Download' ,
498
+ translation (context).download ,
492
499
style: TextStyle (
493
500
color: Theme .of (context)
494
501
.colorScheme
@@ -505,6 +512,16 @@ class _HomePageState extends State<HomePage> {
505
512
),
506
513
),
507
514
),
515
+ SizedBox (
516
+ width:
517
+ MediaQuery .of (context).size.height * 0.7 ,
518
+ child: FadeInImage (
519
+ placeholder: const AssetImage (
520
+ 'assets/images/Ai.webp' ),
521
+ image: MemoryImage (image),
522
+ fit: BoxFit .contain,
523
+ ),
524
+ ),
508
525
],
509
526
),
510
527
);
@@ -568,7 +585,7 @@ class _HomePageState extends State<HomePage> {
568
585
),
569
586
child: Center (
570
587
child: Text (
571
- 'Download' ,
588
+ translation (context).download ,
572
589
style: TextStyle (
573
590
color: Theme .of (context)
574
591
.colorScheme
@@ -593,8 +610,20 @@ class _HomePageState extends State<HomePage> {
593
610
}
594
611
if (state is ImageError ) {
595
612
final error = state.error;
613
+ if (kDebugMode) {
614
+ print (error);
615
+ }
596
616
return Center (
597
- child: Text (error),
617
+ child: Padding (
618
+ padding: const EdgeInsets .all (50.0 ),
619
+ child: Text (
620
+ "${translation (context ).failed } .${translation (context ).noResultFound }" ,
621
+ style: const TextStyle (
622
+ fontWeight: FontWeight .bold,
623
+ fontSize: 20 ,
624
+ ),
625
+ ),
626
+ ),
598
627
);
599
628
}
600
629
return Container ();
@@ -613,7 +642,7 @@ class _HomePageState extends State<HomePage> {
613
642
context: context,
614
643
builder: (BuildContext context) {
615
644
return SimpleDialog (
616
- title: const Text ('Choose style for the image :' ),
645
+ title: Text ('${ translation ( context ). chooseStyle } :' ),
617
646
children: < Widget > [
618
647
Padding (
619
648
padding: const EdgeInsets .all (10.0 ),
@@ -655,13 +684,12 @@ class _HomePageState extends State<HomePage> {
655
684
context: context,
656
685
builder: (BuildContext context) {
657
686
return AlertDialog (
658
- title: const Text ('Choose Directory :' ),
659
- content: const Text (
660
- 'Do you want to Choose Directory to make the app can save images in your Device?' ),
687
+ title: Text ('${translation (context ).chooseDirectory } :' ),
688
+ content: Text (translation (context).confirmDirectory),
661
689
actions: < Widget > [
662
690
TextButton (
663
691
onPressed: () => Navigator .of (context).pop (),
664
- child: const Text ('No' ),
692
+ child: Text (translation (context).no ),
665
693
),
666
694
TextButton (
667
695
onPressed: () {
@@ -673,7 +701,7 @@ class _HomePageState extends State<HomePage> {
673
701
),
674
702
);
675
703
},
676
- child: const Text ('Yes' ),
704
+ child: Text (translation (context).yes ),
677
705
),
678
706
],
679
707
);
0 commit comments