fix: 1.not display inout records when changing date 2.reduce image upload quality
This commit is contained in:
parent
cc8ef3e1a8
commit
61e09970d4
|
@ -29,15 +29,15 @@ if (flutterVersionName == null) {
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace "com.sdkj.skt"
|
namespace "com.sdkj.skt"
|
||||||
compileSdkVersion flutter.compileSdkVersion
|
compileSdkVersion 34
|
||||||
ndkVersion flutter.ndkVersion
|
ndkVersion flutter.ndkVersion
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_17
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_17
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = '1.8'
|
jvmTarget = '17'
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
|
@ -50,8 +50,7 @@ android {
|
||||||
// You can update the following values to match your application needs.
|
// You can update the following values to match your application needs.
|
||||||
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
|
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
|
||||||
minSdkVersion flutter.minSdkVersion
|
minSdkVersion flutter.minSdkVersion
|
||||||
targetSdkVersion flutter.targetSdkVersion
|
targetSdkVersion 34
|
||||||
compileSdkVersion 34
|
|
||||||
versionCode flutterVersionCode.toInteger()
|
versionCode flutterVersionCode.toInteger()
|
||||||
versionName flutterVersionName
|
versionName flutterVersionName
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
package com.sdkj.sk_base_mobile
|
||||||
|
|
||||||
|
import io.flutter.embedding.android.FlutterActivity
|
||||||
|
|
||||||
|
class MainActivity: FlutterActivity() {
|
||||||
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.7.10'
|
ext.kotlin_version = '1.9.22'
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:7.4.0' // Change this to a version that supports compileSdkVersion 34
|
classpath 'com.android.tools.build:gradle:8.0.2' // Change this to a version that supports compileSdkVersion 34
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import 'package:sk_base_mobile/util/logger_util.dart';
|
||||||
import 'package:sk_base_mobile/util/media_util.dart';
|
import 'package:sk_base_mobile/util/media_util.dart';
|
||||||
import 'package:sk_base_mobile/util/screen_adaper_util.dart';
|
import 'package:sk_base_mobile/util/screen_adaper_util.dart';
|
||||||
import 'package:sk_base_mobile/util/snack_bar.util.dart';
|
import 'package:sk_base_mobile/util/snack_bar.util.dart';
|
||||||
|
import 'package:sk_base_mobile/util/util.dart';
|
||||||
import 'package:sk_base_mobile/widgets/common/multi-picker/models/value_item.dart';
|
import 'package:sk_base_mobile/widgets/common/multi-picker/models/value_item.dart';
|
||||||
import 'package:sk_base_mobile/widgets/core/sk_cascade_picker.dart';
|
import 'package:sk_base_mobile/widgets/core/sk_cascade_picker.dart';
|
||||||
import 'package:sk_base_mobile/widgets/core/sk_dialog_header.dart';
|
import 'package:sk_base_mobile/widgets/core/sk_dialog_header.dart';
|
||||||
|
@ -392,9 +393,19 @@ class EditUserInfoController extends GetxController {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> photoPicker() async {
|
Future<void> photoPicker() async {
|
||||||
XFile? pickedFile = await MediaUtil().getImageFromGallery();
|
await MediaUtil().showPicker(callback: (path) async {
|
||||||
if (pickedFile != null) {
|
if (path != null) {
|
||||||
filePath.value = pickedFile.path;
|
filePath.value = path;
|
||||||
}
|
// 拿到照片大小多少MB
|
||||||
|
final file = File(path);
|
||||||
|
final size = await file.length();
|
||||||
|
final sizeInMb = size / (1024 * 1024);
|
||||||
|
print(sizeInMb);
|
||||||
|
// if (sizeInMb > 2) {
|
||||||
|
// SnackBarUtil().error('图片大小不能超过2MB');
|
||||||
|
// filePath.value = '';
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,16 +10,15 @@ import 'package:sk_base_mobile/widgets/fade_in_cache_image.dart';
|
||||||
import '../../../constants/enum.dart';
|
import '../../../constants/enum.dart';
|
||||||
|
|
||||||
class InventoryInoutCard extends StatelessWidget {
|
class InventoryInoutCard extends StatelessWidget {
|
||||||
InventoryInoutCard({super.key, required this.index, required this.ind});
|
InventoryInoutCard({super.key, required this.index});
|
||||||
final int index;
|
final int index;
|
||||||
final int ind;
|
|
||||||
final controller = Get.find<InventoryInoutController>();
|
final controller = Get.find<InventoryInoutController>();
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
controller
|
controller
|
||||||
.showInventoryInoutInfoDialog(controller.list[ind][index].id!);
|
.showInventoryInoutInfoDialog(controller.inoutList[index].id!);
|
||||||
},
|
},
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
|
@ -67,7 +66,7 @@ class InventoryInoutCard extends StatelessWidget {
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
controller.list[ind][index].product?.name ?? '-',
|
controller.inoutList[index].product?.name ?? '-',
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
|
@ -77,7 +76,7 @@ class InventoryInoutCard extends StatelessWidget {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
controller.list[ind][index].product?.company?.name ?? '-',
|
controller.inoutList[index].product?.company?.name ?? '-',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: AppTheme.grey, fontSize: ScreenAdaper.height(20)),
|
color: AppTheme.grey, fontSize: ScreenAdaper.height(20)),
|
||||||
),
|
),
|
||||||
|
@ -88,7 +87,7 @@ class InventoryInoutCard extends StatelessWidget {
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
'${controller.list[ind][index].project?.name}',
|
'${controller.inoutList[index].project?.name}',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: AppTheme.grey, fontSize: ScreenAdaper.height(20)),
|
color: AppTheme.grey, fontSize: ScreenAdaper.height(20)),
|
||||||
),
|
),
|
||||||
|
@ -102,18 +101,18 @@ class InventoryInoutCard extends StatelessWidget {
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
'${controller.list[ind][index].quantity} ${controller.list[ind][index].product?.unit?.label ?? '-'}',
|
'${controller.inoutList[index].quantity} ${controller.inoutList[index].product?.unit?.label ?? '-'}',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: ScreenAdaper.height(20),
|
fontSize: ScreenAdaper.height(20),
|
||||||
fontWeight: FontWeight.w600),
|
fontWeight: FontWeight.w600),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'${SkDateUtil.format(controller.list[ind][index].time!, formats: [
|
'${SkDateUtil.format(controller.inoutList[index].time!, formats: [
|
||||||
'HH',
|
'HH',
|
||||||
':',
|
':',
|
||||||
"nn"
|
"nn"
|
||||||
])} ${controller.list[ind][index].agent ?? '-'}',
|
])} ${controller.inoutList[index].agent ?? '-'}',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: ScreenAdaper.height(20),
|
fontSize: ScreenAdaper.height(20),
|
||||||
fontWeight: FontWeight.w600),
|
fontWeight: FontWeight.w600),
|
||||||
|
@ -132,19 +131,19 @@ class InventoryInoutCard extends StatelessWidget {
|
||||||
child: FadeInCacheImage(
|
child: FadeInCacheImage(
|
||||||
width: ScreenAdaper.height(150),
|
width: ScreenAdaper.height(150),
|
||||||
height: ScreenAdaper.height(150),
|
height: ScreenAdaper.height(150),
|
||||||
url: controller.list[ind][index].files.isNotEmpty
|
url: controller.inoutList[index].files.isNotEmpty
|
||||||
? '${GloablConfig.OSS_URL}${controller.list[ind][index].files[0].path}'
|
? '${GloablConfig.OSS_URL}${controller.inoutList[index].files[0].path}'
|
||||||
: ''),
|
: ''),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildInOrOut() {
|
Widget buildInOrOut() {
|
||||||
final bgColor =
|
final bgColor =
|
||||||
controller.list[ind][index].inOrOut == InventoryInOrOutEnum.In
|
controller.inoutList[index].inOrOut == InventoryInOrOutEnum.In
|
||||||
? AppTheme.snackbarSuccessBackgroudColor
|
? AppTheme.snackbarSuccessBackgroudColor
|
||||||
: AppTheme.snackbarErrorBackgroudColor;
|
: AppTheme.snackbarErrorBackgroudColor;
|
||||||
final textInOut =
|
final textInOut =
|
||||||
controller.list[ind][index].inOrOut == InventoryInOrOutEnum.In
|
controller.inoutList[index].inOrOut == InventoryInOrOutEnum.In
|
||||||
? '入'
|
? '入'
|
||||||
: '出';
|
: '出';
|
||||||
return Container(
|
return Container(
|
||||||
|
|
|
@ -17,33 +17,26 @@ class InventoryInoutViewItem extends StatelessWidget {
|
||||||
return Responsive(
|
return Responsive(
|
||||||
tablet: Grid(
|
tablet: Grid(
|
||||||
columnNum: 2,
|
columnNum: 2,
|
||||||
ind: index,
|
|
||||||
),
|
),
|
||||||
largeTablet: Grid(
|
largeTablet: Grid(
|
||||||
columnNum: 3,
|
columnNum: 3,
|
||||||
ind: index,
|
|
||||||
),
|
),
|
||||||
mobile: Grid(
|
mobile: Grid(
|
||||||
columnNum: 1,
|
columnNum: 1,
|
||||||
ind: index,
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Grid extends StatelessWidget {
|
class Grid extends StatelessWidget {
|
||||||
final int columnNum;
|
final int columnNum;
|
||||||
int ind;
|
|
||||||
final controller = Get.find<InventoryInoutController>();
|
final controller = Get.find<InventoryInoutController>();
|
||||||
Grid({super.key, required this.columnNum, required this.ind});
|
Grid({super.key, required this.columnNum});
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (controller.currentIndex.value != ind) {
|
|
||||||
ind = controller.currentIndex.value;
|
|
||||||
}
|
|
||||||
return Obx(
|
return Obx(
|
||||||
() => controller.loading.value
|
() => controller.loading.value
|
||||||
? const LoadingIndicator(common: true)
|
? const LoadingIndicator(common: true)
|
||||||
: controller.list[ind].isEmpty
|
: controller.inoutList.isEmpty
|
||||||
? Center(
|
? Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
TextEnum.noInventoryInout,
|
TextEnum.noInventoryInout,
|
||||||
|
@ -57,11 +50,10 @@ class Grid extends StatelessWidget {
|
||||||
: MasonryGridView.count(
|
: MasonryGridView.count(
|
||||||
padding: EdgeInsets.only(top: ScreenAdaper.height(60)),
|
padding: EdgeInsets.only(top: ScreenAdaper.height(60)),
|
||||||
crossAxisCount: columnNum,
|
crossAxisCount: columnNum,
|
||||||
itemCount: controller.list[ind].length,
|
itemCount: controller.inoutList.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
return InventoryInoutCard(
|
return InventoryInoutCard(
|
||||||
index: index,
|
index: index,
|
||||||
ind: ind,
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
@ -19,17 +19,8 @@ class InventoryInoutController extends GetxController {
|
||||||
final PageController pageController = PageController();
|
final PageController pageController = PageController();
|
||||||
Rx<DateTime> endTime = Rx<DateTime>(DateTime.now());
|
Rx<DateTime> endTime = Rx<DateTime>(DateTime.now());
|
||||||
final DbHelper db = DbHelper();
|
final DbHelper db = DbHelper();
|
||||||
List<RxList<InventoryInOutModel>> list = [
|
RxList<InventoryInOutModel> inoutList = <InventoryInOutModel>[].obs;
|
||||||
<InventoryInOutModel>[].obs,
|
|
||||||
<InventoryInOutModel>[].obs,
|
|
||||||
<InventoryInOutModel>[].obs,
|
|
||||||
<InventoryInOutModel>[].obs,
|
|
||||||
<InventoryInOutModel>[].obs,
|
|
||||||
<InventoryInOutModel>[].obs,
|
|
||||||
<InventoryInOutModel>[].obs,
|
|
||||||
].obs;
|
|
||||||
RxInt barIndex = 0.obs;
|
RxInt barIndex = 0.obs;
|
||||||
RxList model = [].obs;
|
|
||||||
final ScrollController scrollController = ScrollController();
|
final ScrollController scrollController = ScrollController();
|
||||||
final RefreshController refreshController = RefreshController();
|
final RefreshController refreshController = RefreshController();
|
||||||
final daysNum = 20;
|
final daysNum = 20;
|
||||||
|
@ -242,7 +233,7 @@ class InventoryInoutController extends GetxController {
|
||||||
).then((value) => {Get.delete<InventoryInouInfoController>()});
|
).then((value) => {Get.delete<InventoryInouInfoController>()});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<InventoryInOutModel>> getInoutHistory() async {
|
Future<void> getInoutHistory() async {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
await Future.delayed(const Duration(milliseconds: 500));
|
await Future.delayed(const Duration(milliseconds: 500));
|
||||||
final selectedDate = SkDateUtil.format(
|
final selectedDate = SkDateUtil.format(
|
||||||
|
@ -252,24 +243,17 @@ class InventoryInoutController extends GetxController {
|
||||||
'time': [selectedDate, selectedDate]
|
'time': [selectedDate, selectedDate]
|
||||||
});
|
});
|
||||||
if (res.data != null) {
|
if (res.data != null) {
|
||||||
return res.data!.items
|
inoutList.assignAll(res.data!.items
|
||||||
.map((e) => InventoryInOutModel.fromJson(e))
|
.map((e) => InventoryInOutModel.fromJson(e))
|
||||||
.toList();
|
.toList());
|
||||||
}
|
}
|
||||||
return [];
|
|
||||||
} catch (e) {
|
|
||||||
print(e);
|
|
||||||
return [];
|
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getData() async {
|
getData() async {
|
||||||
getInoutHistory().then((value) {
|
await getInoutHistory();
|
||||||
model.value = value;
|
|
||||||
getSepretLists();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setEndTime(DateTime newEndTime) async {
|
setEndTime(DateTime newEndTime) async {
|
||||||
|
@ -292,23 +276,6 @@ class InventoryInoutController extends GetxController {
|
||||||
endTime.value.add(Duration(days: -(daysNum - value))));
|
endTime.value.add(Duration(days: -(daysNum - value))));
|
||||||
}
|
}
|
||||||
|
|
||||||
getSepretLists() {
|
|
||||||
List<RxList<InventoryInOutModel>> tempList = [];
|
|
||||||
for (int i = daysNum; i > 0; i--) {
|
|
||||||
RxList<InventoryInOutModel> tempList1 = <InventoryInOutModel>[].obs;
|
|
||||||
tempList1.clear();
|
|
||||||
for (int j = 0; j < model.length; j++) {
|
|
||||||
final sourceDateStr = SkDateUtil.format(model[j].time);
|
|
||||||
final currentDateStr = getDateAccordingTabs(i);
|
|
||||||
if (sourceDateStr == currentDateStr) {
|
|
||||||
tempList1.add(model[j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tempList.add(tempList1);
|
|
||||||
}
|
|
||||||
list.assignAll(tempList);
|
|
||||||
}
|
|
||||||
|
|
||||||
onMoveNextPage() {
|
onMoveNextPage() {
|
||||||
if (currentIndex.value > 0) {
|
if (currentIndex.value > 0) {
|
||||||
setIndex(currentIndex.value - 1);
|
setIndex(currentIndex.value - 1);
|
||||||
|
|
|
@ -538,7 +538,7 @@ class SaleQuotationPage extends StatelessWidget {
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
width: ScreenAdaper.width(unitPriceWidth),
|
width: ScreenAdaper.width(unitPriceWidth),
|
||||||
child: Text(
|
child: Text(
|
||||||
CommonUtil.toNumberWithout0(controller
|
CommonUtil.toNumberWithoutZero(controller
|
||||||
.groups[groupIndex].items[rowIndex].unitPrice),
|
.groups[groupIndex].items[rowIndex].unitPrice),
|
||||||
style: TextStyle(fontSize: ScreenAdaper.height(25)),
|
style: TextStyle(fontSize: ScreenAdaper.height(25)),
|
||||||
),
|
),
|
||||||
|
@ -553,7 +553,7 @@ class SaleQuotationPage extends StatelessWidget {
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
width: ScreenAdaper.width(amountWidth),
|
width: ScreenAdaper.width(amountWidth),
|
||||||
child: Text(
|
child: Text(
|
||||||
CommonUtil.toNumberWithout0(
|
CommonUtil.toNumberWithoutZero(
|
||||||
controller.groups[groupIndex].items[rowIndex].amount),
|
controller.groups[groupIndex].items[rowIndex].amount),
|
||||||
style: TextStyle(fontSize: ScreenAdaper.height(25)),
|
style: TextStyle(fontSize: ScreenAdaper.height(25)),
|
||||||
),
|
),
|
||||||
|
@ -607,8 +607,9 @@ class SaleQuotationPage extends StatelessWidget {
|
||||||
horizontal: ScreenAdaper.width(20),
|
horizontal: ScreenAdaper.width(20),
|
||||||
vertical: ScreenAdaper.height(10)),
|
vertical: ScreenAdaper.height(10)),
|
||||||
textController: TextEditingController(
|
textController: TextEditingController(
|
||||||
text:
|
text: value == 0
|
||||||
value == 0 ? '' : CommonUtil.toNumberWithout0(value))),
|
? ''
|
||||||
|
: CommonUtil.toNumberWithoutZero(value))),
|
||||||
)
|
)
|
||||||
: InkWell(
|
: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
|
|
@ -127,7 +127,7 @@ class DioService extends get_package.GetxService {
|
||||||
}
|
}
|
||||||
|
|
||||||
void onResponse(Response response, ResponseInterceptorHandler handler) async {
|
void onResponse(Response response, ResponseInterceptorHandler handler) async {
|
||||||
/* LoggerUtil().info('[Service-dio] ${response.data}'); */
|
LoggerUtil().info('[Service-dio] ${response.data}');
|
||||||
|
|
||||||
if (whiteList.firstWhereOrNull(
|
if (whiteList.firstWhereOrNull(
|
||||||
(item) => response.requestOptions.path.contains(item)) !=
|
(item) => response.requestOptions.path.contains(item)) !=
|
||||||
|
|
|
@ -37,9 +37,13 @@ class CommonUtil {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static String toNumberWithout0(num num) {
|
static String toNumberWithoutZero(num num) {
|
||||||
return num.toStringAsFixed(num.truncateToDouble() == num ? 0 : 2);
|
return num.toStringAsFixed(num.truncateToDouble() == num ? 0 : 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static String addZeroOnFront(num num) {
|
||||||
|
return num.toString().padLeft(2, '0');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TreeNode<T> {
|
class TreeNode<T> {
|
||||||
|
|
|
@ -2,14 +2,57 @@ import 'dart:io';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'package:dio/dio.dart' as dio_package;
|
import 'package:dio/dio.dart' as dio_package;
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:get/get_core/src/get_main.dart';
|
||||||
import 'package:image_gallery_saver/image_gallery_saver.dart';
|
import 'package:image_gallery_saver/image_gallery_saver.dart';
|
||||||
import 'package:sk_base_mobile/apis/api.dart';
|
import 'package:sk_base_mobile/apis/api.dart';
|
||||||
import 'package:image_picker/image_picker.dart';
|
import 'package:image_picker/image_picker.dart';
|
||||||
|
import 'package:sk_base_mobile/app_theme.dart';
|
||||||
import 'package:sk_base_mobile/config.dart';
|
import 'package:sk_base_mobile/config.dart';
|
||||||
import 'package:sk_base_mobile/models/upload_result.model.dart';
|
import 'package:sk_base_mobile/models/upload_result.model.dart';
|
||||||
|
import 'package:sk_base_mobile/router/router.util.dart';
|
||||||
import 'package:sk_base_mobile/services/service.dart';
|
import 'package:sk_base_mobile/services/service.dart';
|
||||||
|
|
||||||
class MediaUtil {
|
class MediaUtil {
|
||||||
|
/// 选择获取图片的方式,并返回路径
|
||||||
|
showPicker({Function(String?)? callback, String title = '请选择上传方式'}) async {
|
||||||
|
await showCupertinoModalPopup(
|
||||||
|
context: Get.overlayContext!,
|
||||||
|
builder: (BuildContext ctx) {
|
||||||
|
return CupertinoActionSheet(
|
||||||
|
title: Text(title),
|
||||||
|
cancelButton: CupertinoActionSheetAction(
|
||||||
|
onPressed: () {
|
||||||
|
RouterUtil.back();
|
||||||
|
},
|
||||||
|
child: const Text(
|
||||||
|
'取消',
|
||||||
|
style: TextStyle(color: Color(0xffcdcdcd)),
|
||||||
|
)),
|
||||||
|
actions: ['拍照', '相册']
|
||||||
|
.map((item) => CupertinoActionSheetAction(
|
||||||
|
onPressed: () async {
|
||||||
|
await RouterUtil.back();
|
||||||
|
XFile? pickedFile = item == '拍照'
|
||||||
|
? await MediaUtil().getImageFromCamera()
|
||||||
|
: await MediaUtil().getImageFromGallery();
|
||||||
|
if (pickedFile != null) {
|
||||||
|
if (callback != null) {
|
||||||
|
callback(pickedFile.path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
item,
|
||||||
|
style: const TextStyle(color: AppTheme.primaryColor),
|
||||||
|
)))
|
||||||
|
.toList(),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
static String getMediaUrl(String? url) {
|
static String getMediaUrl(String? url) {
|
||||||
if ((url ?? '').isEmpty) {
|
if ((url ?? '').isEmpty) {
|
||||||
return '';
|
return '';
|
||||||
|
@ -28,6 +71,7 @@ class MediaUtil {
|
||||||
}
|
}
|
||||||
AppInfoService.to.isCameraing.value = true;
|
AppInfoService.to.isCameraing.value = true;
|
||||||
pickedFile = await ImagePicker().pickImage(
|
pickedFile = await ImagePicker().pickImage(
|
||||||
|
imageQuality: 40,
|
||||||
source: ImageSource.camera,
|
source: ImageSource.camera,
|
||||||
maxWidth: maxWidth ?? 2000,
|
maxWidth: maxWidth ?? 2000,
|
||||||
preferredCameraDevice:
|
preferredCameraDevice:
|
||||||
|
@ -46,7 +90,7 @@ class MediaUtil {
|
||||||
}
|
}
|
||||||
AppInfoService.to.isCameraing.value = true;
|
AppInfoService.to.isCameraing.value = true;
|
||||||
XFile? pickedFile = await ImagePicker()
|
XFile? pickedFile = await ImagePicker()
|
||||||
.pickImage(source: ImageSource.gallery, imageQuality: 60);
|
.pickImage(source: ImageSource.gallery, imageQuality: 40);
|
||||||
AppInfoService.to.isCameraing.value = false;
|
AppInfoService.to.isCameraing.value = false;
|
||||||
return pickedFile;
|
return pickedFile;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:get/get.dart';
|
|
||||||
import 'package:image_picker/image_picker.dart';
|
|
||||||
import 'package:sk_base_mobile/router/router.util.dart';
|
|
||||||
import 'package:sk_base_mobile/util/media_util.dart';
|
|
||||||
import 'package:sk_base_mobile/app_theme.dart';
|
|
||||||
|
|
||||||
class PhotoPickerUtil {
|
|
||||||
showPicker({Function? callback, String title = '请选择上传方式'}) async {
|
|
||||||
return showCupertinoModalPopup(
|
|
||||||
context: Get.context!,
|
|
||||||
builder: (BuildContext ctx) {
|
|
||||||
return CupertinoActionSheet(
|
|
||||||
title: Text(title),
|
|
||||||
cancelButton: CupertinoActionSheetAction(
|
|
||||||
onPressed: () {
|
|
||||||
RouterUtil.back();
|
|
||||||
},
|
|
||||||
child: const Text(
|
|
||||||
'取消',
|
|
||||||
style: TextStyle(color: Color(0xffcdcdcd)),
|
|
||||||
)),
|
|
||||||
actions: ['拍照', '相册']
|
|
||||||
.map((item) => CupertinoActionSheetAction(
|
|
||||||
onPressed: () async {
|
|
||||||
await RouterUtil.back();
|
|
||||||
XFile? pickedFile = item == '拍照'
|
|
||||||
? await MediaUtil().getImageFromCamera()
|
|
||||||
: await MediaUtil().getImageFromGallery();
|
|
||||||
if (pickedFile != null) {
|
|
||||||
if (callback != null) {
|
|
||||||
callback(pickedFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
item,
|
|
||||||
style: const TextStyle(color: AppTheme.primaryColor),
|
|
||||||
)))
|
|
||||||
.toList(),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -3,7 +3,6 @@ library store;
|
||||||
export 'snack_bar.util.dart';
|
export 'snack_bar.util.dart';
|
||||||
export 'loading_util.dart';
|
export 'loading_util.dart';
|
||||||
export 'media_util.dart';
|
export 'media_util.dart';
|
||||||
export 'photo_picker_util.dart';
|
|
||||||
export 'screen_adaper_util.dart';
|
export 'screen_adaper_util.dart';
|
||||||
export 'validator_util.dart';
|
export 'validator_util.dart';
|
||||||
export 'date.util.dart';
|
export 'date.util.dart';
|
||||||
|
|
|
@ -47,7 +47,10 @@ class SkBaseDatePicker extends StatelessWidget {
|
||||||
if (int.parse(month) < 10) {
|
if (int.parse(month) < 10) {
|
||||||
month = '0$month';
|
month = '0$month';
|
||||||
}
|
}
|
||||||
final day = dayController.selectedItem + 1;
|
String day = '${dayController.selectedItem + 1}';
|
||||||
|
if (int.parse(day) < 10) {
|
||||||
|
day = '0$day';
|
||||||
|
}
|
||||||
if (onDateTimeChanged != null) {
|
if (onDateTimeChanged != null) {
|
||||||
onDateTimeChanged!('$year-$month-$day');
|
onDateTimeChanged!('$year-$month-$day');
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ class MyAvatarWidget extends StatelessWidget {
|
||||||
class MyAvatarController extends GetxController {
|
class MyAvatarController extends GetxController {
|
||||||
final uploadImgFilePath = ''.obs;
|
final uploadImgFilePath = ''.obs;
|
||||||
Future<void> photoPicker() async {
|
Future<void> photoPicker() async {
|
||||||
await PhotoPickerUtil().showPicker(callback: (XFile pickedFile) async {
|
await MediaUtil().showPicker(callback: (String? pickedFile) async {
|
||||||
await LoadingUtil.to.show(status: 'Uploading...');
|
await LoadingUtil.to.show(status: 'Uploading...');
|
||||||
try {
|
try {
|
||||||
// UploadResultModel? res = await MediaUtil().uploadImg(File(pickedFile.path));
|
// UploadResultModel? res = await MediaUtil().uploadImg(File(pickedFile.path));
|
||||||
|
|
|
@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.devz
|
||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
# In Windows, build-name is used as the major, minor, and patch parts
|
# In Windows, build-name is used as the major, minor, and patch parts
|
||||||
# of the product and file versions while build-number is used as the build suffix.
|
# of the product and file versions while build-number is used as the build suffix.
|
||||||
version: 1.0.3+1
|
version: 1.0.4+1
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=3.2.6 <4.0.0'
|
sdk: '>=3.2.6 <4.0.0'
|
||||||
|
|
Loading…
Reference in New Issue