From 1bafc21e2a2439260eb072707306079e96a4dfdf Mon Sep 17 00:00:00 2001 From: Pius Fiifi Junior Date: Wed, 20 Dec 2023 17:27:44 +0000 Subject: [PATCH 1/8] Create pub_login.sh --- pub_login.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 pub_login.sh diff --git a/pub_login.sh b/pub_login.sh new file mode 100644 index 00000000..d37fb64f --- /dev/null +++ b/pub_login.sh @@ -0,0 +1,35 @@ +# This script creates/updates credentials.json file which is used +# to authorize publisher when publishing packages to pub.dev + +# Checking whether the secrets are available as environment +# variables or not. +if [ -z "${PUB_DEV_PUBLISH_ACCESS_TOKEN}" ]; then + echo "Missing PUB_DEV_PUBLISH_ACCESS_TOKEN environment variable" + exit 1 +fi + +if [ -z "${PUB_DEV_PUBLISH_REFRESH_TOKEN}" ]; then + echo "Missing PUB_DEV_PUBLISH_REFRESH_TOKEN environment variable" + exit 1 +fi + +if [ -z "${PUB_DEV_PUBLISH_TOKEN_ENDPOINT}" ]; then + echo "Missing PUB_DEV_PUBLISH_TOKEN_ENDPOINT environment variable" + exit 1 +fi + +if [ -z "${PUB_DEV_PUBLISH_EXPIRATION}" ]; then + echo "Missing PUB_DEV_PUBLISH_EXPIRATION environment variable" + exit 1 +fi + +# Create credentials.json file. +cat < ~/.pub-cache/credentials.json +{ + "accessToken":"${PUB_DEV_PUBLISH_ACCESS_TOKEN}", + "refreshToken":"${PUB_DEV_PUBLISH_REFRESH_TOKEN}", + "tokenEndpoint":"${PUB_DEV_PUBLISH_TOKEN_ENDPOINT}", + "scopes":["https://www.googleapis.com/auth/userinfo.email","openid"], + "expiration":${PUB_DEV_PUBLISH_EXPIRATION} +} +EOF From b96db1403955697dffc2b562b7d514b0df796240 Mon Sep 17 00:00:00 2001 From: Pius Fiifi Junior Date: Wed, 20 Dec 2023 17:33:20 +0000 Subject: [PATCH 2/8] Create publish.yml --- .github/workflows/dart.yml | 44 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/dart.yml diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml new file mode 100644 index 00000000..ddbb4a08 --- /dev/null +++ b/.github/workflows/dart.yml @@ -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 From 72c52498e009fa7ff0e669e3d4ef6e60988dd356 Mon Sep 17 00:00:00 2001 From: Fiifi Pius Date: Sun, 11 Feb 2024 13:53:28 +0000 Subject: [PATCH 3/8] updated dependencies --- pubspec.lock | 30 +++++++++++++++--------------- pubspec.yaml | 4 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index e7404331..1ba05721 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -37,10 +37,10 @@ packages: dependency: "direct main" description: name: collection - sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.17.2" + version: "1.18.0" crypto: dependency: transitive description: @@ -148,10 +148,10 @@ packages: dependency: transitive description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" path: dependency: transitive description: @@ -273,18 +273,18 @@ packages: dependency: transitive description: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" string_scanner: dependency: transitive description: @@ -313,10 +313,10 @@ packages: dependency: transitive description: name: test_api - sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" url: "https://pub.dev" source: hosted - version: "0.6.0" + version: "0.6.1" typed_data: dependency: transitive description: @@ -345,10 +345,10 @@ packages: dependency: "direct main" description: name: video_player - sha256: e16f0a83601a78d165dabc17e4dac50997604eb9e4cc76e10fa219046b70cef3 + sha256: fbf28ce8bcfe709ad91b5789166c832cb7a684d14f571a81891858fefb5bb1c2 url: "https://pub.dev" source: hosted - version: "2.8.1" + version: "2.8.2" video_player_android: dependency: transitive description: @@ -385,10 +385,10 @@ packages: dependency: transitive description: name: web - sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 url: "https://pub.dev" source: hosted - version: "0.1.4-beta" + version: "0.3.0" win32: dependency: transitive description: @@ -406,5 +406,5 @@ packages: source: hosted version: "1.0.3" sdks: - dart: ">=3.1.0 <4.0.0" + dart: ">=3.2.0-194.0.dev <4.0.0" flutter: ">=3.13.0" diff --git a/pubspec.yaml b/pubspec.yaml index d0062e66..265b502f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,8 +11,8 @@ dependencies: sdk: flutter flutter_cache_manager: ^3.3.1 rxdart: ^0.27.7 - video_player: ^2.8.1 - collection: ^1.17.2 + video_player: ^2.8.2 + collection: ^1.18.0 dev_dependencies: flutter_test: From 8e031b14243db9832c166da34d5575570950334c Mon Sep 17 00:00:00 2001 From: Fiifi Pius Date: Sun, 11 Feb 2024 13:55:57 +0000 Subject: [PATCH 4/8] updated example changes --- example/example.dart | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/example/example.dart b/example/example.dart index cceeb54b..e5c2bce4 100644 --- a/example/example.dart +++ b/example/example.dart @@ -82,7 +82,7 @@ class Home extends StatelessWidget { ), ) ], - onStoryShow: (s) { + onStoryShow: (storyItem, index) { print("Showing a story"); }, onComplete: () { @@ -168,25 +168,53 @@ class _MoreStoriesState extends State { 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: () { From 76b382c3f766b8f0dd2370dfa6f14c47f5fe9c02 Mon Sep 17 00:00:00 2001 From: Fiifi Pius Date: Sun, 11 Feb 2024 13:56:44 +0000 Subject: [PATCH 5/8] exposed loading widget and error widget on story image --- lib/widgets/story_image.dart | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/widgets/story_image.dart b/lib/widgets/story_image.dart index f88babd5..6f3d333e 100644 --- a/lib/widgets/story_image.dart +++ b/lib/widgets/story_image.dart @@ -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] @@ -84,6 +88,8 @@ class StoryImage extends StatefulWidget { StoryController? controller, Map? requestHeaders, BoxFit fit = BoxFit.fitWidth, + Widget? loadingWidget, + Widget? errorWidget, Key? key, }) { return StoryImage( @@ -93,7 +99,10 @@ class StoryImage extends StatefulWidget { ), controller: controller, fit: fit, - key: key); + loadingWidget: loadingWidget, + errorWidget: errorWidget, + key: key, + ); } @override @@ -186,7 +195,7 @@ class StoryImageState extends State { ); case LoadState.failure: return Center( - child: Text( + child: widget.errorWidget?? Text( "Image failed to load.", style: TextStyle( color: Colors.white, @@ -194,7 +203,7 @@ class StoryImageState extends State { )); default: return Center( - child: Container( + child: widget.loadingWidget?? Container( width: 70, height: 70, child: CircularProgressIndicator( From 6de13e84f97c13313cc4f023abad52e94bf256a9 Mon Sep 17 00:00:00 2001 From: Fiifi Pius Date: Sun, 11 Feb 2024 13:56:51 +0000 Subject: [PATCH 6/8] exposed loading widget and error widget on story video --- lib/widgets/story_video.dart | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/lib/widgets/story_video.dart b/lib/widgets/story_video.dart index 8924855b..0c46f1c2 100644 --- a/lib/widgets/story_video.dart +++ b/lib/widgets/story_video.dart @@ -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? 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? requestHeaders, + Key? key, + Widget? loadingWidget, + Widget? errorWidget, + }) { return StoryVideo( VideoLoader(url, requestHeaders: requestHeaders), storyController: controller, key: key, + loadingWidget: loadingWidget, + errorWidget: errorWidget, ); } @@ -116,7 +127,7 @@ class StoryVideoState extends State { return widget.videoLoader.state == LoadState.loading ? Center( - child: Container( + child: widget.loadingWidget?? Container( width: 70, height: 70, child: CircularProgressIndicator( @@ -126,7 +137,7 @@ class StoryVideoState extends State { ), ) : Center( - child: Text( + child: widget.errorWidget?? Text( "Media failed to load.", style: TextStyle( color: Colors.white, From 11ecfe0b8bd32eb34a4b4d1b9cb255a935665633 Mon Sep 17 00:00:00 2001 From: Fiifi Pius Date: Sun, 11 Feb 2024 14:00:00 +0000 Subject: [PATCH 7/8] added medium to IndicatorHeight exposed outerPaddings to widgets, exposed loading and error widgets onStoryShow callback now has storyItem and index as params --- lib/widgets/story_view.dart | 83 ++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/lib/widgets/story_view.dart b/lib/widgets/story_view.dart index 630665c6..3a6e8db1 100644 --- a/lib/widgets/story_view.dart +++ b/lib/widgets/story_view.dart @@ -14,7 +14,7 @@ enum ProgressPosition { top, bottom, none } /// This is used to specify the height of the progress indicator. Inline stories /// should use [small] -enum IndicatorHeight { small, large } +enum IndicatorHeight { small, medium, large } /// This is a representation of a story item (or page). class StoryItem { @@ -56,6 +56,7 @@ class StoryItem { bool shown = false, bool roundedTop = false, bool roundedBottom = false, + EdgeInsetsGeometry? textOuterPadding, Duration? duration, }) { double contrast = ContrastHelper.contrast([ @@ -78,7 +79,7 @@ class StoryItem { bottom: Radius.circular(roundedBottom ? 8 : 0), ), ), - padding: EdgeInsets.symmetric( + padding: textOuterPadding?? EdgeInsets.symmetric( horizontal: 24, vertical: 16, ), @@ -109,9 +110,12 @@ class StoryItem { required StoryController controller, Key? key, BoxFit imageFit = BoxFit.fitWidth, - String? caption, + Text? caption, bool shown = false, Map? requestHeaders, + Widget? loadingWidget, + Widget? errorWidget, + EdgeInsetsGeometry? captionOuterPadding, Duration? duration, }) { return StoryItem( @@ -125,6 +129,8 @@ class StoryItem { controller: controller, fit: imageFit, requestHeaders: requestHeaders, + loadingWidget: loadingWidget, + errorWidget: errorWidget, ), SafeArea( child: Align( @@ -134,21 +140,12 @@ class StoryItem { margin: EdgeInsets.only( bottom: 24, ), - padding: EdgeInsets.symmetric( + padding: captionOuterPadding?? EdgeInsets.symmetric( horizontal: 24, vertical: 8, ), color: caption != null ? Colors.black54 : Colors.transparent, - child: caption != null - ? Text( - caption, - style: TextStyle( - fontSize: 15, - color: Colors.white, - ), - textAlign: TextAlign.center, - ) - : SizedBox(), + child: caption?? const SizedBox.shrink(), ), ), ) @@ -172,6 +169,9 @@ class StoryItem { bool shown = false, bool roundedTop = true, bool roundedBottom = false, + Widget? loadingWidget, + Widget? errorWidget, + EdgeInsetsGeometry? captionOuterPadding, Duration? duration, }) { return StoryItem( @@ -188,14 +188,16 @@ class StoryItem { controller: controller, fit: imageFit, requestHeaders: requestHeaders, + loadingWidget: loadingWidget, + errorWidget: errorWidget, ), Container( margin: EdgeInsets.only(bottom: 16), - padding: EdgeInsets.symmetric(horizontal: 24, vertical: 8), + padding: captionOuterPadding?? EdgeInsets.symmetric(horizontal: 24, vertical: 8), child: Align( alignment: Alignment.bottomLeft, child: Container( - child: caption == null ? SizedBox() : caption, + child: caption?? const SizedBox.shrink(), width: double.infinity, ), ), @@ -222,9 +224,11 @@ class StoryItem { Key? key, Duration? duration, BoxFit imageFit = BoxFit.fitWidth, - String? caption, + Widget? caption, bool shown = false, Map? requestHeaders, + Widget? loadingWidget, + Widget? errorWidget, }) { return StoryItem( Container( @@ -236,6 +240,8 @@ class StoryItem { url, controller: controller, requestHeaders: requestHeaders, + loadingWidget: loadingWidget, + errorWidget: errorWidget, ), SafeArea( child: Align( @@ -246,13 +252,7 @@ class StoryItem { padding: EdgeInsets.symmetric(horizontal: 24, vertical: 8), color: caption != null ? Colors.black54 : Colors.transparent, - child: caption != null - ? Text( - caption, - style: TextStyle(fontSize: 15, color: Colors.white), - textAlign: TextAlign.center, - ) - : SizedBox(), + child: caption?? const SizedBox.shrink(), ), ), ) @@ -387,8 +387,8 @@ class StoryView extends StatefulWidget { /// provide this callback so as to enable scroll events on the list view. final Function(Direction?)? onVerticalSwipeComplete; - /// Callback for when a story is currently being shown. - final ValueChanged? onStoryShow; + /// Callback for when a story and it index is currently being shown. + final void Function(StoryItem storyItem, int index)? onStoryShow; /// Where the progress indicator should be placed. final ProgressPosition progressPosition; @@ -401,14 +401,20 @@ class StoryView extends StatefulWidget { /// a [ListView] or [Column]) then set this to `true`. final bool inline; - // Controls the playback of the stories + /// Controls the playback of the stories final StoryController controller; - // Indicator Color + /// Indicator Color final Color? indicatorColor; - // Indicator Foreground Color + /// Indicator Foreground Color final Color? indicatorForegroundColor; + /// Determine the height of the indicator + final IndicatorHeight indicatorHeight; + + /// Use this if you want to give outer padding to the indicator + final EdgeInsetsGeometry indicatorOuterPadding; + StoryView({ required this.storyItems, required this.controller, @@ -420,6 +426,8 @@ class StoryView extends StatefulWidget { this.onVerticalSwipeComplete, this.indicatorColor, this.indicatorForegroundColor, + this.indicatorHeight = IndicatorHeight.large, + this.indicatorOuterPadding = const EdgeInsets.symmetric(horizontal: 16, vertical: 8,), }); @override @@ -517,8 +525,10 @@ class StoryViewState extends State with TickerProviderStateMixin { return !it!.shown; })!; + final storyItemIndex = widget.storyItems.indexOf(storyItem); + if (widget.onStoryShow != null) { - widget.onStoryShow!(storyItem); + widget.onStoryShow!(storyItem, storyItemIndex); } _animationController = @@ -634,19 +644,14 @@ class StoryViewState extends State with TickerProviderStateMixin { bottom: widget.inline ? false : true, // we use SafeArea here for notched and bezeles phones child: Container( - padding: EdgeInsets.symmetric( - horizontal: 16, - vertical: 8, - ), + padding: widget.indicatorOuterPadding, child: PageBar( widget.storyItems .map((it) => PageData(it!.duration, it.shown)) .toList(), this._currentAnimation, key: UniqueKey(), - indicatorHeight: widget.inline - ? IndicatorHeight.small - : IndicatorHeight.large, + indicatorHeight: widget.indicatorHeight, indicatorColor: widget.indicatorColor, indicatorForegroundColor: widget.indicatorForegroundColor, ), @@ -763,7 +768,7 @@ class PageBarState extends State { super.initState(); int count = widget.pages.length; - spacing = (count > 15) ? 1 : ((count > 10) ? 2 : 4); + spacing = (count > 15) ? 2 : ((count > 10) ? 3 : 4); widget.animation!.addListener(() { setState(() {}); @@ -792,7 +797,7 @@ class PageBarState extends State { child: StoryProgressIndicator( isPlaying(it) ? widget.animation!.value : (it.shown ? 1 : 0), indicatorHeight: - widget.indicatorHeight == IndicatorHeight.large ? 5 : 3, + widget.indicatorHeight == IndicatorHeight.large ? 5 : widget.indicatorHeight == IndicatorHeight.medium ? 3 : 2, indicatorColor: widget.indicatorColor, indicatorForegroundColor: widget.indicatorForegroundColor, ), From 5eec52fceebc0960482490c2b71e00edccced3cf Mon Sep 17 00:00:00 2001 From: Fiifi Pius Date: Sun, 18 Feb 2024 14:17:50 +0000 Subject: [PATCH 8/8] added changed log --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50891751..892c5321 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## [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 + ## [0.16.0] - 30 November 2023 - Replace `PaintingBinding` with `ui`