Problems after version 0.3.1 have been resolved

This commit is contained in:
Furkan 2023-01-21 03:43:51 +03:00
parent 0cab155c53
commit 875d3030a4
10 changed files with 193 additions and 150 deletions

View File

@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"permission_handler_apple","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler_apple-9.0.7\\\\","native_build":true,"dependencies":[]},{"name":"photo_gallery","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\photo_gallery-1.1.1\\\\","native_build":true,"dependencies":[]},{"name":"video_player_avfoundation","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\video_player_avfoundation-2.3.8\\\\","native_build":true,"dependencies":[]},{"name":"video_thumbnail","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\video_thumbnail-0.5.3\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"permission_handler_android","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler_android-10.2.0\\\\","native_build":true,"dependencies":[]},{"name":"photo_gallery","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\photo_gallery-1.1.1\\\\","native_build":true,"dependencies":[]},{"name":"video_player_android","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\video_player_android-2.3.10\\\\","native_build":true,"dependencies":[]},{"name":"video_thumbnail","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\video_thumbnail-0.5.3\\\\","native_build":true,"dependencies":[]}],"macos":[],"linux":[],"windows":[{"name":"permission_handler_windows","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler_windows-0.1.2\\\\","native_build":true,"dependencies":[]}],"web":[{"name":"video_player_web","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\video_player_web-2.0.13\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"permission_handler","dependencies":["permission_handler_android","permission_handler_apple","permission_handler_windows"]},{"name":"permission_handler_android","dependencies":[]},{"name":"permission_handler_apple","dependencies":[]},{"name":"permission_handler_windows","dependencies":[]},{"name":"photo_gallery","dependencies":[]},{"name":"video_player","dependencies":["video_player_android","video_player_avfoundation","video_player_web"]},{"name":"video_player_android","dependencies":[]},{"name":"video_player_avfoundation","dependencies":[]},{"name":"video_player_web","dependencies":[]},{"name":"video_thumbnail","dependencies":[]}],"date_created":"2023-01-20 10:38:51.103847","version":"3.3.10"} {"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"permission_handler_apple","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler_apple-9.0.7\\\\","native_build":true,"dependencies":[]},{"name":"photo_gallery","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\photo_gallery-1.1.1\\\\","native_build":true,"dependencies":[]},{"name":"video_player_avfoundation","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\video_player_avfoundation-2.3.8\\\\","native_build":true,"dependencies":[]},{"name":"video_thumbnail","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\video_thumbnail-0.5.3\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"permission_handler_android","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler_android-10.2.0\\\\","native_build":true,"dependencies":[]},{"name":"photo_gallery","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\photo_gallery-1.1.1\\\\","native_build":true,"dependencies":[]},{"name":"video_player_android","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\video_player_android-2.3.10\\\\","native_build":true,"dependencies":[]},{"name":"video_thumbnail","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\video_thumbnail-0.5.3\\\\","native_build":true,"dependencies":[]}],"macos":[],"linux":[],"windows":[{"name":"permission_handler_windows","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler_windows-0.1.2\\\\","native_build":true,"dependencies":[]}],"web":[{"name":"video_player_web","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\video_player_web-2.0.13\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"permission_handler","dependencies":["permission_handler_android","permission_handler_apple","permission_handler_windows"]},{"name":"permission_handler_android","dependencies":[]},{"name":"permission_handler_apple","dependencies":[]},{"name":"permission_handler_windows","dependencies":[]},{"name":"photo_gallery","dependencies":[]},{"name":"video_player","dependencies":["video_player_android","video_player_avfoundation","video_player_web"]},{"name":"video_player_android","dependencies":[]},{"name":"video_player_avfoundation","dependencies":[]},{"name":"video_player_web","dependencies":[]},{"name":"video_thumbnail","dependencies":[]}],"date_created":"2023-01-21 03:35:10.968143","version":"3.3.10"}

View File

@ -103,4 +103,8 @@
## 0.3.1 ## 0.3.1
* fixes formatting issues * fixes formatting issues
## 0.3.2
* Problems after version 0.3.1 have been resolved

View File

@ -224,6 +224,7 @@ A Config class is provided to user to customize your gallery picker. You can cus
```dart ```dart
List<MediaFile>? media = await GalleryPicker.pickMedia( List<MediaFile>? media = await GalleryPicker.pickMedia(
context: context, context: context,
pageTransitionType: PageTransitionType.rightToLeft
config: Config( config: Config(
backgroundColor: Colors.white, backgroundColor: Colors.white,
permissionDeniedPage:PermissionDeniedPage(), permissionDeniedPage:PermissionDeniedPage(),

View File

@ -173,7 +173,6 @@ class _MyHomePageState extends State<MyHomePage> {
Future<void> pickMedia() async { Future<void> pickMedia() async {
List<MediaFile>? media = await GalleryPicker.pickMedia( List<MediaFile>? media = await GalleryPicker.pickMedia(
context: context, context: context,
config: Config(lastWeek: "Bu hafta"),
initSelectedMedia: selectedMedias, initSelectedMedia: selectedMedias,
extraRecentMedia: selectedMedias, extraRecentMedia: selectedMedias,
startWithRecent: true); startWithRecent: true);

View File

@ -21,7 +21,7 @@ packages:
name: bottom_sheet_scaffold name: bottom_sheet_scaffold
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.1.1" version: "0.1.2"
camera: camera:
dependency: "direct dev" dependency: "direct dev"
description: description:
@ -141,7 +141,7 @@ packages:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "0.3.1" version: "0.3.2"
get: get:
dependency: transitive dependency: transitive
description: description:
@ -198,6 +198,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.0" version: "1.8.0"
page_transition:
dependency: transitive
description:
name: page_transition
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.9"
path: path:
dependency: transitive dependency: transitive
description: description:

View File

@ -47,7 +47,7 @@ class PhoneGalleryController extends GetxController {
late bool startWithRecent; late bool startWithRecent;
late bool isRecent; late bool isRecent;
bool permissionGranted = false; bool? permissionGranted;
bool configurationCompleted = false; bool configurationCompleted = false;
late Function(List<MediaFile> selectedMedias) onSelect; late Function(List<MediaFile> selectedMedias) onSelect;
Widget Function(String tag, MediaFile media, BuildContext context)? Widget Function(String tag, MediaFile media, BuildContext context)?
@ -70,12 +70,13 @@ class PhoneGalleryController extends GetxController {
GalleryAlbum? selectedAlbum; GalleryAlbum? selectedAlbum;
void resetBottomSheetView() { void resetBottomSheetView() {
if (permissionGranted) { if (permissionGranted == true) {
isRecent = true; isRecent = true;
if (selectedAlbum == null) { if (selectedAlbum == null) {
pickerPageController.jumpToPage(0); pickerPageController.jumpToPage(0);
} else { } else {
pageController.jumpToPage(0); pageController.jumpToPage(0);
pickerPageController = PageController();
} }
selectedAlbum = null; selectedAlbum = null;
update(); update();
@ -112,6 +113,7 @@ class PhoneGalleryController extends GetxController {
required bool isBottomSheet}) async { required bool isBottomSheet}) async {
_selectedFiles.clear(); _selectedFiles.clear();
selectedAlbum = album; selectedAlbum = album;
update();
updatePickerListener(); updatePickerListener();
await pageController.animateToPage(1, await pageController.animateToPage(1,
duration: const Duration(milliseconds: 500), curve: Curves.easeIn); duration: const Duration(milliseconds: 500), curve: Curves.easeIn);
@ -121,9 +123,11 @@ class PhoneGalleryController extends GetxController {
_selectedFiles.clear(); _selectedFiles.clear();
_pickerMode = false; _pickerMode = false;
pickerPageController = PageController(initialPage: 1); pickerPageController = PageController(initialPage: 1);
update();
await pageController.animateToPage(0, await pageController.animateToPage(0,
duration: const Duration(milliseconds: 500), curve: Curves.easeIn); duration: const Duration(milliseconds: 500), curve: Curves.easeIn);
selectedAlbum = null; selectedAlbum = null;
update();
} }
void unselectMedia(MediaFile file) { void unselectMedia(MediaFile file) {

View File

@ -6,6 +6,7 @@ export 'models/mode.dart';
export 'models/medium.dart'; export 'models/medium.dart';
export 'models/gallery_media.dart'; export 'models/gallery_media.dart';
export 'models/gallery_album.dart'; export 'models/gallery_album.dart';
export 'package:page_transition/src/enum.dart';
export 'user_widgets/thumbnail_media.dart'; export 'user_widgets/thumbnail_media.dart';
export 'user_widgets/album_categories_view.dart'; export 'user_widgets/album_categories_view.dart';
export 'user_widgets/album_media_view.dart'; export 'user_widgets/album_media_view.dart';
@ -21,6 +22,7 @@ import 'package:bottom_sheet_scaffold/bottom_sheet_scaffold.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:gallery_picker/models/gallery_media.dart'; import 'package:gallery_picker/models/gallery_media.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:page_transition/page_transition.dart';
import '../../controller/gallery_controller.dart'; import '../../controller/gallery_controller.dart';
import 'controller/picker_listener.dart'; import 'controller/picker_listener.dart';
import 'models/config.dart'; import 'models/config.dart';
@ -49,24 +51,25 @@ class GalleryPicker {
{Config? config, {Config? config,
bool startWithRecent = false, bool startWithRecent = false,
bool singleMedia = false, bool singleMedia = false,
PageTransitionType pageTransitionType = PageTransitionType.rightToLeft,
List<MediaFile>? initSelectedMedia, List<MediaFile>? initSelectedMedia,
List<MediaFile>? extraRecentMedia, List<MediaFile>? extraRecentMedia,
required BuildContext context}) async { required BuildContext context}) async {
List<MediaFile>? media; List<MediaFile>? media;
await Navigator.push( await Navigator.push(
context, context,
MaterialPageRoute( PageTransition(
builder: (context) => GalleryPickerView( type: pageTransitionType,
onSelect: (mediaTmp) { child: GalleryPickerView(
media = mediaTmp; onSelect: (mediaTmp) {
}, media = mediaTmp;
config: config, },
singleMedia: singleMedia, config: config,
initSelectedMedia: initSelectedMedia, singleMedia: singleMedia,
extraRecentMedia: extraRecentMedia, initSelectedMedia: initSelectedMedia,
startWithRecent: startWithRecent, extraRecentMedia: extraRecentMedia,
)), startWithRecent: startWithRecent,
); )));
return media; return media;
} }
@ -77,24 +80,25 @@ class GalleryPicker {
Widget Function(String tag, MediaFile media, BuildContext context)? Widget Function(String tag, MediaFile media, BuildContext context)?
heroBuilder, heroBuilder,
bool singleMedia = false, bool singleMedia = false,
PageTransitionType pageTransitionType = PageTransitionType.rightToLeft,
List<MediaFile>? initSelectedMedia, List<MediaFile>? initSelectedMedia,
List<MediaFile>? extraRecentMedia, List<MediaFile>? extraRecentMedia,
bool startWithRecent = false, bool startWithRecent = false,
required BuildContext context}) async { required BuildContext context}) async {
await Navigator.push( await Navigator.push(
context, context,
MaterialPageRoute( PageTransition(
builder: (context) => GalleryPickerView( type: pageTransitionType,
onSelect: (media) {}, child: GalleryPickerView(
multipleMediaBuilder: multipleMediaBuilder, onSelect: (media) {},
heroBuilder: heroBuilder, multipleMediaBuilder: multipleMediaBuilder,
singleMedia: singleMedia, heroBuilder: heroBuilder,
config: config, singleMedia: singleMedia,
initSelectedMedia: initSelectedMedia, config: config,
extraRecentMedia: extraRecentMedia, initSelectedMedia: initSelectedMedia,
startWithRecent: startWithRecent, extraRecentMedia: extraRecentMedia,
)), startWithRecent: startWithRecent,
); )));
} }
static Future<void> openSheet() async { static Future<void> openSheet() async {
@ -103,9 +107,6 @@ class GalleryPicker {
static Future<void> closeSheet() async { static Future<void> closeSheet() async {
BottomSheetPanel.close(); BottomSheetPanel.close();
if (GetInstance().isRegistered<PhoneGalleryController>()) {
Get.find<PhoneGalleryController>().resetBottomSheetView();
}
} }
static bool get isSheetOpened { static bool get isSheetOpened {

View File

@ -89,122 +89,133 @@ class _GalleryPickerState extends State<GalleryPickerView> {
double width = MediaQuery.of(context).size.width; double width = MediaQuery.of(context).size.width;
return GetBuilder<PhoneGalleryController>(builder: (controller) { return GetBuilder<PhoneGalleryController>(builder: (controller) {
return GetInstance().isRegistered<PhoneGalleryController>() return GetInstance().isRegistered<PhoneGalleryController>()
? controller.permissionGranted ? controller.permissionGranted != false
? PageView( ? PageView(
controller: controller.pageController, controller: controller.pageController,
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
children: [ children: [
Scaffold( WillPopScope(
backgroundColor: config.backgroundColor, child: Scaffold(
appBar: PickerAppBar( backgroundColor: config.backgroundColor,
controller: controller, appBar: PickerAppBar(
isBottomSheet: widget.isBottomSheet, controller: controller,
), isBottomSheet: widget.isBottomSheet,
body: Column( ),
children: [ body: Column(
Container( children: [
width: width, Container(
height: 48, width: width,
color: config.appbarColor, height: 48,
child: Row( color: config.appbarColor,
mainAxisAlignment: MainAxisAlignment.spaceAround, child: Row(
children: [ mainAxisAlignment:
Container( MainAxisAlignment.spaceAround,
decoration: controller.isRecent children: [
? BoxDecoration( Container(
border: Border( decoration: controller.isRecent
bottom: BorderSide( ? BoxDecoration(
color: config.underlineColor, border: Border(
width: 3.0, bottom: BorderSide(
), color: config.underlineColor,
)) width: 3.0,
: null, ),
height: 48, ))
width: width / 2, : null,
child: TextButton( height: 48,
onPressed: () { width: width / 2,
controller.pickerPageController child: TextButton(
.animateToPage(0, onPressed: () {
duration: const Duration( controller.pickerPageController
milliseconds: 50), .animateToPage(0,
curve: Curves.easeIn); duration: const Duration(
setState(() { milliseconds: 50),
controller.isRecent = true; curve: Curves.easeIn);
controller.switchPickerMode(false); setState(() {
}); controller.isRecent = true;
}, controller
child: Text(config.recents, .switchPickerMode(false);
style: controller.isRecent });
? config.selectedMenuStyle },
: config.unselectedMenuStyle)), child: Text(config.recents,
style: controller.isRecent
? config.selectedMenuStyle
: config
.unselectedMenuStyle)),
),
Container(
decoration: !controller.isRecent
? BoxDecoration(
border: Border(
bottom: BorderSide(
color: config.underlineColor,
width: 3.0,
),
))
: null,
height: 48,
width: width / 2,
child: TextButton(
onPressed: () {
controller.pickerPageController
.animateToPage(1,
duration: const Duration(
milliseconds: 50),
curve: Curves.easeIn);
controller.isRecent = false;
controller.switchPickerMode(false);
},
child: Text(
config.gallery,
style: controller.isRecent
? config.unselectedMenuStyle
: config.selectedMenuStyle,
)),
)
],
), ),
Container( ),
decoration: !controller.isRecent Expanded(
? BoxDecoration( child: PageView(
border: Border( controller: controller.pickerPageController,
bottom: BorderSide( onPageChanged: (value) {
color: config.underlineColor, if (value == 0) {
width: 3.0, controller.isRecent = true;
), controller.switchPickerMode(false);
)) } else {
: null,
height: 48,
width: width / 2,
child: TextButton(
onPressed: () {
controller.pickerPageController
.animateToPage(1,
duration: const Duration(
milliseconds: 50),
curve: Curves.easeIn);
controller.isRecent = false; controller.isRecent = false;
controller.switchPickerMode(false); controller.switchPickerMode(false);
}, }
child: Text( },
config.gallery, scrollDirection: Axis.horizontal,
style: controller.isRecent children: [
? config.unselectedMenuStyle controller.isInitialized &&
: config.selectedMenuStyle, controller.recent != null
)), ? AlbumMediasView(
) galleryAlbum: controller.recent!,
], controller: controller,
), isBottomSheet:
widget.isBottomSheet,
singleMedia: widget.singleMedia)
: const Center(
child: CircularProgressIndicator(
color: Colors.grey,
)),
AlbumCategoriesView(
controller: controller,
isBottomSheet: widget.isBottomSheet,
singleMedia: widget.singleMedia,
)
]),
),
],
), ),
Expanded( ),
child: PageView( onWillPop: () async {
controller: controller.pickerPageController, if (!widget.isBottomSheet) {
onPageChanged: (value) { controller.disposeController();
if (value == 0) { }
controller.isRecent = true; return true;
controller.switchPickerMode(false); }),
} else {
controller.isRecent = false;
controller.switchPickerMode(false);
}
},
scrollDirection: Axis.horizontal,
children: [
controller.isInitialized &&
controller.recent != null
? AlbumMediasView(
galleryAlbum: controller.recent!,
controller: controller,
isBottomSheet: widget.isBottomSheet,
singleMedia: widget.singleMedia)
: const Center(
child: CircularProgressIndicator(
color: Colors.grey,
)),
AlbumCategoriesView(
controller: controller,
isBottomSheet: widget.isBottomSheet,
singleMedia: widget.singleMedia,
)
]),
),
],
),
),
AlbumPage( AlbumPage(
album: controller.selectedAlbum, album: controller.selectedAlbum,
controller: controller, controller: controller,
@ -212,10 +223,12 @@ class _GalleryPickerState extends State<GalleryPickerView> {
isBottomSheet: widget.isBottomSheet) isBottomSheet: widget.isBottomSheet)
], ],
) )
: controller.config.permissionDeniedPage ?? : Material(
PermissionDeniedView( child: controller.config.permissionDeniedPage ??
config: controller.config, PermissionDeniedView(
) config: controller.config,
),
)
: ReloadGallery( : ReloadGallery(
config, config,
onpressed: () async { onpressed: () async {

View File

@ -109,6 +109,19 @@ class PickerScaffold extends StatelessWidget {
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
bottomNavigationBar: bottomNavigationBar, bottomNavigationBar: bottomNavigationBar,
body: body, body: body,
onWillPop: () async {
if (BottomSheetPanel.isOpen) {
if (GetInstance().isRegistered<PhoneGalleryController>() &&
Get.find<PhoneGalleryController>().selectedAlbum != null) {
Get.find<PhoneGalleryController>().backToPicker();
} else {
BottomSheetPanel.close();
}
return false;
} else {
return true;
}
},
bottomSheet: DraggableBottomSheet( bottomSheet: DraggableBottomSheet(
draggableBody: true, draggableBody: true,
maxHeight: MediaQuery.of(context).size.height, maxHeight: MediaQuery.of(context).size.height,

View File

@ -1,6 +1,6 @@
name: gallery_picker name: gallery_picker
description: Gallery Picker is a flutter package that will allow you to pick media file(s), manage and navigate inside your gallery with modern tools and views. description: Gallery Picker is a flutter package that will allow you to pick media file(s), manage and navigate inside your gallery with modern tools and views.
version: 0.3.1 version: 0.3.2
homepage: https://github.com/FlutterWay/gallery_picker homepage: https://github.com/FlutterWay/gallery_picker
environment: environment:
@ -18,7 +18,8 @@ dependencies:
get: ^4.6.5 get: ^4.6.5
video_thumbnail: ^0.5.3 video_thumbnail: ^0.5.3
intl: ^0.18.0 intl: ^0.18.0
bottom_sheet_scaffold: ^0.1.1 page_transition: ^2.0.9
bottom_sheet_scaffold: ^0.1.2
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter