Skip to content
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

Added Content of the story, witch has haptic logics. So it should be at the top of the Stack to handle haptic events #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
28 changes: 23 additions & 5 deletions lib/widgets/story_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,17 @@ class StoryItem {
/// story item.
bool shown;

/// Content of the story, witch has haptic logics. So it should be at the top of
/// the Stack to handle haptic events
final Widget hapticContent;

/// The page content
final Widget view;
StoryItem(
this.view, {
this.duration,
this.shown = false,
this.duration,
this.hapticContent,
this.shown = false,
}) : assert(duration != null, "[duration] should not be null");

/// Short hand to create text-only page.
Expand All @@ -56,6 +61,7 @@ class StoryItem {
bool shown = false,
bool roundedTop = false,
bool roundedBottom = false,
Widget hapticContent,
Duration duration,
}) {
double contrast = ContrastHelper.contrast([
Expand Down Expand Up @@ -98,6 +104,7 @@ class StoryItem {
//color: backgroundColor,
),
shown: shown,
hapticContent: hapticContent,
duration: duration ?? Duration(seconds: 3),
);
}
Expand All @@ -110,6 +117,7 @@ class StoryItem {
Key key,
BoxFit imageFit = BoxFit.fitWidth,
String caption,
Widget hapticContent,
bool shown = false,
Map<String, dynamic> requestHeaders,
Duration duration,
Expand Down Expand Up @@ -156,6 +164,7 @@ class StoryItem {
),
),
shown: shown,
hapticContent: hapticContent,
duration: duration ?? Duration(seconds: 3),
);
}
Expand All @@ -172,6 +181,7 @@ class StoryItem {
bool shown = false,
bool roundedTop = true,
bool roundedBottom = false,
Widget hapticContent,
Duration duration,
}) {
return StoryItem(
Expand Down Expand Up @@ -210,6 +220,7 @@ class StoryItem {
),
),
shown: shown,
hapticContent: hapticContent,
duration: duration ?? Duration(seconds: 3),
);
}
Expand All @@ -223,6 +234,7 @@ class StoryItem {
Duration duration,
BoxFit imageFit = BoxFit.fitWidth,
String caption,
Widget hapticContent,
bool shown = false,
Map<String, dynamic> requestHeaders,
}) {
Expand Down Expand Up @@ -260,6 +272,7 @@ class StoryItem {
),
),
shown: shown,
hapticContent: hapticContent,
duration: duration ?? Duration(seconds: 10));
}

Expand All @@ -271,6 +284,7 @@ class StoryItem {
Key key,
BoxFit imageFit = BoxFit.fitWidth,
String caption,
Widget hapticContent,
bool shown = false,
Duration duration,
}) {
Expand Down Expand Up @@ -320,6 +334,7 @@ class StoryItem {
),
),
shown: shown,
hapticContent: hapticContent,
duration: duration ?? Duration(seconds: 3));
}

Expand All @@ -330,6 +345,7 @@ class StoryItem {
ImageProvider image, {
Key key,
Text caption,
Widget hapticContent,
bool shown = false,
bool roundedTop = true,
bool roundedBottom = false,
Expand Down Expand Up @@ -366,6 +382,7 @@ class StoryItem {
),
),
shown: shown,
hapticContent: hapticContent,
duration: duration ?? Duration(seconds: 3),
);
}
Expand Down Expand Up @@ -440,10 +457,10 @@ class StoryViewState extends State<StoryView> with TickerProviderStateMixin {

StoryItem get _currentStory =>
widget.storyItems.firstWhere((it) => !it.shown, orElse: () => null);
StoryItem get _currentOrLastStory => widget.storyItems
.firstWhere((it) => !it.shown, orElse: () => widget.storyItems.last);

Widget get _currentView => widget.storyItems
.firstWhere((it) => !it.shown, orElse: () => widget.storyItems.last)
.view;
Widget get _currentView => _currentOrLastStory.view;

@override
void initState() {
Expand Down Expand Up @@ -714,6 +731,7 @@ class StoryViewState extends State<StoryView> with TickerProviderStateMixin {
}),
width: 70),
),
_currentOrLastStory.hapticContent ?? const SizedBox.shrink()
],
),
);
Expand Down