Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: layout Overflow Issues in About Us Page and Handle Null cases in Images #1143

Open
wants to merge 1 commit into
base: flutter_app
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions lib/bademagic_module/utils/converters.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ class Converters {
if (key is List) {
String filename = key[0];
List<dynamic>? decodedData = await fileHelper.readFromFile(filename);
final List<List<dynamic>> image = decodedData!.cast<List<dynamic>>();

// Handling the potential null case for decodedData
if (decodedData == null) {
// Optionally handle the null case, e.g., throw an exception, return a default value, or log the error.
throw Exception('Decoded data is null for the file: $filename');
}

final List<List<dynamic>> image = decodedData.cast<List<dynamic>>();
List<List<int>> imageData =
image.map((list) => list.cast<int>()).toList();
hexStrings += convertBitmapToLEDHex(imageData, true);
Expand All @@ -50,8 +57,7 @@ class Converters {
return hexStrings;
}

//function to convert the bitmap to the LED hex format
//it takes the 2D list of pixels and converts it to the LED hex format
// Function to convert the bitmap to the LED hex format
static List<String> convertBitmapToLEDHex(
List<List<int>> image, bool isDrawn) {
// Determine the height and width of the image
Expand Down Expand Up @@ -170,7 +176,7 @@ class Converters {
return e.map((e) => e ? 1 : 0).toList();
}).toList();

//add 1 at the satrt and end of each row in the 2D list
// Add 1 at the start and end of each row in the 2D list
for (int i = 0; i < hexArray.length; i++) {
hexArray[i].insert(0, 1);
hexArray[i].add(1);
Expand Down
65 changes: 36 additions & 29 deletions lib/view/about_us_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class _AboutUsScreenState extends State<AboutUsScreen> {
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
SizedBox(
const SizedBox(
height: 25,
),
Center(
Expand All @@ -74,40 +74,47 @@ class _AboutUsScreenState extends State<AboutUsScreen> {
fontSize: 12),
),
const SizedBox(height: 16),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Developed by',
style: GoogleFonts.sora(
fontWeight: FontWeight.w500,
color: Colors.grey),
),
SizedBox(
width: 10,
),
GestureDetector(
onTap: () => openUrl(
'https://github.com/fossasia/badge-magic-android'),
child: Text(
'FOSSASIA contributors',
style: GoogleFonts.sora(
fontWeight: FontWeight.w500,
color: Colors.red,
decoration: TextDecoration.underline),
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Flexible(
child: Text(
'Developed by',
style: GoogleFonts.sora(
fontWeight: FontWeight.w500,
color: Colors.grey),
),
),
),
],
const SizedBox(
width: 10,
),
Flexible(
child: GestureDetector(
onTap: () => openUrl(
'https://github.com/fossasia/badge-magic-android'),
child: Text(
'FOSSASIA contributors',
style: GoogleFonts.sora(
fontWeight: FontWeight.w500,
color: Colors.red,
decoration: TextDecoration.underline),
),
),
),
],
),
),
],
),
),
),
SizedBox(height: 10),
const SizedBox(height: 10),
Container(
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
boxShadow: const [
BoxShadow(
blurRadius: 1,
color: Colors.grey,
Expand All @@ -119,7 +126,7 @@ class _AboutUsScreenState extends State<AboutUsScreen> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(left: 12.0, top: 12.0),
padding: const EdgeInsets.only(left: 12.0, top: 12.0),
child: Text(
'Contact With Us',
style: GoogleFonts.sora(
Expand Down Expand Up @@ -151,13 +158,13 @@ class _AboutUsScreenState extends State<AboutUsScreen> {
],
),
),
SizedBox(
const SizedBox(
height: 10,
),
Container(
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
boxShadow: const [
BoxShadow(
blurRadius: 1,
color: Colors.grey,
Expand Down
2 changes: 1 addition & 1 deletion lib/view/homescreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class _HomeScreenState extends State<HomeScreen>
specialTextSpanBuilder: ImageBuilder(),
decoration: InputDecoration(
hintText: errorVal,
hintStyle: TextStyle(color: Colors.red),
hintStyle: const TextStyle(color: Colors.red),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.r),
),
Expand Down
12 changes: 6 additions & 6 deletions lib/view/widgets/about_us_daialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class LicenseDialogContainer extends StatelessWidget {
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
const SizedBox(
width: 16,
),
Text(
Expand All @@ -39,7 +39,7 @@ class LicenseDialogContainer extends StatelessWidget {
],
),
Padding(
padding: EdgeInsets.only(left: 16.0),
padding: const EdgeInsets.only(left: 16.0),
child: GestureDetector(
onTap: () => openUrl(url),
child: Text(
Expand Down Expand Up @@ -83,7 +83,7 @@ void showLicenseDialog(BuildContext context) {
context: context,
builder: (BuildContext context) {
return Dialog(
insetPadding: EdgeInsets.all(8),
insetPadding: const EdgeInsets.all(8),
backgroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
Expand All @@ -94,9 +94,9 @@ void showLicenseDialog(BuildContext context) {
children: [
Container(
padding: const EdgeInsets.only(left: 16.0, top: 16, bottom: 8),
decoration: BoxDecoration(
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.only(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10.0),
topRight: Radius.circular(10.0),
),
Expand All @@ -117,7 +117,7 @@ void showLicenseDialog(BuildContext context) {
child: InteractiveViewer(
minScale: 1.0,
maxScale: 5.0,
child: SingleChildScrollView(
child: const SingleChildScrollView(
child: Padding(
padding: EdgeInsets.all(8.0),
child: Column(
Expand Down
8 changes: 4 additions & 4 deletions lib/view/widgets/badge_delete_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ class DeleteBadgeDialog extends StatelessWidget {
),
Row(
children: [
SizedBox(
const SizedBox(
width: 20,
),
Icon(Icons.delete, color: Colors.black),
SizedBox(
const Icon(Icons.delete, color: Colors.black),
const SizedBox(
width: 10,
),
Text(
Expand All @@ -47,7 +47,7 @@ class DeleteBadgeDialog extends StatelessWidget {
),
Row(
children: [
SizedBox(
const SizedBox(
width: 20,
),
Text('Are you sure want to delete this badge?',
Expand Down
4 changes: 2 additions & 2 deletions lib/view/widgets/save_badge_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class SaveBadgeDialog extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expanded(
const Expanded(
flex: 1,
child: const Text(
child: Text(
'Save Badge',
style: TextStyle(
fontWeight: FontWeight.bold,
Expand Down
Loading