|
|
@@ -1,7 +1,7 @@
|
|
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
-import 'package:adaptive_dialog/adaptive_dialog.dart';
|
|
|
+// import 'package:adaptive_dialog/adaptive_dialog.dart';
|
|
|
import 'package:cached_network_image/cached_network_image.dart';
|
|
|
import 'package:device_info_plus/device_info_plus.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
@@ -12,6 +12,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
import 'package:get/get.dart';
|
|
|
import 'package:iquokka/pages/footprint/blank_journal/controller/blank_journal_ctrl.dart';
|
|
|
import 'package:iquokka/utils/base_app_bar.dart';
|
|
|
+import 'package:iquokka/utils/bottom_sheet_dialog.dart';
|
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
|
import 'package:photo_view/photo_view.dart';
|
|
|
import 'package:photo_view/photo_view_gallery.dart';
|
|
|
@@ -23,6 +24,7 @@ import '../../../../common/AC.dart';
|
|
|
import '../../../../gen_a/A.dart';
|
|
|
import '../../../../utils/file_utils.dart';
|
|
|
import '../../../../utils/hex_color.dart';
|
|
|
+import '../../../../utils/modal_action_sheet_dialog.dart';
|
|
|
import '../../../../utils/oss_utils.dart';
|
|
|
import '../../../../utils/picker_img_utils.dart';
|
|
|
import '../../../../utils/time_util.dart';
|
|
|
@@ -229,19 +231,28 @@ class BlankJournalPage extends GetView<BlankJournalCtrl> {
|
|
|
onTap: () async{
|
|
|
controller.titleFocusNode.unfocus();
|
|
|
controller.contentFocusNode.unfocus();
|
|
|
- final result = await showOkCancelAlertDialog(
|
|
|
- context: context,
|
|
|
- okLabel: "删除照片".tr,
|
|
|
- cancelLabel: "取消".tr,
|
|
|
- isDestructiveAction: true,
|
|
|
- style: AdaptiveStyle.iOS,
|
|
|
- useActionSheetForIOS: true,
|
|
|
+ // final result = await showOkCancelAlertDialog(
|
|
|
+ // context: context,
|
|
|
+ // okLabel: "删除照片".tr,
|
|
|
+ // cancelLabel: "取消".tr,
|
|
|
+ // isDestructiveAction: true,
|
|
|
+ // style: AdaptiveStyle.iOS,
|
|
|
+ // useActionSheetForIOS: true,
|
|
|
+ // );
|
|
|
+ // if (result == OkCancelResult.ok) {
|
|
|
+ // _.imageList.removeAt(index);
|
|
|
+ // _.update(["text", "photoButton"]);
|
|
|
+ // //controller.saveImageToDraft();
|
|
|
+ // }
|
|
|
+
|
|
|
+ BottomSheetDialog.showSheet(
|
|
|
+ sureText: "删除照片".tr,
|
|
|
+ cancelText: "取消".tr,
|
|
|
+ sureHandle: (){
|
|
|
+ _.imageList.removeAt(index);
|
|
|
+ _.update(["text", "photoButton"]);
|
|
|
+ }
|
|
|
);
|
|
|
- if (result == OkCancelResult.ok) {
|
|
|
- _.imageList.removeAt(index);
|
|
|
- _.update(["text", "photoButton"]);
|
|
|
- //controller.saveImageToDraft();
|
|
|
- }
|
|
|
},
|
|
|
),
|
|
|
)
|
|
|
@@ -436,29 +447,48 @@ class BlankJournalPage extends GetView<BlankJournalCtrl> {
|
|
|
),
|
|
|
),
|
|
|
onTap: () async{
|
|
|
- final result = await showOkCancelAlertDialog(
|
|
|
- context: Get.context!,
|
|
|
- okLabel: "删除照片".tr,
|
|
|
- cancelLabel: "取消".tr,
|
|
|
- isDestructiveAction: true,
|
|
|
- style: AdaptiveStyle.iOS,
|
|
|
- useActionSheetForIOS: true,
|
|
|
- );
|
|
|
- if (result == OkCancelResult.ok) {
|
|
|
- controller.imageList.removeAt(flagIndex);
|
|
|
- if (controller.imageList.isNotEmpty) {
|
|
|
- if (flagIndex >= controller.imageList.length) {
|
|
|
- flagIndex -= 1;
|
|
|
- pageController = PageController(initialPage: flagIndex);
|
|
|
+ // final result = await showOkCancelAlertDialog(
|
|
|
+ // context: Get.context!,
|
|
|
+ // okLabel: "删除照片".tr,
|
|
|
+ // cancelLabel: "取消".tr,
|
|
|
+ // isDestructiveAction: true,
|
|
|
+ // style: AdaptiveStyle.iOS,
|
|
|
+ // useActionSheetForIOS: true,
|
|
|
+ // );
|
|
|
+ // if (result == OkCancelResult.ok) {
|
|
|
+ // controller.imageList.removeAt(flagIndex);
|
|
|
+ // if (controller.imageList.isNotEmpty) {
|
|
|
+ // if (flagIndex >= controller.imageList.length) {
|
|
|
+ // flagIndex -= 1;
|
|
|
+ // pageController = PageController(initialPage: flagIndex);
|
|
|
+ // }
|
|
|
+ // controller.update(["text", "photoButton", "big_photo"]);
|
|
|
+ // }
|
|
|
+ // else {
|
|
|
+ // Get.back();
|
|
|
+ // controller.update(["text", "photoButton"]);
|
|
|
+ // }
|
|
|
+ // //controller.saveImageToDraft();
|
|
|
+ // }
|
|
|
+
|
|
|
+ BottomSheetDialog.showSheet(
|
|
|
+ sureText: "删除照片".tr,
|
|
|
+ cancelText: "取消".tr,
|
|
|
+ sureHandle: (){
|
|
|
+ controller.imageList.removeAt(flagIndex);
|
|
|
+ if (controller.imageList.isNotEmpty) {
|
|
|
+ if (flagIndex >= controller.imageList.length) {
|
|
|
+ flagIndex -= 1;
|
|
|
+ pageController = PageController(initialPage: flagIndex);
|
|
|
+ }
|
|
|
+ controller.update(["text", "photoButton", "big_photo"]);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Get.back();
|
|
|
+ controller.update(["text", "photoButton"]);
|
|
|
+ }
|
|
|
}
|
|
|
- controller.update(["text", "photoButton", "big_photo"]);
|
|
|
- }
|
|
|
- else {
|
|
|
- Get.back();
|
|
|
- controller.update(["text", "photoButton"]);
|
|
|
- }
|
|
|
- //controller.saveImageToDraft();
|
|
|
- }
|
|
|
+ );
|
|
|
},
|
|
|
),
|
|
|
],
|
|
|
@@ -486,68 +516,131 @@ class BlankJournalPage extends GetView<BlankJournalCtrl> {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- final result = await showModalActionSheet<int>(
|
|
|
- context: Get.context!,
|
|
|
- cancelLabel: "取消".tr,
|
|
|
- style: AdaptiveStyle.iOS,
|
|
|
- actions: [
|
|
|
- SheetAction(key: 0, label: "拍照".tr),
|
|
|
- SheetAction(key: 1, label: "从相册中选取".tr),
|
|
|
- ]
|
|
|
- );
|
|
|
- if (result == 0){ //拍照
|
|
|
- if (UniversalPlatform.isAndroid) {
|
|
|
- PermissionStatus camerasStatus = await Permission.camera.status;
|
|
|
- if (camerasStatus.isGranted) {
|
|
|
- _takePhone();
|
|
|
+ // final result = await showModalActionSheet<int>(
|
|
|
+ // context: Get.context!,
|
|
|
+ // cancelLabel: "取消".tr,
|
|
|
+ // style: AdaptiveStyle.iOS,
|
|
|
+ // actions: [
|
|
|
+ // SheetAction(key: 0, label: "拍照".tr),
|
|
|
+ // SheetAction(key: 1, label: "从相册中选取".tr),
|
|
|
+ // ]
|
|
|
+ // );
|
|
|
+ // if (result == 0){ //拍照
|
|
|
+ // if (UniversalPlatform.isAndroid) {
|
|
|
+ // PermissionStatus camerasStatus = await Permission.camera.status;
|
|
|
+ // if (camerasStatus.isGranted) {
|
|
|
+ // _takePhone();
|
|
|
+ // }
|
|
|
+ // else {
|
|
|
+ // TipsDialog.showDialog(
|
|
|
+ // title: "温馨提示".tr,
|
|
|
+ // content: "心境奇旅将使用您的相机权限拍照上传心情记录图片".tr,
|
|
|
+ // cancelText: "取消".tr,
|
|
|
+ // sureText: "确定".tr,
|
|
|
+ // sureHandle: (){
|
|
|
+ // _takePhone();
|
|
|
+ // }
|
|
|
+ // );
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // else {
|
|
|
+ // _takePhone();
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // else if (result == 1) { //从相册中选取
|
|
|
+ // if (UniversalPlatform.isAndroid) {
|
|
|
+ // AndroidDeviceInfo androidInfo = await DeviceInfoPlugin().androidInfo;
|
|
|
+ // String androidBrand = androidInfo.brand.toLowerCase();
|
|
|
+ // if (androidBrand == "huawei" || androidBrand == "honor") {
|
|
|
+ // if (await Permission.storage.status.isGranted) {
|
|
|
+ // _selectPhotosInPhotoAlbum();
|
|
|
+ // }
|
|
|
+ // else {
|
|
|
+ // TipsDialog.showDialog(
|
|
|
+ // title: "温馨提示".tr,
|
|
|
+ // content: "心境奇旅将使用您的相册存储权限以选取相册中的图片".tr,
|
|
|
+ // cancelText: "取消".tr,
|
|
|
+ // sureText: "确定".tr,
|
|
|
+ // cancelHandle: (){
|
|
|
+ // return false;
|
|
|
+ // },
|
|
|
+ // sureHandle: () async {
|
|
|
+ // _selectPhotosInPhotoAlbum();
|
|
|
+ // }
|
|
|
+ // );
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // else {
|
|
|
+ // _selectPhotosInPhotoAlbum();
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // else {
|
|
|
+ // _selectPhotosInPhotoAlbum();
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ ModalActionSheetDialog.showSheet(
|
|
|
+ cancelText: "取消".tr,
|
|
|
+ actions: [
|
|
|
+ ActionSheetModel(id: 0, name: "拍照".tr),
|
|
|
+ ActionSheetModel(id: 1, name: "从相册中选取".tr)
|
|
|
+ ],
|
|
|
+ actionHandle: (result) async {
|
|
|
+ if (result == 0){ //拍照
|
|
|
+ if (UniversalPlatform.isAndroid) {
|
|
|
+ PermissionStatus camerasStatus = await Permission.camera.status;
|
|
|
+ if (camerasStatus.isGranted) {
|
|
|
+ _takePhone();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ TipsDialog.showDialog(
|
|
|
+ title: "温馨提示".tr,
|
|
|
+ content: "心境奇旅将使用您的相机权限拍照上传心情记录图片".tr,
|
|
|
+ cancelText: "取消".tr,
|
|
|
+ sureText: "确定".tr,
|
|
|
+ sureHandle: (){
|
|
|
+ _takePhone();
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ _takePhone();
|
|
|
+ }
|
|
|
}
|
|
|
- else {
|
|
|
- TipsDialog.showDialog(
|
|
|
- title: "温馨提示".tr,
|
|
|
- content: "心境奇旅将使用您的相机权限拍照上传心情记录图片".tr,
|
|
|
- cancelText: "取消".tr,
|
|
|
- sureText: "确定".tr,
|
|
|
- sureHandle: (){
|
|
|
- _takePhone();
|
|
|
+ else if (result == 1) { //从相册中选取
|
|
|
+ if (UniversalPlatform.isAndroid) {
|
|
|
+ AndroidDeviceInfo androidInfo = await DeviceInfoPlugin().androidInfo;
|
|
|
+ String androidBrand = androidInfo.brand.toLowerCase();
|
|
|
+ if (androidBrand == "huawei" || androidBrand == "honor") {
|
|
|
+ if (await Permission.storage.status.isGranted) {
|
|
|
+ _selectPhotosInPhotoAlbum();
|
|
|
}
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- _takePhone();
|
|
|
- }
|
|
|
- }
|
|
|
- else if (result == 1) { //从相册中选取
|
|
|
- if (UniversalPlatform.isAndroid) {
|
|
|
- AndroidDeviceInfo androidInfo = await DeviceInfoPlugin().androidInfo;
|
|
|
- String androidBrand = androidInfo.brand.toLowerCase();
|
|
|
- if (androidBrand == "huawei" || androidBrand == "honor") {
|
|
|
- if (await Permission.storage.status.isGranted) {
|
|
|
- _selectPhotosInPhotoAlbum();
|
|
|
+ else {
|
|
|
+ TipsDialog.showDialog(
|
|
|
+ title: "温馨提示".tr,
|
|
|
+ content: "心境奇旅将使用您的相册存储权限以选取相册中的图片".tr,
|
|
|
+ cancelText: "取消".tr,
|
|
|
+ sureText: "确定".tr,
|
|
|
+ cancelHandle: (){
|
|
|
+ return false;
|
|
|
+ },
|
|
|
+ sureHandle: () async {
|
|
|
+ _selectPhotosInPhotoAlbum();
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ _selectPhotosInPhotoAlbum();
|
|
|
+ }
|
|
|
}
|
|
|
else {
|
|
|
- TipsDialog.showDialog(
|
|
|
- title: "温馨提示".tr,
|
|
|
- content: "心境奇旅将使用您的相册存储权限以选取相册中的图片".tr,
|
|
|
- cancelText: "取消".tr,
|
|
|
- sureText: "确定".tr,
|
|
|
- cancelHandle: (){
|
|
|
- return false;
|
|
|
- },
|
|
|
- sureHandle: () async {
|
|
|
- _selectPhotosInPhotoAlbum();
|
|
|
- }
|
|
|
- );
|
|
|
+ _selectPhotosInPhotoAlbum();
|
|
|
}
|
|
|
}
|
|
|
- else {
|
|
|
- _selectPhotosInPhotoAlbum();
|
|
|
- }
|
|
|
}
|
|
|
- else {
|
|
|
- _selectPhotosInPhotoAlbum();
|
|
|
- }
|
|
|
- }
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
// 拍照
|