generated from Stacked-Org/package-template
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update HoverExtensions * Compile templates
- Loading branch information
1 parent
ad50af2
commit 20955c9
Showing
3 changed files
with
129 additions
and
177 deletions.
There are no files selected for viewing
27 changes: 20 additions & 7 deletions
27
lib/src/templates/app/web/lib/extensions/hover_extensions.dart.stk
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,31 +1,44 @@ | ||
import 'package:{{packageName}}/ui/widgets/mouse_transforms/scale_on_hover.dart'; | ||
import 'package:{{packageName}}/ui/widgets/mouse_transforms/translate_on_hover.dart'; | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
extension HoverExtensions on Widget { | ||
Widget get showCursorOnHover { | ||
return MouseRegion( | ||
return _returnUnalteredOnMobile(MouseRegion( | ||
child: this, | ||
cursor: SystemMouseCursors.click, | ||
); | ||
)); | ||
} | ||
|
||
/// Moves the widget by x,y pixels on hover | ||
/// | ||
/// to move up use -y values, to move left use -x values | ||
Widget moveOnHover({double? x, double? y}) { | ||
return TranslateOnHover( | ||
return _returnUnalteredOnMobile(TranslateOnHover( | ||
x: x, | ||
y: y, | ||
child: this, | ||
); | ||
)); | ||
} | ||
|
||
/// Scales the widget by [scale] on hover | ||
Widget scaleOnHover({double scale = 1.1}) { | ||
return ScaleOnHover( | ||
return _returnUnalteredOnMobile(ScaleOnHover( | ||
child: this, | ||
scale: scale, | ||
); | ||
)); | ||
} | ||
} | ||
|
||
/// Takes in the alteredWidget and if we detect we're on Android or iOS | ||
/// we return the unaltered widget. | ||
/// | ||
/// The reason we can do this is because all altered widgets require mouse | ||
/// functionality to work. | ||
Widget _returnUnalteredOnMobile(Widget alteredWidget) { | ||
if (kIsWeb) { | ||
return alteredWidget; | ||
} | ||
return this; | ||
} | ||
} |
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
Oops, something went wrong.