diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies new file mode 100644 index 0000000..c8a6d41 --- /dev/null +++ b/.flutter-plugins-dependencies @@ -0,0 +1 @@ +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_keyboard_visibility","path":"C:\\\\Users\\\\gian_\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_keyboard_visibility-5.4.0\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"flutter_keyboard_visibility","path":"C:\\\\Users\\\\gian_\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_keyboard_visibility-5.4.0\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"flutter_keyboard_visibility_macos","path":"C:\\\\Users\\\\gian_\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_keyboard_visibility_macos-1.0.0\\\\","native_build":false,"dependencies":[]}],"linux":[{"name":"flutter_keyboard_visibility_linux","path":"C:\\\\Users\\\\gian_\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_keyboard_visibility_linux-1.0.0\\\\","native_build":false,"dependencies":[]}],"windows":[{"name":"flutter_keyboard_visibility_windows","path":"C:\\\\Users\\\\gian_\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_keyboard_visibility_windows-1.0.0\\\\","native_build":false,"dependencies":[]}],"web":[{"name":"flutter_keyboard_visibility_web","path":"C:\\\\Users\\\\gian_\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_keyboard_visibility_web-2.0.0\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_keyboard_visibility","dependencies":["flutter_keyboard_visibility_linux","flutter_keyboard_visibility_macos","flutter_keyboard_visibility_web","flutter_keyboard_visibility_windows"]},{"name":"flutter_keyboard_visibility_linux","dependencies":[]},{"name":"flutter_keyboard_visibility_macos","dependencies":[]},{"name":"flutter_keyboard_visibility_web","dependencies":[]},{"name":"flutter_keyboard_visibility_windows","dependencies":[]}],"date_created":"2023-04-19 21:51:08.892689","version":"3.7.11"} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index b39fc66..d82f069 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.1.8] - 2023-04-19 +- Added safeAreaList parameter [PR#174](https://github.com/Pyozer/introduction_screen/pull/174) + ## [3.1.7] - 2023-03-16 - Added hideBottomOnKeyboard parameter [PR#171](https://github.com/Pyozer/introduction_screen/pull/171) diff --git a/README.md b/README.md index 638e942..0273535 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ You just need to add `introduction_screen` as a [dependency in your pubspec.yaml ```yaml dependencies: - introduction_screen: ^3.1.7 + introduction_screen: ^3.1.8 ``` ## Examples @@ -459,6 +459,7 @@ This is the full list: - Change default implicit scrolling behavior by adding `allowImplicitScrolling: true` - Default `false` - Reference: [PageView's `allowImplicitScrolling` parameter](https://api.flutter.dev/flutter/widgets/PageView/PageView.html) +- Activate the SafeArea by setting `safeAreaList: [true,true,true,true]` parameter. ### PageViewModel parameters diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart deleted file mode 100644 index 0404c05..0000000 --- a/example/test/widget_test.dart +++ /dev/null @@ -1,29 +0,0 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility in the flutter_test package. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. - -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:introduction_example/main.dart'; - -void main() { - testWidgets('Counter increments smoke test', (WidgetTester tester) async { - // Build our app and trigger a frame. - await tester.pumpWidget(const App()); - - // Verify that our counter starts at 0. - expect(find.text('0'), findsOneWidget); - expect(find.text('1'), findsNothing); - - // Tap the '+' icon and trigger a frame. - await tester.tap(find.byIcon(Icons.add)); - await tester.pump(); - - // Verify that our counter has incremented. - expect(find.text('0'), findsNothing); - expect(find.text('1'), findsOneWidget); - }); -} diff --git a/lib/src/introduction_screen.dart b/lib/src/introduction_screen.dart index d3d24d6..62506fa 100644 --- a/lib/src/introduction_screen.dart +++ b/lib/src/introduction_screen.dart @@ -254,6 +254,12 @@ class IntroductionScreen extends StatefulWidget { /// @Default `false` final bool allowImplicitScrolling; + /// PageView's bool safe area list. + /// the list defines if the safe area will be active on left,right,top and bottom, respectively. + /// + /// @Default `[false,false,false,false]` + final List safeAreaList; + /// A handler to check if the user is allowed to progress to the next page. /// If returned value is true, the page will progress to the next page, otherwise the page will not progress. /// In order to make it work properly with TextFormField, you should place setState in the onChanged callback of the TextFormField. @@ -332,6 +338,7 @@ class IntroductionScreen extends StatefulWidget { this.rtl = false, this.allowImplicitScrolling = false, this.canProgress = defaultCanProgressFunction, + this.safeAreaList = const [false,false,false,false] }) : assert( pages != null || rawPages != null, "You must set either 'pages' or 'rawPages' parameter", @@ -551,106 +558,112 @@ class IntroductionScreenState extends State { ); } - return Scaffold( - backgroundColor: widget.globalBackgroundColor, - resizeToAvoidBottomInset: widget.resizeToAvoidBottomInset, - body: Stack( - children: [ - Positioned.fill( - top: widget.bodyPadding.top, - left: widget.bodyPadding.left, - right: widget.bodyPadding.right, - bottom: widget.bodyPadding.bottom, - child: NotificationListener( - onNotification: _onScroll, - child: PageView( - reverse: widget.rtl, - scrollDirection: widget.pagesAxis, - controller: _pageController, - onPageChanged: widget.onChange, - allowImplicitScrolling: widget.allowImplicitScrolling, - physics: widget.freeze - ? const NeverScrollableScrollPhysics() - : !widget.canProgress(_currentPage) - ? const NeverScrollableScrollPhysics() - : widget.scrollPhysics, - children: widget.pages - ?.mapIndexed( - (index, page) => IntroPage( - page: page, - scrollController: - (CustomList(widget.scrollControllers) - ?.elementAtOrNull(index)), - isTopSafeArea: widget.isTopSafeArea, - isBottomSafeArea: widget.isBottomSafeArea, - ), - ) - .toList() ?? - widget.rawPages!, + return SafeArea( + left: widget.safeAreaList[0], + right: widget.safeAreaList[1], + top: widget.safeAreaList[2], + bottom: widget.safeAreaList[3], + child: Scaffold( + backgroundColor: widget.globalBackgroundColor, + resizeToAvoidBottomInset: widget.resizeToAvoidBottomInset, + body: Stack( + children: [ + Positioned.fill( + top: widget.bodyPadding.top, + left: widget.bodyPadding.left, + right: widget.bodyPadding.right, + bottom: widget.bodyPadding.bottom, + child: NotificationListener( + onNotification: _onScroll, + child: PageView( + reverse: widget.rtl, + scrollDirection: widget.pagesAxis, + controller: _pageController, + onPageChanged: widget.onChange, + allowImplicitScrolling: widget.allowImplicitScrolling, + physics: widget.freeze + ? const NeverScrollableScrollPhysics() + : !widget.canProgress(_currentPage) + ? const NeverScrollableScrollPhysics() + : widget.scrollPhysics, + children: widget.pages + ?.mapIndexed( + (index, page) => IntroPage( + page: page, + scrollController: + (CustomList(widget.scrollControllers) + ?.elementAtOrNull(index)), + isTopSafeArea: widget.isTopSafeArea, + isBottomSafeArea: widget.isBottomSafeArea, + ), + ) + .toList() ?? + widget.rawPages!, + ), ), ), - ), - if (widget.globalHeader != null) - Positioned( - top: 0, - left: 0, - right: 0, - child: widget.globalHeader!, - ), - if (_showBottom) - Positioned( - left: widget.controlsPosition.left, - top: widget.controlsPosition.top, - right: widget.controlsPosition.right, - bottom: widget.controlsPosition.bottom, - child: Column( - children: [ - Container( - padding: widget.controlsPadding, - margin: widget.controlsMargin, - decoration: widget.dotsContainerDecorator, - child: Row( - children: [ - Expanded( - flex: widget.skipOrBackFlex, - child: leftBtn ?? const SizedBox(), - ), - Expanded( - flex: widget.dotsFlex, - child: Center( - child: widget.isProgress - ? widget.customProgress ?? - Semantics( - label: - "Page ${_currentPage.round() + 1} of ${getPagesLength()}", - excludeSemantics: true, - child: DotsIndicator( - reversed: widget.rtl, - dotsCount: getPagesLength(), - position: _currentPage, - decorator: widget.dotsDecorator, - onTap: widget.isProgressTap && - !widget.freeze - ? (pos) => - animateScroll(pos.toInt()) - : null, - ), - ) - : const SizedBox(), + if (widget.globalHeader != null) + Positioned( + top: 0, + left: 0, + right: 0, + child: widget.globalHeader!, + ), + if (_showBottom) + Positioned( + left: widget.controlsPosition.left, + top: widget.controlsPosition.top, + right: widget.controlsPosition.right, + bottom: widget.controlsPosition.bottom, + child: Column( + children: [ + Container( + padding: widget.controlsPadding, + margin: widget.controlsMargin, + decoration: widget.dotsContainerDecorator, + child: Row( + children: [ + Expanded( + flex: widget.skipOrBackFlex, + child: leftBtn ?? const SizedBox(), ), - ), - Expanded( - flex: widget.nextFlex, - child: rightBtn ?? const SizedBox(), - ), - ].asReversed(widget.rtl), + Expanded( + flex: widget.dotsFlex, + child: Center( + child: widget.isProgress + ? widget.customProgress ?? + Semantics( + label: + "Page ${_currentPage.round() + 1} of ${getPagesLength()}", + excludeSemantics: true, + child: DotsIndicator( + reversed: widget.rtl, + dotsCount: getPagesLength(), + position: _currentPage, + decorator: widget.dotsDecorator, + onTap: widget.isProgressTap && + !widget.freeze + ? (pos) => + animateScroll(pos.toInt()) + : null, + ), + ) + : const SizedBox(), + ), + ), + Expanded( + flex: widget.nextFlex, + child: rightBtn ?? const SizedBox(), + ), + ].asReversed(widget.rtl), + ), ), - ), - if (widget.globalFooter != null) widget.globalFooter! - ], + if (widget.globalFooter != null) widget.globalFooter! + ], + ), ), - ), - ], + ], + ), ), ); } diff --git a/pubspec.yaml b/pubspec.yaml index bbd58f5..56d4dd2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: introduction_screen description: Introduction/Onboarding package for flutter app with some customizations possibilities -version: 3.1.7 +version: 3.1.8 homepage: https://github.com/pyozer/introduction_screen