Skip to content

Commit 6f6c123

Browse files
Merge branch 'development' into issue#1268
2 parents bb2c601 + 854bf07 commit 6f6c123

File tree

6 files changed

+121
-136
lines changed

6 files changed

+121
-136
lines changed

.github/workflows/flutter_upgrade.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
5757
PR_URL=$(gh pr create --title "chore(deps): upgrade Flutter to ${{ env.latest_flutter_version }}" \
5858
--body "This PR updates Flutter version in pubspec.yaml to the latest stable release." \
59-
--base flutter_app \
59+
--base development \
6060
--head $BRANCH_NAME)
6161
6262
# Close and reopen the PR to trigger workflows

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The Badge Magic Android app lets you create moving text and draw clipart for LED
2323

2424
## Download
2525

26-
* [Latest Release Build](https://github.com/fossasia/badgemagic-app/raw/apk/badge-magic-flutter_app-release.apk) in the apk branch
26+
* [Latest Release Build](https://github.com/fossasia/badgemagic-app/raw/apk/badge-magic-development-release.apk) in the apk branch
2727

2828
## Permissions
2929
* **Bluetooth**: For sending org.fossasia.badgemagic.data to the badge.

lib/view/draw_badge_screen.dart

Lines changed: 70 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'package:badgemagic/bademagic_module/utils/byte_array_utils.dart';
21
import 'package:badgemagic/bademagic_module/utils/converters.dart';
32
import 'package:badgemagic/bademagic_module/utils/file_helper.dart';
43
import 'package:badgemagic/bademagic_module/utils/toast_utils.dart';
@@ -14,7 +13,6 @@ class DrawBadge extends StatefulWidget {
1413
final bool? isSavedCard;
1514
final bool? isSavedClipart;
1615
final List<List<int>>? badgeGrid;
17-
1816
const DrawBadge({
1917
super.key,
2018
this.filename,
@@ -28,15 +26,12 @@ class DrawBadge extends StatefulWidget {
2826
}
2927

3028
class _DrawBadgeState extends State<DrawBadge> {
31-
late DrawBadgeProvider drawToggle;
29+
var drawToggle = DrawBadgeProvider();
3230

3331
@override
34-
void initState() {
35-
super.initState();
36-
drawToggle = DrawBadgeProvider();
37-
WidgetsBinding.instance.addPostFrameCallback((_) {
38-
_setLandscapeOrientation();
39-
});
32+
void didChangeDependencies() {
33+
super.didChangeDependencies();
34+
_setLandscapeOrientation();
4035
}
4136

4237
@override
@@ -45,67 +40,27 @@ class _DrawBadgeState extends State<DrawBadge> {
4540
super.dispose();
4641
}
4742

48-
Future<void> _resetPortraitOrientation() async {
49-
try {
50-
await SystemChrome.setPreferredOrientations([
51-
DeviceOrientation.portraitUp,
52-
DeviceOrientation.portraitDown,
53-
]);
54-
} catch (e) {
55-
logger.e('Error setting portrait orientation', error: e);
56-
}
57-
}
58-
59-
Future<void> _setLandscapeOrientation() async {
60-
try {
61-
await SystemChrome.setPreferredOrientations([
62-
DeviceOrientation.landscapeRight,
63-
DeviceOrientation.landscapeLeft,
64-
]);
65-
} catch (e) {
66-
logger.e('Error setting landscape orientation', error: e);
67-
}
43+
void _resetPortraitOrientation() {
44+
SystemChrome.setPreferredOrientations([
45+
DeviceOrientation.portraitUp,
46+
DeviceOrientation.portraitDown,
47+
]);
6848
}
6949

70-
Future<void> _saveImage() async {
71-
try {
72-
List<List<int>> badgeGrid = drawToggle
73-
.getDrawViewGrid()
74-
.map((e) => e.map((e) => e ? 1 : 0).toList())
75-
.toList();
76-
List<String> hexString =
77-
Converters.convertBitmapToLEDHex(badgeGrid, false);
78-
79-
if (widget.isSavedCard == true) {
80-
await FileHelper().updateBadgeText(
81-
widget.filename ?? '',
82-
hexString,
83-
);
84-
} else if (widget.isSavedClipart == true) {
85-
await FileHelper().updateClipart(
86-
widget.filename ?? '',
87-
badgeGrid,
88-
);
89-
} else {
90-
await FileHelper().saveImage(drawToggle.getDrawViewGrid());
91-
}
92-
93-
await FileHelper().generateClipartCache();
94-
ToastUtils().showToast("Clipart Saved Successfully");
95-
} catch (e) {
96-
logger.e('Error saving image', error: e);
97-
}
50+
void _setLandscapeOrientation() {
51+
SystemChrome.setPreferredOrientations([
52+
DeviceOrientation.landscapeRight,
53+
DeviceOrientation.landscapeLeft,
54+
]);
9855
}
9956

10057
@override
10158
Widget build(BuildContext context) {
102-
return PopScope(
103-
canPop: true,
104-
// ignore: deprecated_member_use
105-
onPopInvoked: (didPop) async {
106-
if (didPop) {
107-
await _resetPortraitOrientation();
108-
}
59+
FileHelper fileHelper = FileHelper();
60+
return WillPopScope(
61+
onWillPop: () async {
62+
_resetPortraitOrientation();
63+
return true;
10964
},
11065
child: CommonScaffold(
11166
index: 1,
@@ -154,7 +109,7 @@ class _DrawBadgeState extends State<DrawBadge> {
154109
Text(
155110
'Draw',
156111
style: TextStyle(
157-
color: drawToggle.getIsDrawing()
112+
color: drawToggle.isDrawing
158113
? colorPrimary
159114
: Colors.black,
160115
),
@@ -172,14 +127,14 @@ class _DrawBadgeState extends State<DrawBadge> {
172127
children: [
173128
Icon(
174129
Icons.delete,
175-
color: drawToggle.getIsDrawing()
130+
color: drawToggle.isDrawing
176131
? Colors.black
177132
: colorPrimary,
178133
),
179134
Text(
180135
'Erase',
181136
style: TextStyle(
182-
color: drawToggle.getIsDrawing()
137+
color: drawToggle.isDrawing
183138
? Colors.black
184139
: colorPrimary,
185140
),
@@ -195,19 +150,62 @@ class _DrawBadgeState extends State<DrawBadge> {
195150
},
196151
child: const Column(
197152
children: [
198-
Icon(Icons.refresh, color: Colors.black),
199-
Text('Reset',
200-
style: TextStyle(color: Colors.black))
153+
Icon(
154+
Icons.refresh,
155+
color: Colors.black,
156+
),
157+
Text(
158+
'Reset',
159+
style: TextStyle(color: Colors.black),
160+
)
201161
],
202162
),
203163
),
204164
TextButton(
205165
onPressed: () async {
206-
await _saveImage();
166+
try {
167+
List<List<int>> badgeGrid = drawToggle
168+
.getDrawViewGrid()
169+
.map((e) => e.map((e) => e ? 1 : 0).toList())
170+
.toList();
171+
List<String> hexString =
172+
Converters.convertBitmapToLEDHex(
173+
badgeGrid, false);
174+
175+
if (widget.isSavedCard!) {
176+
await fileHelper.updateBadgeText(
177+
widget.filename!, hexString);
178+
} else if (widget.isSavedClipart!) {
179+
await fileHelper.updateClipart(
180+
widget.filename!, badgeGrid);
181+
} else {
182+
await fileHelper
183+
.saveImage(drawToggle.getDrawViewGrid());
184+
}
185+
186+
await fileHelper.generateClipartCache();
187+
188+
ToastUtils()
189+
.showToast("Clipart Saved Successfully");
190+
191+
await Future.delayed(
192+
const Duration(milliseconds: 800));
193+
194+
if (mounted) {
195+
Navigator.of(context)
196+
.popUntil((route) => route.isFirst);
197+
}
198+
} catch (e) {
199+
ToastUtils().showToast(
200+
"Failed to save badge: ${e.toString()}");
201+
}
207202
},
208203
child: const Column(
209204
children: [
210-
Icon(Icons.save, color: Colors.black),
205+
Icon(
206+
Icons.save,
207+
color: Colors.black,
208+
),
211209
Text('Save',
212210
style: TextStyle(color: Colors.black))
213211
],

lib/view/widgets/badge_delete_dialog.dart

Lines changed: 39 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,80 +2,67 @@ import 'package:flutter/material.dart';
22
import 'package:flutter_screenutil/flutter_screenutil.dart';
33

44
class DeleteBadgeDialog extends StatelessWidget {
5-
const DeleteBadgeDialog({
6-
super.key,
7-
});
5+
const DeleteBadgeDialog({super.key});
86

97
@override
108
Widget build(BuildContext context) {
119
return Dialog(
10+
insetPadding: EdgeInsets.symmetric(horizontal: 24.w),
1211
shape: RoundedRectangleBorder(
13-
borderRadius: BorderRadius.circular(5.r),
12+
borderRadius: BorderRadius.circular(12.r),
1413
),
15-
child: Container(
16-
height: 110.h,
17-
width: 300.w,
18-
decoration: BoxDecoration(
19-
color: Colors.white,
20-
borderRadius: BorderRadius.circular(5.r),
21-
),
14+
child: Padding(
15+
padding: EdgeInsets.all(20.w),
2216
child: Column(
17+
mainAxisSize: MainAxisSize.min,
18+
crossAxisAlignment: CrossAxisAlignment.start,
2319
children: [
24-
SizedBox(
25-
height: 10.h,
26-
),
2720
Row(
2821
children: [
29-
SizedBox(
30-
width: 20,
31-
),
32-
Icon(Icons.delete, color: Colors.black),
33-
SizedBox(
34-
width: 10,
35-
),
36-
Text(
37-
'Delete',
38-
style: TextStyle(
39-
fontSize: 16.sp,
40-
fontWeight: FontWeight.w500,
22+
Icon(Icons.delete_outline, color: Colors.red),
23+
SizedBox(width: 10.w),
24+
Expanded(
25+
child: Text(
26+
'Delete Badge',
27+
style: TextStyle(
28+
fontSize: 18.sp,
29+
fontWeight: FontWeight.w600,
30+
),
4131
),
4232
),
4333
],
4434
),
45-
SizedBox(
46-
height: 7.h,
47-
),
48-
Row(
49-
children: [
50-
SizedBox(
51-
width: 20,
52-
),
53-
Text('Are you sure want to delete this badge?',
54-
style: TextStyle(fontSize: 14.sp)),
55-
],
56-
),
57-
SizedBox(
58-
height: 10.h,
35+
SizedBox(height: 16.h),
36+
Text(
37+
'Are you sure you want to delete this badge? This action cannot be undone.',
38+
style: TextStyle(fontSize: 15.sp),
5939
),
40+
SizedBox(height: 24.h),
6041
Row(
6142
mainAxisAlignment: MainAxisAlignment.end,
6243
children: [
6344
TextButton(
64-
onPressed: () {
65-
Navigator.of(context).pop(false);
66-
},
67-
child: const Text(
45+
onPressed: () => Navigator.of(context).pop(false),
46+
child: Text(
6847
'Cancel',
69-
style: TextStyle(color: Colors.red),
48+
style: TextStyle(
49+
color: Theme.of(context).colorScheme.secondary,
50+
fontSize: 14.sp,
51+
),
7052
),
7153
),
72-
TextButton(
73-
onPressed: () {
74-
Navigator.of(context).pop(true);
75-
},
76-
child: const Text(
77-
'OK',
78-
style: TextStyle(color: Colors.red),
54+
SizedBox(width: 8.w),
55+
ElevatedButton(
56+
style: ElevatedButton.styleFrom(
57+
backgroundColor: Colors.red,
58+
padding:
59+
EdgeInsets.symmetric(horizontal: 20.w, vertical: 10.h),
60+
minimumSize: Size(64.w, 36.h),
61+
),
62+
onPressed: () => Navigator.of(context).pop(true),
63+
child: Text(
64+
'Delete',
65+
style: TextStyle(fontSize: 14.sp, color: Colors.white),
7966
),
8067
),
8168
],

pubspec.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ packages:
55
dependency: transitive
66
description:
77
name: _fe_analyzer_shared
8-
sha256: e55636ed79578b9abca5fecf9437947798f5ef7456308b5cb85720b793eac92f
8+
sha256: da0d9209ca76bde579f2da330aeb9df62b6319c834fa7baae052021b0462401f
99
url: "https://pub.dev"
1010
source: hosted
11-
version: "82.0.0"
11+
version: "85.0.0"
1212
analyzer:
1313
dependency: transitive
1414
description:
1515
name: analyzer
16-
sha256: "904ae5bb474d32c38fb9482e2d925d5454cda04ddd0e55d2e6826bc72f6ba8c0"
16+
sha256: "974859dc0ff5f37bc4313244b3218c791810d03ab3470a579580279ba971a48d"
1717
url: "https://pub.dev"
1818
source: hosted
19-
version: "7.4.5"
19+
version: "7.7.1"
2020
archive:
2121
dependency: transitive
2222
description:
@@ -117,10 +117,10 @@ packages:
117117
dependency: "direct dev"
118118
description:
119119
name: dart_style
120-
sha256: "5b236382b47ee411741447c1f1e111459c941ea1b3f2b540dde54c210a3662af"
120+
sha256: "8a0e5fba27e8ee025d2ffb4ee820b4e6e2cf5e4246a6b1a477eb66866947e0bb"
121121
url: "https://pub.dev"
122122
source: hosted
123-
version: "3.1.0"
123+
version: "3.1.1"
124124
dbus:
125125
dependency: transitive
126126
description:
@@ -387,10 +387,10 @@ packages:
387387
dependency: "direct main"
388388
description:
389389
name: logger
390-
sha256: "2621da01aabaf223f8f961e751f2c943dbb374dc3559b982f200ccedadaa6999"
390+
sha256: "55d6c23a6c15db14920e037fe7e0dc32e7cdaf3b64b4b25df2d541b5b6b81c0c"
391391
url: "https://pub.dev"
392392
source: hosted
393-
version: "2.6.0"
393+
version: "2.6.1"
394394
logging:
395395
dependency: transitive
396396
description:

0 commit comments

Comments
 (0)