-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from RisabhKedai/main
Added new features and resolved some bugs
- Loading branch information
Showing
9 changed files
with
138 additions
and
30 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
|
||
import 'package:flutter/material.dart'; | ||
|
||
class ReUsuable extends StatelessWidget { | ||
|
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 |
---|---|---|
@@ -1,18 +1,60 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class RoundIconButton extends StatelessWidget { | ||
RoundIconButton({@required this.icon, this.onPressed}); | ||
class RoundIconButton extends StatefulWidget { | ||
final IconData icon; | ||
final Function onPressed; | ||
final Function onLongPressed; | ||
RoundIconButton({@required this.icon, this.onPressed, this.onLongPressed}); | ||
_RoundIconButton createState() => | ||
_RoundIconButton(this.icon, this.onPressed, this.onLongPressed); | ||
} | ||
|
||
class _RoundIconButton extends State<RoundIconButton> { | ||
final IconData icon; | ||
final Function onPressed; | ||
final Function onLongPressed; | ||
_RoundIconButton(this.icon, this.onPressed, this.onLongPressed); | ||
|
||
bool isPressed = false; | ||
@override | ||
Widget build(BuildContext context) { | ||
return RawMaterialButton( | ||
child: Icon(icon), | ||
onPressed: onPressed, | ||
elevation: 6.0, | ||
return Container( | ||
constraints: BoxConstraints.tightFor(width: 56.0, height: 56.0), | ||
shape: CircleBorder(), | ||
fillColor: Colors.grey, | ||
child: GestureDetector( | ||
child: ElevatedButton( | ||
child: Icon(icon), | ||
onPressed: onPressed, | ||
style: ButtonStyle( | ||
elevation: MaterialStateProperty.resolveWith<double>( | ||
(Set<MaterialState> states) { | ||
return 6.0; | ||
}, | ||
), | ||
overlayColor: MaterialStateProperty.resolveWith<Color>( | ||
(Set<MaterialState> states) { | ||
return Colors.transparent; | ||
}), | ||
backgroundColor: MaterialStateProperty.resolveWith<Color>( | ||
(Set<MaterialState> states) { | ||
return Colors.grey; | ||
}, | ||
), | ||
shape: MaterialStateProperty.resolveWith<OutlinedBorder>( | ||
(Set<MaterialState> states) { | ||
return CircleBorder(); | ||
}, | ||
), | ||
), | ||
), | ||
onLongPressStart: (_) async { | ||
isPressed = true; | ||
do { | ||
if (onLongPressed != null) onLongPressed(); | ||
await Future.delayed(Duration(milliseconds: 50)); | ||
} while (isPressed); | ||
}, | ||
onLongPressEnd: (_) => setState(() => isPressed = false), | ||
), | ||
); | ||
} | ||
} |
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