-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added the screen for draw clipart functionality (#976)
- Loading branch information
1 parent
5fd4ecb
commit 7595618
Showing
16 changed files
with
527 additions
and
210 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class DrawBadgeProvider extends ChangeNotifier { | ||
//List that contains the state of each cell of the badge | ||
List<List<bool>> grid = | ||
List.generate(11, (i) => List.generate(44, (j) => false)); | ||
|
||
//function to update the state of the cell | ||
void updateGrid(int row, int col) { | ||
grid[row][col] = isDrawing; | ||
notifyListeners(); | ||
} | ||
|
||
//function to reset the state of the cell | ||
void resetGrid() { | ||
grid = List.generate(11, (i) => List.generate(44, (j) => false)); | ||
notifyListeners(); | ||
} | ||
|
||
//function to get the state of the cell | ||
List<List<bool>> getGrid() => grid; | ||
|
||
//boolean variable to check for isDrawing on Draw badge screen | ||
bool isDrawing = true; | ||
|
||
//function to toggle the isDrawing variable | ||
void toggleIsDrawing(bool drawing) { | ||
isDrawing = drawing; | ||
notifyListeners(); | ||
} | ||
|
||
//function to get the isDrawing variable | ||
bool getIsDrawing() => isDrawing; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
import 'package:badgemagic/constants.dart'; | ||
import 'package:badgemagic/providers/drawbadge_provider.dart'; | ||
import 'package:badgemagic/view/widgets/common_scaffold_widget.dart'; | ||
import 'package:badgemagic/virtualbadge/view/draw_badge.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/services.dart'; | ||
import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
import 'package:get_it/get_it.dart'; | ||
import 'package:provider/provider.dart'; | ||
|
||
class DrawBadge extends StatefulWidget { | ||
const DrawBadge({super.key}); | ||
|
||
@override | ||
State<DrawBadge> createState() => _DrawBadgeState(); | ||
} | ||
|
||
class _DrawBadgeState extends State<DrawBadge> { | ||
DrawBadgeProvider cellStateToggle = GetIt.instance<DrawBadgeProvider>(); | ||
|
||
@override | ||
void initState() { | ||
SystemChrome.setPreferredOrientations([ | ||
DeviceOrientation.landscapeLeft, | ||
]); | ||
super.initState(); | ||
} | ||
|
||
@override | ||
void dispose() { | ||
SystemChrome.setPreferredOrientations([ | ||
DeviceOrientation.portraitUp, | ||
DeviceOrientation.portraitDown, | ||
DeviceOrientation.landscapeLeft, | ||
DeviceOrientation.landscapeRight, | ||
]); | ||
cellStateToggle.resetGrid(); | ||
super.dispose(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
DrawBadgeProvider drawToggle = Provider.of<DrawBadgeProvider>(context); | ||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky); | ||
return CommonScaffold( | ||
title: 'BadgeMagic', | ||
body: Column( | ||
children: [ | ||
Container( | ||
margin: EdgeInsets.symmetric(vertical: 20.h, horizontal: 20.w), | ||
padding: EdgeInsets.all(10.dg), | ||
height: 400.h, | ||
width: 500.w, | ||
decoration: BoxDecoration( | ||
color: Colors.black, | ||
border: Border.all(color: Colors.black), | ||
borderRadius: BorderRadius.circular(10), | ||
), | ||
child: const BMBadge(), | ||
), | ||
SizedBox( | ||
height: 55.h, | ||
), | ||
Row( | ||
children: [ | ||
TextButton( | ||
onPressed: () { | ||
setState(() { | ||
drawToggle.toggleIsDrawing(true); | ||
}); | ||
}, | ||
child: Column( | ||
children: [ | ||
Icon( | ||
Icons.edit, | ||
color: | ||
drawToggle.getIsDrawing() ? Colors.red : Colors.black, | ||
), | ||
Text( | ||
'Draw', | ||
style: TextStyle( | ||
color: drawToggle.isDrawing ? Colors.red : Colors.black, | ||
), | ||
) | ||
], | ||
), | ||
), | ||
TextButton( | ||
onPressed: () { | ||
setState(() { | ||
drawToggle.toggleIsDrawing(false); | ||
}); | ||
}, | ||
child: Column( | ||
children: [ | ||
Icon( | ||
Icons.delete, | ||
color: drawToggle.isDrawing ? Colors.black : Colors.red, | ||
), | ||
Text( | ||
'Erase', | ||
style: TextStyle( | ||
color: drawToggle.isDrawing ? Colors.black : Colors.red, | ||
), | ||
) | ||
], | ||
), | ||
), | ||
TextButton( | ||
onPressed: () { | ||
setState(() { | ||
drawToggle.resetGrid(); | ||
}); | ||
}, | ||
child: const Column( | ||
children: [ | ||
Icon( | ||
Icons.refresh, | ||
color: Colors.black, | ||
), | ||
Text( | ||
'Reset', | ||
style: TextStyle(color: Colors.black), | ||
) | ||
], | ||
), | ||
), | ||
TextButton( | ||
onPressed: () {}, | ||
child: const Column( | ||
children: [ | ||
Icon( | ||
Icons.save, | ||
color: Colors.black, | ||
), | ||
Text('Save', style: TextStyle(color: Colors.black)) | ||
], | ||
), | ||
), | ||
], | ||
) | ||
], | ||
), | ||
key: const Key(drawBadgeScreen), | ||
); | ||
} | ||
} |
Oops, something went wrong.