任务发布-发布新任务-添加照片

pull/1/head
张萌 3 years ago
parent b5bcee3842
commit fc22339a6e

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 B

File diff suppressed because it is too large Load Diff

@ -7,6 +7,7 @@
import 'package:audio_session/audio_session_web.dart';
import 'package:device_info_plus_web/device_info_plus_web.dart';
import 'package:flutter_sound_web/flutter_sound_web.dart';
import 'package:image_picker_for_web/image_picker_for_web.dart';
import 'package:just_audio_web/just_audio_web.dart';
import 'package:package_info_plus_web/package_info_plus_web.dart';
@ -18,6 +19,7 @@ import 'package:flutter_web_plugins/flutter_web_plugins.dart';
void registerPlugins(Registrar registrar) {
AudioSessionWeb.registerWith(registrar);
DeviceInfoPlusPlugin.registerWith(registrar);
FlutterSoundPlugin.registerWith(registrar);
ImagePickerPlugin.registerWith(registrar);
JustAudioPlugin.registerWith(registrar);
PackageInfoPlugin.registerWith(registrar);

@ -218,7 +218,7 @@ class _HomePageState extends State<HomePage>
mainAxisSize: MainAxisSize.min,
children: [
head,
HomeSwiper(), //
// HomeSwiper(), //
// SizedBox(height: 100.w),
Container(
padding: EdgeInsets.only(top: 24.w, bottom: 32.w),

@ -39,6 +39,7 @@ class _HallViewState extends State<HallView> {
padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w),
itemBuilder: (context, index) {
return HallCard(
key: ValueKey(models[index].id),
model: models[index],
refresh: () => _refreshController.callRefresh());
},

File diff suppressed because it is too large Load Diff

@ -32,7 +32,7 @@ class TaskFunc {
static Future<bool> cancel({
required int taskId,
}) async {
var base = await NetUtil().get(API.manager.task.cancel, params: {
var base = await NetUtil().get(SARSAPI.task.cancel, params: {
'taskId': taskId,
});
return base.success;
@ -43,9 +43,11 @@ class TaskFunc {
static Future<bool> take({
required int taskId,
}) async {
var base = await NetUtil().get(API.manager.task.take, params: {
'taskId': taskId,
});
var base = await NetUtil().get(SARSAPI.task.receive,
params: {
'taskId': taskId,
},
showMessage: true);
return base.success;
}
@ -54,9 +56,40 @@ class TaskFunc {
static Future<bool> finish({
required int taskId,
}) async {
var base = await NetUtil().get(API.manager.task.finish, params: {
var base = await NetUtil().get(SARSAPI.task.finish, params: {
'taskId': taskId,
});
return base.success;
}
///
static Future<bool> confirm({
required int taskId,
}) async {
var base = await NetUtil().get(SARSAPI.task.confirm, params: {
'taskId': taskId,
});
return base.success;
}
///
static Future<bool> start({
required int taskId,
}) async {
var base = await NetUtil().get(SARSAPI.task.startService, params: {
'taskId': taskId,
});
return base.success;
}
///
static Future<bool> evaluate({
required int taskId,
required int star,
required String evaluation,
}) async {
var base = await NetUtil().get(SARSAPI.task.evaluation,
params: {'taskId': taskId, 'star': star, 'evaluation': evaluation});
return base.success;
}
}

@ -0,0 +1,82 @@
import 'package:aku_new_community/base/base_style.dart';
import 'package:aku_new_community/widget/bee_scaffold.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:velocity_x/src/extensions/num_ext.dart';
import 'package:velocity_x/src/extensions/string_ext.dart';
class TaskRemarkPage extends StatefulWidget {
const TaskRemarkPage({Key? key}) : super(key: key);
@override
_TaskRemarkPageState createState() => _TaskRemarkPageState();
}
class _TaskRemarkPageState extends State<TaskRemarkPage> {
TextEditingController _contentController = TextEditingController();
@override
void dispose() {
_contentController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return BeeScaffold(
title: '添加备注',
body: ListView(
padding: EdgeInsets.all(32.w),
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
'任务内容'
.text
.size(28.sp)
.color(Colors.black.withOpacity(0.45))
.make(),
],
),
32.w.heightBox,
Container(
width: double.infinity,
padding: EdgeInsets.symmetric(horizontal: 24.w),
decoration: BoxDecoration(
color: Colors.black.withOpacity(0.06),
borderRadius: BorderRadius.circular(16.w)),
child: TextField(
controller: _contentController,
autofocus: false,
onChanged: (text) => setState(() {}),
minLines: 5,
maxLength: 200,
maxLines: 20,
decoration: InputDecoration(
border: InputBorder.none,
),
),
)
],
),
bottomNavi: Padding(
padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 32.w),
child: MaterialButton(
elevation: 0,
height: 93.w,
disabledColor: Colors.black.withOpacity(0.06),
disabledTextColor: Colors.black.withOpacity(0.25),
textColor: Colors.black.withOpacity(0.85),
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(65.w)),
color: kPrimaryColor,
onPressed: () async {
Get.back(result: _contentController.text);
},
child: '完成'.text.size(32.sp).bold.make(),
),
),
);
}
}

@ -0,0 +1,115 @@
// Dart imports:
import 'dart:io';
import 'package:aku_new_community/extensions/widget_list_ext.dart';
import 'package:aku_new_community/gen/assets.gen.dart';
import 'package:aku_new_community/widget/picker/bee_image_picker.dart';
// Package imports:
import 'package:dotted_border/dotted_border.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:velocity_x/velocity_x.dart';
class BeePickImageWidget extends StatefulWidget {
final double? size;
final Function(List<File> files) onChanged;
final String description;
BeePickImageWidget(
{Key? key, this.size, required this.onChanged, this.description = '上传照片'})
: super(key: key);
@override
_BeePickImageWidgetState createState() => _BeePickImageWidgetState();
}
class _BeePickImageWidgetState extends State<BeePickImageWidget> {
List<File> _files = [];
@override
Widget build(BuildContext context) {
return Row(
children: [
..._files.map((e) => showImage(e)).toList(),
GestureDetector(
onTap: () async {
await BeeImagePicker.pick(title: '选择图片').then(
(value) {
if (value != null) {
_files.add(
File(value.path),
);
}
},
);
widget.onChanged(_files);
setState(() {});
},
child: DottedBorder(
color: Colors.black.withOpacity(0.25),
borderType: BorderType.RRect,
strokeWidth: 2.w,
dashPattern: [6, 3],
radius: Radius.circular(8.w),
child: Container(
width: widget.size ?? 160.w,
height: widget.size ?? 160.w,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset(
Assets.icons.camera.path,
width: 60.w,
height: 60.w,
color: Color(0xFF999999),
),
4.w.heightBox,
widget.description.text
.color(Colors.black.withOpacity(0.45))
.size(22.sp)
.make(),
],
),
),
).material(color: Colors.transparent),
)
].sepWidget(separate: 10.w.widthBox),
);
}
Widget showImage(File file) {
return Stack(children: [
Container(
width: widget.size ?? 160.w,
height: widget.size ?? 160.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.w),
color: Colors.black.withOpacity(0.03)),
child: Image.file(file),
),
Positioned(
top: 8.w,
right: 8.w,
child: Container(
width: 40.w,
height: 40.w,
child: Icon(
CupertinoIcons.xmark,
size: 20.w,
color: Colors.white,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.w),
color: Color(0xFF000000),
),
).onTap(() {
_files.remove(file);
widget.onChanged(_files);
setState(() {});
}),
)
]);
}
}

@ -3,14 +3,19 @@ import 'dart:math';
import 'package:aku_new_community/constants/sars_api.dart';
import 'package:aku_new_community/extensions/num_ext.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:just_audio/just_audio.dart';
class VoicePlayer extends StatefulWidget {
final String url;
final VoidCallback? onDelete;
final bool showXmark;
const VoicePlayer({Key? key, required this.url}) : super(key: key);
const VoicePlayer(
{Key? key, required this.url, this.onDelete, this.showXmark = false})
: super(key: key);
@override
_VoicePlayerState createState() => _VoicePlayerState();
@ -26,12 +31,13 @@ class _VoicePlayerState extends State<VoicePlayer>
bool inAnimate = false;
final player = AudioPlayer();
Timer? _timer;
int _voiceLength = 0;
Duration? _voiceLength;
int _currentLength = 0;
void stopPlay() {
inAnimate = false;
controller.stop();
player.stop();
player.pause();
_timer?.cancel();
_timer = null;
if (mounted) {
@ -39,25 +45,45 @@ class _VoicePlayerState extends State<VoicePlayer>
}
}
void startPlay() {
void startPlay() async {
inAnimate = true;
controller.forward();
player.play();
_timer = Timer.periodic(Duration(seconds: 1), (timer) async {
_voiceLength--;
if (_voiceLength <= 0) {
_voiceLength = (player.duration?.inSeconds) ?? 0;
_timer?.cancel();
_timer = null;
controller.stop();
inAnimate = false;
}
if (mounted) {
setState(() {});
_currentLength--;
if (_currentLength <= 0) {
resetPlay();
} else {
if (mounted) {
setState(() {});
}
}
});
}
Future initVoice() async {
await player.setUrl(SARSAPI.image(widget.url));
_voiceLength = await player.load();
_currentLength = _voiceLength?.inSeconds ?? 0;
await player.setClip(start: Duration(seconds: 0), end: _voiceLength);
if (mounted) {
setState(() {});
}
}
Future resetPlay() async {
_timer?.cancel();
_timer = null;
controller.stop();
inAnimate = false;
player.stop();
_currentLength = _voiceLength?.inSeconds ?? 0;
await player.setClip(start: Duration(seconds: 0), end: _voiceLength);
if (mounted) {
setState(() {});
}
}
@override
void initState() {
controller = AnimationController(
@ -80,17 +106,16 @@ class _VoicePlayerState extends State<VoicePlayer>
controller.forward();
}
});
Future.delayed(Duration(milliseconds: 0), () async {
await player.setUrl(SARSAPI.image(widget.url));
var length = await player.load();
_voiceLength = length?.inSeconds ?? 0;
if (mounted) {
setState(() {});
}
});
initVoice();
super.initState();
}
@override
void didUpdateWidget(covariant VoicePlayer oldWidget) {
resetPlay();
super.didUpdateWidget(oldWidget);
}
@override
void dispose() {
stopPlay();
@ -113,22 +138,40 @@ class _VoicePlayerState extends State<VoicePlayer>
},
child: Material(
color: Colors.transparent,
child: Container(
width: width,
// height: height,
padding: EdgeInsets.symmetric(vertical: 14.w, horizontal: 20.w),
decoration: BoxDecoration(
color: Color(0xFFFFE7BA),
borderRadius: BorderRadius.circular(8.w)),
child: Row(
children: [
CustomPaint(
painter: VoicePlayerPainter(inAnimate ? animation.value : 3),
child: Stack(
fit: StackFit.passthrough,
clipBehavior: Clip.none,
children: [
Container(
width: width,
// height: height,
padding: EdgeInsets.symmetric(vertical: 14.w, horizontal: 20.w),
decoration: BoxDecoration(
color: Color(0xFFFFE7BA),
borderRadius: BorderRadius.circular(8.w)),
child: Row(
children: [
CustomPaint(
painter:
VoicePlayerPainter(inAnimate ? animation.value : 3),
),
40.wb,
Text('${_currentLength}\"'),
],
),
40.wb,
Text('${_voiceLength}\"'),
],
),
),
if (widget.showXmark)
Positioned(
top: -10.w,
right: -10.w,
child: GestureDetector(
onTap: widget.onDelete,
child: Icon(
CupertinoIcons.xmark_circle_fill,
size: 30.w,
),
))
],
),
),
);

@ -512,6 +512,27 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.6.0"
flutter_sound:
dependency: "direct main"
description:
name: flutter_sound
url: "https://pub.flutter-io.cn"
source: hosted
version: "9.1.3"
flutter_sound_platform_interface:
dependency: transitive
description:
name: flutter_sound_platform_interface
url: "https://pub.flutter-io.cn"
source: hosted
version: "9.1.3"
flutter_sound_web:
dependency: transitive
description:
name: flutter_sound_web
url: "https://pub.flutter-io.cn"
source: hosted
version: "9.1.3"
flutter_test:
dependency: "direct dev"
description: flutter
@ -990,7 +1011,7 @@ packages:
name: provider
url: "https://pub.flutter-io.cn"
source: hosted
version: "5.0.0"
version: "6.0.2"
pub_semver:
dependency: "direct dev"
description:
@ -1042,6 +1063,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0"
recase:
dependency: transitive
description:
name: recase
url: "https://pub.flutter-io.cn"
source: hosted
version: "4.0.0"
rxdart:
dependency: transitive
description:

@ -18,7 +18,7 @@ dependencies:
#包信息
package_info: ^2.0.0
#状态管理
provider: ^5.0.0
provider: ^6.0.0
#屏幕适配
flutter_screenutil: ^5.0.0+2
#图标集合
@ -117,6 +117,8 @@ dependencies:
palette_generator: ^0.3.2
#音频播放
just_audio: ^0.9.20
#录音
flutter_sound: ^9.1.3
dev_dependencies:

Loading…
Cancel
Save