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

Feature/exposing properties for easy customizations #174

44 changes: 44 additions & 0 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Publish Package

on:
release: [published]

push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Install Flutter
uses: subosito/flutter-action@v1
with:
flutter-version: '1.9.1+hotfix.6'
- name: Install dependencies
run: flutter pub get
- name: Analyze
run: flutter analyze
- name: Run tests
run: flutter test
- name: Setup Pub Credentials
shell: bash
env:
PUB_DEV_PUBLISH_ACCESS_TOKEN: ${{ secrets.PUB_DEV_PUBLISH_ACCESS_TOKEN }}
PUB_DEV_PUBLISH_REFRESH_TOKEN: ${{ secrets.PUB_DEV_PUBLISH_REFRESH_TOKEN }}
PUB_DEV_PUBLISH_TOKEN_ENDPOINT: ${{ secrets.PUB_DEV_PUBLISH_TOKEN_ENDPOINT }}
PUB_DEV_PUBLISH_EXPIRATION: ${{ secrets.PUB_DEV_PUBLISH_EXPIRATION }}
run: |
sh ./pub_login.sh
- name: Check Publish Warnings
run: pub publish --dry-run
- name: Publish Package
run: pub publish -f
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [0.16.5] - 18 Feb 2024
- Bump dependencies to latest
- Added medium to Indicator Height
- Exposed loading and error widget API on both story image and story video
- Exposed outerPaddings API
- onStoryShow callback now returns both storyItem and it's index

## [0.16.3] - 18 Feb 2024
- Test `publish.yml` worflow

Expand Down
40 changes: 34 additions & 6 deletions example/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Home extends StatelessWidget {
),
)
],
onStoryShow: (s) {
onStoryShow: (storyItem, index) {
print("Showing a story");
},
onComplete: () {
Expand Down Expand Up @@ -168,25 +168,53 @@ class _MoreStoriesState extends State<MoreStories> {
StoryItem.pageImage(
url:
"https://image.ibb.co/cU4WGx/Omotuo-Groundnut-Soup-braperucci-com-1.jpg",
caption: "Still sampling",
caption: Text(
"Still sampling",
style: TextStyle(
fontSize: 15,
color: Colors.white,
),
textAlign: TextAlign.center,
),
controller: storyController,
),
StoryItem.pageImage(
url: "https://media.giphy.com/media/5GoVLqeAOo6PK/giphy.gif",
caption: "Working with gifs",
caption: Text(
"Working with gifs",
style: TextStyle(
fontSize: 15,
color: Colors.white,
),
textAlign: TextAlign.center,
),
controller: storyController),
StoryItem.pageImage(
url: "https://media.giphy.com/media/XcA8krYsrEAYXKf4UQ/giphy.gif",
caption: "Hello, from the other side",
caption: Text(
"Hello, from the other side",
style: TextStyle(
fontSize: 15,
color: Colors.white,
),
textAlign: TextAlign.center,
),
controller: storyController,
),
StoryItem.pageImage(
url: "https://media.giphy.com/media/XcA8krYsrEAYXKf4UQ/giphy.gif",
caption: "Hello, from the other side2",
caption: Text(
"Hello, from the other side2",
style: TextStyle(
fontSize: 15,
color: Colors.white,
),
textAlign: TextAlign.center,
),
controller: storyController,
),
],
onStoryShow: (s) {
onStoryShow: (storyItem, index) {
print("Showing a story");
},
onComplete: () {
Expand Down
15 changes: 12 additions & 3 deletions lib/widgets/story_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,16 @@ class StoryImage extends StatefulWidget {
final BoxFit? fit;

final StoryController? controller;
final Widget? loadingWidget;
final Widget? errorWidget;

StoryImage(
this.imageLoader, {
Key? key,
this.controller,
this.fit,
this.loadingWidget,
this.errorWidget,
}) : super(key: key ?? UniqueKey());

/// Use this shorthand to fetch images/gifs from the provided [url]
Expand All @@ -84,6 +88,8 @@ class StoryImage extends StatefulWidget {
StoryController? controller,
Map<String, dynamic>? requestHeaders,
BoxFit fit = BoxFit.fitWidth,
Widget? loadingWidget,
Widget? errorWidget,
Key? key,
}) {
return StoryImage(
Expand All @@ -93,7 +99,10 @@ class StoryImage extends StatefulWidget {
),
controller: controller,
fit: fit,
key: key);
loadingWidget: loadingWidget,
errorWidget: errorWidget,
key: key,
);
}

@override
Expand Down Expand Up @@ -186,15 +195,15 @@ class StoryImageState extends State<StoryImage> {
);
case LoadState.failure:
return Center(
child: Text(
child: widget.errorWidget?? Text(
"Image failed to load.",
style: TextStyle(
color: Colors.white,
),
));
default:
return Center(
child: Container(
child: widget.loadingWidget?? Container(
width: 70,
height: 70,
child: CircularProgressIndicator(
Expand Down
31 changes: 21 additions & 10 deletions lib/widgets/story_video.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,29 @@ class VideoLoader {
class StoryVideo extends StatefulWidget {
final StoryController? storyController;
final VideoLoader videoLoader;

StoryVideo(this.videoLoader, {this.storyController, Key? key})
: super(key: key ?? UniqueKey());

static StoryVideo url(String url,
{StoryController? controller,
Map<String, dynamic>? requestHeaders,
Key? key}) {
final Widget? loadingWidget;
final Widget? errorWidget;

StoryVideo(this.videoLoader, {
Key? key,
this.storyController,
this.loadingWidget,
this.errorWidget,
}) : super(key: key ?? UniqueKey());

static StoryVideo url(String url, {
StoryController? controller,
Map<String, dynamic>? requestHeaders,
Key? key,
Widget? loadingWidget,
Widget? errorWidget,
}) {
return StoryVideo(
VideoLoader(url, requestHeaders: requestHeaders),
storyController: controller,
key: key,
loadingWidget: loadingWidget,
errorWidget: errorWidget,
);
}

Expand Down Expand Up @@ -116,7 +127,7 @@ class StoryVideoState extends State<StoryVideo> {

return widget.videoLoader.state == LoadState.loading
? Center(
child: Container(
child: widget.loadingWidget?? Container(
width: 70,
height: 70,
child: CircularProgressIndicator(
Expand All @@ -126,7 +137,7 @@ class StoryVideoState extends State<StoryVideo> {
),
)
: Center(
child: Text(
child: widget.errorWidget?? Text(
"Media failed to load.",
style: TextStyle(
color: Colors.white,
Expand Down
Loading