Skip to content

Commit

Permalink
Merge pull request #62 from kevlatus/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
kevlatus authored Jul 4, 2021
2 parents a4e7d70 + 9353552 commit acf17fc
Show file tree
Hide file tree
Showing 17 changed files with 825 additions and 123 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [1.1.0] - 2021-07-04

- add gesture detection to FortuneItems
- improve wheel performance by reducing the number of calculations and transformations

## [1.0.1] - 2021-06-19

- bump flutter_hooks dependency to v0.17.0
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class FortuneBarPage extends HookWidget {
selected: selected.stream,
items: [
for (var it in Constants.fortuneValues)
FortuneItem(child: Text(it))
FortuneItem(child: Text(it), onTap: () => print(it))
],
onFling: handleRoll,
onAnimationStart: () {
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/wheel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class FortuneWheelPage extends HookWidget {
],
items: [
for (var it in Constants.fortuneValues)
FortuneItem(child: Text(it))
FortuneItem(child: Text(it), onTap: () => print(it))
],
),
),
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.0.1"
version: "1.1.0"
flutter_hooks:
dependency: "direct main"
description:
Expand Down
16 changes: 9 additions & 7 deletions lib/src/bar/fortune_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class FortuneBar extends HookWidget implements FortuneWidget {
children: [
for (int i = 0; i < items.length; i++)
_FortuneBarItem(
child: items[i].child,
item: items[i],
style: styleStrategy.getItemStyle(
theme,
i,
Expand All @@ -176,12 +176,14 @@ class FortuneBar extends HookWidget implements FortuneWidget {
);
}),
for (var it in indicators)
Align(
alignment: it.alignment,
child: SizedBox(
width: size.width / visibleItemCount,
height: height,
child: it.child,
IgnorePointer(
child: Align(
alignment: it.alignment,
child: SizedBox(
width: size.width / visibleItemCount,
height: height,
child: it.child,
),
),
),
],
Expand Down
86 changes: 67 additions & 19 deletions lib/src/bar/item.dart
Original file line number Diff line number Diff line change
@@ -1,36 +1,84 @@
part of 'bar.dart';

class _FortuneBarItem extends StatelessWidget {
final Widget child;
final FortuneItem item;
final FortuneItemStyle style;

const _FortuneBarItem({
Key? key,
required this.child,
required this.item,
this.style = const FortuneItemStyle(),
}) : super(key: key);

@override
Widget build(BuildContext context) {
return DecoratedBox(
decoration: BoxDecoration(
border: Border.symmetric(
horizontal: BorderSide(
color: style.borderColor,
width: style.borderWidth / 2,
),
vertical: BorderSide(
color: style.borderColor,
width: style.borderWidth / 4,
return GestureDetector(
onTap: item.onTap,
onTapCancel: item.onTapCancel,
onTapDown: item.onTapDown,
onTapUp: item.onTapUp,
onDoubleTap: item.onDoubleTap,
onDoubleTapCancel: item.onDoubleTapCancel,
onDoubleTapDown: item.onDoubleTapDown,
onForcePressEnd: item.onForcePressEnd,
onForcePressPeak: item.onForcePressPeak,
onForcePressStart: item.onForcePressStart,
onForcePressUpdate: item.onForcePressUpdate,
onLongPress: item.onLongPress,
onLongPressEnd: item.onLongPressEnd,
onLongPressMoveUpdate: item.onLongPressMoveUpdate,
onLongPressStart: item.onLongPressStart,
onLongPressUp: item.onLongPressUp,
onPanCancel: item.onPanCancel,
onPanDown: item.onPanDown,
onPanEnd: item.onPanEnd,
onPanStart: item.onPanStart,
onPanUpdate: item.onPanUpdate,
onScaleEnd: item.onScaleEnd,
onScaleStart: item.onScaleStart,
onScaleUpdate: item.onScaleUpdate,
onSecondaryLongPress: item.onSecondaryLongPress,
onSecondaryLongPressMoveUpdate: item.onSecondaryLongPressMoveUpdate,
onSecondaryLongPressStart: item.onSecondaryLongPressStart,
onSecondaryLongPressEnd: item.onSecondaryLongPressEnd,
onSecondaryLongPressUp: item.onSecondaryLongPressUp,
onHorizontalDragCancel: item.onHorizontalDragCancel,
onHorizontalDragDown: item.onHorizontalDragDown,
onHorizontalDragEnd: item.onHorizontalDragEnd,
onHorizontalDragStart: item.onHorizontalDragStart,
onHorizontalDragUpdate: item.onHorizontalDragUpdate,
onVerticalDragCancel: item.onVerticalDragCancel,
onVerticalDragDown: item.onVerticalDragDown,
onVerticalDragEnd: item.onVerticalDragEnd,
onVerticalDragStart: item.onVerticalDragStart,
onVerticalDragUpdate: item.onVerticalDragUpdate,
onSecondaryTap: item.onSecondaryTap,
onSecondaryTapCancel: item.onSecondaryTapCancel,
onSecondaryTapDown: item.onSecondaryTapDown,
onSecondaryTapUp: item.onSecondaryTapUp,
onTertiaryTapCancel: item.onTertiaryTapCancel,
onTertiaryTapDown: item.onTertiaryTapDown,
onTertiaryTapUp: item.onTertiaryTapUp,
child: DecoratedBox(
decoration: BoxDecoration(
border: Border.symmetric(
horizontal: BorderSide(
color: style.borderColor,
width: style.borderWidth / 2,
),
vertical: BorderSide(
color: style.borderColor,
width: style.borderWidth / 4,
),
),
color: style.color,
),
color: style.color,
),
child: Center(
child: DefaultTextStyle(
textAlign: style.textAlign,
style: style.textStyle,
child: child,
child: Center(
child: DefaultTextStyle(
textAlign: style.textAlign,
style: style.textStyle,
child: item.child,
),
),
),
);
Expand Down
7 changes: 7 additions & 0 deletions lib/src/core/core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ import '../indicators/indicators.dart';
import '../wheel/wheel.dart';

part 'animations.dart';

part 'fortune_item.dart';

part 'fortune_widget.dart';

part 'gestures.dart';

part 'pan_detector.dart';

part 'random.dart';

part 'styling.dart';
Loading

0 comments on commit acf17fc

Please sign in to comment.