-
Notifications
You must be signed in to change notification settings - Fork 219
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
feat: Added the screen for draw clipart functionality #976
Merged
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
dcccf6d
feat:Added the draw badge screen.
Jhalakupadhyay 6a561f9
chore:code formating.
Jhalakupadhyay f4d8f90
chore:code refactoring.
Jhalakupadhyay b99dd15
chore: code refactoring.
Jhalakupadhyay ab6c567
chore:code refactoring
Jhalakupadhyay f99ef67
chore: Formated code and resolved the issue for the screen rotation.
Jhalakupadhyay 62b8bed
chore: code formating.
Jhalakupadhyay 4bd56c0
chore:removed unused import.
Jhalakupadhyay 9fb9b37
chore:removed non referenced function.
Jhalakupadhyay 388df9a
chore:Code refactoring.
Jhalakupadhyay bda2022
chore:updated the file name.
Jhalakupadhyay File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
import 'package:badgemagic/providers/drawbadge_provider.dart'; | ||
import 'package:badgemagic/view/widgets/navigation_drawer.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 Scaffold( | ||
appBar: AppBar( | ||
leading: Builder(builder: (context) { | ||
return IconButton( | ||
onPressed: () { | ||
Scaffold.of(context).openDrawer(); | ||
}, | ||
icon: const Icon( | ||
Icons.menu, | ||
color: Colors.white, | ||
)); | ||
}), | ||
backgroundColor: Colors.red, | ||
title: const Text( | ||
'Badge Magic', | ||
style: TextStyle(color: Colors.white), | ||
), | ||
), | ||
drawer: const BMDrawer(), | ||
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)) | ||
], | ||
), | ||
), | ||
], | ||
) | ||
], | ||
), | ||
); | ||
} | ||
} |
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,44 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class BMDrawer extends StatelessWidget { | ||
const BMDrawer({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Drawer( | ||
child: ListView( | ||
padding: EdgeInsets.zero, | ||
children: <Widget>[ | ||
const DrawerHeader( | ||
decoration: BoxDecoration( | ||
color: Colors.red, | ||
), | ||
child: Center( | ||
child: Text( | ||
'Badge Magic', | ||
style: TextStyle( | ||
color: Colors.white, | ||
fontSize: 24, | ||
), | ||
), | ||
), | ||
), | ||
ListTile( | ||
leading: const Icon(Icons.edit), | ||
title: const Text('Create Badges'), | ||
onTap: () { | ||
Navigator.pushNamed(context, '/'); | ||
}, | ||
), | ||
ListTile( | ||
leading: const Icon(Icons.draw_outlined), | ||
title: const Text('Draw Clipart'), | ||
onTap: () { | ||
Navigator.pushNamed(context, '/drawBadge'); | ||
}, | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should create a common class which will encapsulate this logic, rather than duplicating it. We need to manage the drawer from one class. You can then have these hooks which inject the content and creates the entire page for you