Skip to content

Commit

Permalink
fix: Yellow underline (because of missing Material widget)
Browse files Browse the repository at this point in the history
  • Loading branch information
vanlooverenkoen committed Oct 1, 2024
1 parent 0cf96c5 commit a8d7066
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 59 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.2.5

## Fix

- Yellow underline (because of missing `Material` widget)

# 0.2.4

## CI
Expand Down
3 changes: 2 additions & 1 deletion lib/snacky.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export 'src/model/snacky.dart';
export 'src/model/snacky_location.dart';
export 'src/model/snacky_type.dart';
export 'src/navigator/snacky_navigator_observer.dart';
export 'src/transition/slide_transition.dart';
export 'src/transition/snacky_slide_transition.dart';
export 'src/widget/base_snacky_widget.dart';
export 'src/widget/snacky_configurator_widget.dart';
export 'src/widget/snacky_swipe_detector.dart';
12 changes: 4 additions & 8 deletions lib/src/builder/simple_snacky_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ class SimpleSnackyBuilder extends SnackyBuilder {
),
],
if (snacky.bottomWidgetBuilder != null) ...[
snacky.bottomWidgetBuilder!(
context, cancelableSnacky),
snacky.bottomWidgetBuilder!(context, cancelableSnacky),
],
],
),
Expand All @@ -123,8 +122,7 @@ class SimpleSnackyBuilder extends SnackyBuilder {
padding: const EdgeInsets.all(8),
child: Icon(
Icons.close,
color: _getTextStyle(snacky, SimpleSnackyTextType.title)
.color,
color: _getTextStyle(snacky, SimpleSnackyTextType.title).color,
),
),
),
Expand All @@ -133,8 +131,7 @@ class SimpleSnackyBuilder extends SnackyBuilder {
const SizedBox(width: 8),
Icon(
Icons.keyboard_arrow_right,
color:
_getTextStyle(snacky, SimpleSnackyTextType.title).color,
color: _getTextStyle(snacky, SimpleSnackyTextType.title).color,
),
const SizedBox(width: 16),
] else ...[
Expand Down Expand Up @@ -186,8 +183,7 @@ class SimpleSnackyBuilder extends SnackyBuilder {
}
switch (textType) {
case SimpleSnackyTextType.title:
return const TextStyle(
color: Colors.black, fontSize: 16, fontWeight: FontWeight.bold);
return const TextStyle(color: Colors.black, fontSize: 16, fontWeight: FontWeight.bold);
case SimpleSnackyTextType.subtitle:
return const TextStyle(color: Colors.black, fontSize: 12);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ import 'package:snacky/src/model/cancelable_snacky.dart';
import 'package:snacky/src/model/snacky.dart';
import 'package:snacky/src/model/snacky_location.dart';

class SlideTransitionExample extends StatefulWidget {
class SnackySlideTransition extends StatefulWidget {
final Widget child;
final CancelableSnacky cancelableSnacky;
final SnackyController snackyController;

const SlideTransitionExample({
const SnackySlideTransition({
required this.child,
required this.cancelableSnacky,
required this.snackyController,
super.key,
});

@override
State<SlideTransitionExample> createState() => _SlideTransitionExampleState();
State<SnackySlideTransition> createState() => _SnackySlideTransitionState();
}

class _SlideTransitionExampleState extends State<SlideTransitionExample>
class _SnackySlideTransitionState extends State<SnackySlideTransition>
with SingleTickerProviderStateMixin, CancelableSnackyListener {
Timer? _timer;

Expand All @@ -49,11 +49,9 @@ class _SlideTransitionExampleState extends State<SlideTransitionExample>
});

// Animation
final beginX = snacky.location == SnackyLocation.topStart ||
snacky.location == SnackyLocation.bottomStart
final beginX = snacky.location == SnackyLocation.topStart || snacky.location == SnackyLocation.bottomStart
? -1
: snacky.location == SnackyLocation.topEnd ||
snacky.location == SnackyLocation.bottomEnd
: snacky.location == SnackyLocation.topEnd || snacky.location == SnackyLocation.bottomEnd
? 1
: 0;
final beginY = snacky.location == SnackyLocation.top
Expand Down
36 changes: 20 additions & 16 deletions lib/src/widget/base_snacky_widget.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:snacky/snacky.dart';
import 'package:snacky/src/widget/swipe_detector.dart';
import 'package:snacky/src/controller/snacky_controller.dart';
import 'package:snacky/src/model/cancelable_snacky.dart';
import 'package:snacky/src/transition/snacky_slide_transition.dart';
import 'package:snacky/src/widget/snacky_swipe_detector.dart';
import 'package:snacky/src/widget/touch_feedback.dart';

class BaseSnackyWidget extends StatelessWidget {
Expand All @@ -24,32 +26,34 @@ class BaseSnackyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final snacky = cancelableSnacky.snacky;
return SlideTransitionExample(
return SnackySlideTransition(
snackyController: snackyController,
cancelableSnacky: cancelableSnacky,
child: SafeArea(
top: snacky.location.isTop,
bottom: snacky.location.isBottom,
child: SwipeDetector(
child: SnackySwipeDetector(
enabled: cancelableSnacky.isNotCancelled,
alignment: snacky.location.alignment,
onSwipe: () => cancelableSnacky.cancel(),
child: Padding(
padding: margin,
child: Stack(
children: [
child,
if (snacky.onTap != null) ...[
Positioned.fill(
child: TouchFeedback(
onTap: snacky.onTap,
disableInkWell: disableInkWell,
borderRadius: borderRadius,
child: const ColoredBox(color: Colors.transparent),
child: Material(
child: Stack(
children: [
child,
if (snacky.onTap != null) ...[
Positioned.fill(
child: TouchFeedback(
onTap: snacky.onTap,
disableInkWell: disableInkWell,
borderRadius: borderRadius,
child: const ColoredBox(color: Colors.transparent),
),
),
),
],
],
],
),
),
),
),
Expand Down
33 changes: 15 additions & 18 deletions lib/src/widget/snacky_configurator_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@ class SnackyConfiguratorWidget extends StatefulWidget {
});

@override
State<SnackyConfiguratorWidget> createState() =>
_SnackyConfiguratorWidgetState();
State<SnackyConfiguratorWidget> createState() => _SnackyConfiguratorWidgetState();
}

class _SnackyConfiguratorWidgetState extends State<SnackyConfiguratorWidget>
implements SnackyListener {
SnackyController get snackyController =>
widget.snackyController ?? SnackyController.instance;
class _SnackyConfiguratorWidgetState extends State<SnackyConfiguratorWidget> implements SnackyListener {
SnackyController get snackyController => widget.snackyController ?? SnackyController.instance;

@override
void initState() {
Expand All @@ -46,16 +43,17 @@ class _SnackyConfiguratorWidgetState extends State<SnackyConfiguratorWidget>

@override
Widget buildSnacky(BuildContext context, CancelableSnacky activeSnacky) {
return Directionality(
textDirection: widget.textDirection,
child: Builder(
builder: (context) => Stack(
key: ValueKey(activeSnacky.hashCode),
alignment: activeSnacky.snacky.location.alignment,
children: [
widget.snackyBuilder.build(context, activeSnacky, snackyController),
],
),
return Builder(
builder: (context) => Stack(
key: ValueKey(activeSnacky.hashCode),
alignment: activeSnacky.snacky.location.alignment,
children: [
widget.snackyBuilder.build(
context,
activeSnacky,
snackyController,
),
],
),
);
}
Expand All @@ -74,8 +72,7 @@ class _SnackyConfiguratorWidgetState extends State<SnackyConfiguratorWidget>

context.visitChildElements(visitor);

assert(navigator != null,
'''It looks like you are not using Navigator in your app.
assert(navigator != null, '''It looks like you are not using Navigator in your app.
Do you wrapped you app widget like this?
SnackyConfiguratorWidget(
app: MaterialApp(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import 'package:flutter/widgets.dart';

class SwipeDetector extends StatefulWidget {
class SnackySwipeDetector extends StatefulWidget {
final Widget child;
final bool enabled;
final AlignmentDirectional alignment;
final VoidCallback onSwipe;

const SwipeDetector({
const SnackySwipeDetector({
required this.child,
required this.enabled,
required this.alignment,
Expand All @@ -15,10 +15,10 @@ class SwipeDetector extends StatefulWidget {
});

@override
State<SwipeDetector> createState() => _SwipeDetectorState();
State<SnackySwipeDetector> createState() => _SnackySwipeDetectorState();
}

class _SwipeDetectorState extends State<SwipeDetector> {
class _SnackySwipeDetectorState extends State<SnackySwipeDetector> {
var _dragPositionY = 0.0;
var _dragPositionStart = 0.0;

Expand All @@ -41,8 +41,7 @@ class _SwipeDetectorState extends State<SwipeDetector> {
// Bottom notification
widget.onSwipe();
}
if (widget.alignment == AlignmentDirectional.topCenter &&
details.globalPosition.dy < _dragPositionY) {
if (widget.alignment == AlignmentDirectional.topCenter && details.globalPosition.dy < _dragPositionY) {
widget.onSwipe();
} else if (widget.alignment == AlignmentDirectional.bottomCenter &&
details.globalPosition.dy > _dragPositionY) {
Expand All @@ -59,8 +58,7 @@ class _SwipeDetectorState extends State<SwipeDetector> {
widget.onSwipe();
} else if (start == 0) {
// Center notification (do nothing)
} else if (start > 0 &&
details.globalPosition.dx > _dragPositionStart) {
} else if (start > 0 && details.globalPosition.dx > _dragPositionStart) {
// End notification
widget.onSwipe();
}
Expand Down

0 comments on commit a8d7066

Please sign in to comment.