Skip to content

Update pubspec.yaml #5

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

Open
wants to merge 3 commits into
base: master
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
20 changes: 13 additions & 7 deletions lib/src/radial_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ typedef double ItemAngleCalculator(int index);

/// A radial menu for selecting from a list of items.
///
/// A radial menu lets the user select from a number of items. It displays a
/// A radial menu RadialMenuCenterButtonlets the user select from a number of items. It displays a
/// button that opens the menu, showing its items arranged in an arc. Selecting
/// an item triggers the animation of a progress bar drawn at the specified
/// [radius] around the central menu button.
Expand Down Expand Up @@ -44,8 +44,10 @@ class RadialMenu<T> extends StatefulWidget {
@required this.items,
@required this.onSelected,
this.radius = 100.0,
this.menuAnimationDuration = const Duration(milliseconds: 1000),
this.progressAnimationDuration = const Duration(milliseconds: 1000),
this.expandLeftOnly,
this.customIcon,
this.menuAnimationDuration = const Duration(milliseconds: 200),
this.progressAnimationDuration = const Duration(milliseconds: 200),
}) : assert(radius != null),
assert(menuAnimationDuration != null),
assert(progressAnimationDuration != null),
Expand All @@ -62,6 +64,7 @@ class RadialMenu<T> extends StatefulWidget {
/// Defaults to 100.0.
final double radius;

final Icon customIcon;
/// Duration of the menu opening/closing animation.
///
/// Defaults to 1000 milliseconds.
Expand All @@ -71,7 +74,7 @@ class RadialMenu<T> extends StatefulWidget {
///
/// Defaults to 1000 milliseconds.
final Duration progressAnimationDuration;

final expandLeftOnly;
@override
RadialMenuState createState() => new RadialMenuState();
}
Expand All @@ -85,7 +88,9 @@ class RadialMenuState extends State<RadialMenu> with TickerProviderStateMixin {
// todo: xqwzts: allow users to pass in their own calculator as a param.
// and change this to the default: radialItemAngleCalculator.
double calculateItemAngle(int index) {
double _itemSpacing = 360.0 / widget.items.length;
double modifier = 360.0;
widget.expandLeftOnly != null? modifier = -180.0 : 360.0;
double _itemSpacing = modifier / widget.items.length;
return _startAngle + index * _itemSpacing * _radiansPerDegree;
}

Expand Down Expand Up @@ -170,6 +175,7 @@ class RadialMenuState extends State<RadialMenu> with TickerProviderStateMixin {
return new LayoutId(
id: _RadialMenuLayout.menuButton,
child: new RadialMenuCenterButton(
customIcon: widget.customIcon != null? widget.customIcon : null,
openCloseAnimationController: _menuAnimationController.view,
activateAnimationController: _progressAnimationController.view,
isOpen: _isOpen,
Expand All @@ -181,7 +187,7 @@ class RadialMenuState extends State<RadialMenu> with TickerProviderStateMixin {
@override
Widget build(BuildContext context) {
final List<Widget> children = <Widget>[];

print(widget.customIcon);
for (int i = 0; i < widget.items.length; i++) {
if (_activeItemIndex != i) {
children.add(_buildActionButton(i));
Expand Down Expand Up @@ -236,7 +242,7 @@ class _RadialMenuLayout extends MultiChildLayoutDelegate {

@override
void performLayout(Size size) {
center = new Offset(size.width / 2, size.height / 2);
center = new Offset(size.width - 40, size.height / 2);

if (hasChild(menuButton)) {
Size menuButtonSize;
Expand Down
11 changes: 7 additions & 4 deletions lib/src/radial_menu_center_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class RadialMenuCenterButton extends StatelessWidget {
/// Called when the user presses this button.
final VoidCallback onPressed;

final Icon customIcon;
/// The opened/closed state of the menu.
///
/// Determines which of [closedColor] or [openedColor] should be used as the
Expand Down Expand Up @@ -56,6 +57,7 @@ class RadialMenuCenterButton extends StatelessWidget {
@required this.activateAnimationController,
@required this.onPressed,
@required this.isOpen,
this.customIcon,
this.iconColor = Colors.black,
this.closedColor = Colors.white,
this.openedColor = Colors.grey,
Expand All @@ -79,17 +81,18 @@ class RadialMenuCenterButton extends StatelessWidget {

@override
Widget build(BuildContext context) {
final AnimatedIcon animatedIcon = new AnimatedIcon(
var icon;
icon = new AnimatedIcon(
color: iconColor,
icon: AnimatedIcons.menu_close,
icon: AnimatedIcons.menu_close,
progress: _progress,
);

//print(icon);
final Widget child = new Container(
width: size,
height: size,
child: new Center(
child: animatedIcon,
child: icon,
),
);

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ dev_dependencies:
sdk: flutter

environment:
sdk: '>=1.19.0 <2.0.0'
sdk: '>=1.19.0 <3.0.0'