棉花app新增页面
This commit is contained in:
77
lib/component/img/img_default_widget.dart
Normal file
77
lib/component/img/img_default_widget.dart
Normal file
@@ -0,0 +1,77 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../controller/mh/apply_repair_controller.dart';
|
||||
|
||||
|
||||
class ImgPreviewDefaultWidget extends GetView {
|
||||
ApplyRepairController applyRepairController;
|
||||
|
||||
ImgPreviewDefaultWidget({required this.applyRepairController}) {}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
// onTap: applyRepairController.uploadImg,
|
||||
onTap: ()async{},
|
||||
child: Container(
|
||||
width: MediaQuery.sizeOf(context).width * 0.25,
|
||||
height: MediaQuery.sizeOf(context).height * 0.15,
|
||||
constraints: BoxConstraints(
|
||||
minHeight: 152,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
width: MediaQuery.sizeOf(context).width,
|
||||
height: MediaQuery.sizeOf(context).height * 0.116,
|
||||
constraints: BoxConstraints(
|
||||
minHeight: 152,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFFF3F5F6),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional(0, 0),
|
||||
child: Container(
|
||||
width: 35,
|
||||
height: 35,
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
fit: BoxFit.cover,
|
||||
image: Image.asset(
|
||||
'assets/images/camera.png',
|
||||
).image,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Align(
|
||||
alignment: AlignmentDirectional(0, 0),
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(0, 8, 0, 13),
|
||||
child: Text(
|
||||
' ',
|
||||
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||
fontFamily: 'Readex Pro',
|
||||
color: Color(0xFF9EA4B7),
|
||||
fontSize: 11,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
23
lib/component/img/img_preview_controller.dart
Normal file
23
lib/component/img/img_preview_controller.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'img_preview_controller.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class ImgPreviewModel {
|
||||
//版本id
|
||||
String? url; //图片地址
|
||||
|
||||
|
||||
ImgPreviewModel();
|
||||
|
||||
static ImgPreviewModel fromJson(Map<String, dynamic> json) =>
|
||||
_$ImgPreviewModelFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$ImgPreviewModelToJson(this);
|
||||
}
|
||||
|
||||
class ImgPreviewController extends GetControllerEx<ImgPreviewModel> {
|
||||
ImgPreviewController() {
|
||||
attr = GetModel(ImgPreviewModel()).obs;
|
||||
}
|
||||
}
|
||||
15
lib/component/img/img_preview_controller.g.dart
Normal file
15
lib/component/img/img_preview_controller.g.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'img_preview_controller.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
ImgPreviewModel _$ImgPreviewModelFromJson(Map<String, dynamic> json) =>
|
||||
ImgPreviewModel()..url = json['url'] as String?;
|
||||
|
||||
Map<String, dynamic> _$ImgPreviewModelToJson(ImgPreviewModel instance) =>
|
||||
<String, dynamic>{
|
||||
'url': instance.url,
|
||||
};
|
||||
80
lib/component/img/img_preview_widget.dart
Normal file
80
lib/component/img/img_preview_widget.dart
Normal file
@@ -0,0 +1,80 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../common/color/appFontsize.dart';
|
||||
import '../../controller/mh/apply_repair_controller.dart';
|
||||
|
||||
class ImgPreviewWidget extends GetView {
|
||||
String imgUrl;
|
||||
int index;
|
||||
ApplyRepairController applyRepairController;
|
||||
bool isDel;
|
||||
|
||||
ImgPreviewWidget(
|
||||
{required this.imgUrl,
|
||||
required this.index,
|
||||
required this.applyRepairController,
|
||||
required this.isDel}) {}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: MediaQuery.sizeOf(context).width * 0.25,
|
||||
height: MediaQuery.sizeOf(context).height * 0.15,
|
||||
constraints: BoxConstraints(
|
||||
minHeight: 140,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
width: MediaQuery.sizeOf(context).width,
|
||||
height: MediaQuery.sizeOf(context).height * 0.116,
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFFF3F5F6),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Image.network(
|
||||
'https://picsum.photos/seed/73/600',
|
||||
// applyRepairController.getPublicUrl(imgUrl),
|
||||
|
||||
width: 300,
|
||||
height: 200,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: isDel,
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional(0, 0),
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(0, 8, 0, 13),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
applyRepairController.model.issue_img!.removeAt(index);
|
||||
applyRepairController.updateAll();
|
||||
},
|
||||
child: Text(
|
||||
'删除',
|
||||
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||
fontFamily: 'Readex Pro',
|
||||
color: Color(0xFF9EA4B7),
|
||||
fontSize: AppFontsize.small_text_size,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
)),
|
||||
)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,102 @@
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
|
||||
// class CustomCard extends StatefulWidget {
|
||||
// final double borderRadius; // 圆角
|
||||
// final VoidCallback onTap; // 点击回调
|
||||
// final List<Color> colors; // 背景颜色列表
|
||||
// final Widget child; // 子组件
|
||||
// final bool enableAnimation; // 是否启用动画效果
|
||||
// final bool enableGradient; // 是否启用渐变
|
||||
|
||||
// const CustomCard({
|
||||
// Key? key,
|
||||
// required this.borderRadius,
|
||||
// required this.onTap,
|
||||
// required this.colors,
|
||||
// required this.child,
|
||||
// this.enableAnimation = true, // 默认启用动画效果
|
||||
// this.enableGradient = true, // 默认启用渐变效果
|
||||
// }) : super(key: key);
|
||||
|
||||
// @override
|
||||
// State<CustomCard> createState() => _CustomCardState();
|
||||
// }
|
||||
|
||||
// class _CustomCardState extends State<CustomCard>
|
||||
// with SingleTickerProviderStateMixin {
|
||||
// double _scale = 1.0;
|
||||
// final Duration _animationDuration = const Duration(milliseconds: 50);
|
||||
|
||||
// Future<void> _handleTap() async {
|
||||
// if (widget.enableAnimation) {
|
||||
// setState(() {
|
||||
// _scale = 0.95;
|
||||
// });
|
||||
|
||||
// await Future.delayed(_animationDuration);
|
||||
|
||||
// setState(() {
|
||||
// _scale = 1.0;
|
||||
// });
|
||||
// }
|
||||
|
||||
// widget.onTap();
|
||||
// }
|
||||
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// final bool isGradient = widget.enableGradient && widget.colors.length > 1;
|
||||
// final Color baseColor = widget.colors.first;
|
||||
|
||||
// return Material(
|
||||
// color: Colors.transparent,
|
||||
// borderRadius: BorderRadius.circular(widget.borderRadius),
|
||||
// child: InkWell(
|
||||
// onTap: _handleTap,
|
||||
// borderRadius: BorderRadius.circular(widget.borderRadius),
|
||||
// splashColor: widget.colors.first.withOpacity(0.2),
|
||||
// child: widget.enableAnimation
|
||||
// ? AnimatedScale(
|
||||
// scale: _scale,
|
||||
// duration: _animationDuration,
|
||||
// curve: Curves.easeInOut,
|
||||
// child: _buildContent(isGradient, baseColor),
|
||||
// )
|
||||
// : _buildContent(isGradient, baseColor),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
|
||||
// Widget _buildContent(bool isGradient, Color baseColor) {
|
||||
// return Container(
|
||||
// decoration: BoxDecoration(
|
||||
// color: isGradient ? null : baseColor,
|
||||
// gradient: isGradient
|
||||
// ? LinearGradient(
|
||||
// colors: widget.colors,
|
||||
// begin: Alignment.topLeft,
|
||||
// end: Alignment.bottomRight,
|
||||
// )
|
||||
// : null,
|
||||
// borderRadius: BorderRadius.circular(widget.borderRadius),
|
||||
// ),
|
||||
// child: Padding(
|
||||
// padding: EdgeInsets.fromLTRB(0.rpx, 0.rpx, 0.rpx, 5.rpx),
|
||||
// child: widget.child,
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
|
||||
/// 枚举控制渐变方向
|
||||
enum GradientDirection {
|
||||
horizontal,
|
||||
vertical,
|
||||
}
|
||||
|
||||
class CustomCard extends StatefulWidget {
|
||||
final double borderRadius; // 圆角
|
||||
final VoidCallback onTap; // 点击回调
|
||||
@@ -8,6 +104,8 @@ class CustomCard extends StatefulWidget {
|
||||
final Widget child; // 子组件
|
||||
final bool enableAnimation; // 是否启用动画效果
|
||||
final bool enableGradient; // 是否启用渐变
|
||||
final GradientDirection gradientDirection; // 渐变方向
|
||||
final EdgeInsetsGeometry? margin; // 外部间距
|
||||
|
||||
const CustomCard({
|
||||
Key? key,
|
||||
@@ -15,8 +113,10 @@ class CustomCard extends StatefulWidget {
|
||||
required this.onTap,
|
||||
required this.colors,
|
||||
required this.child,
|
||||
this.enableAnimation = true, // 默认启用动画效果
|
||||
this.enableGradient = true, // 默认启用渐变效果
|
||||
this.enableAnimation = true,
|
||||
this.enableGradient = true,
|
||||
this.gradientDirection = GradientDirection.horizontal,
|
||||
this.margin,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
@@ -49,21 +149,24 @@ class _CustomCardState extends State<CustomCard>
|
||||
final bool isGradient = widget.enableGradient && widget.colors.length > 1;
|
||||
final Color baseColor = widget.colors.first;
|
||||
|
||||
return Material(
|
||||
color: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(widget.borderRadius),
|
||||
child: InkWell(
|
||||
onTap: _handleTap,
|
||||
return Container(
|
||||
margin: widget.margin, // 应用外部间距
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(widget.borderRadius),
|
||||
splashColor: widget.colors.first.withOpacity(0.2),
|
||||
child: widget.enableAnimation
|
||||
? AnimatedScale(
|
||||
scale: _scale,
|
||||
duration: _animationDuration,
|
||||
curve: Curves.easeInOut,
|
||||
child: _buildContent(isGradient, baseColor),
|
||||
)
|
||||
: _buildContent(isGradient, baseColor),
|
||||
child: InkWell(
|
||||
onTap: _handleTap,
|
||||
borderRadius: BorderRadius.circular(widget.borderRadius),
|
||||
splashColor: widget.colors.first.withOpacity(0.2),
|
||||
child: widget.enableAnimation
|
||||
? AnimatedScale(
|
||||
scale: _scale,
|
||||
duration: _animationDuration,
|
||||
curve: Curves.easeInOut,
|
||||
child: _buildContent(isGradient, baseColor),
|
||||
)
|
||||
: _buildContent(isGradient, baseColor),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -75,14 +178,18 @@ class _CustomCardState extends State<CustomCard>
|
||||
gradient: isGradient
|
||||
? LinearGradient(
|
||||
colors: widget.colors,
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
begin: widget.gradientDirection == GradientDirection.vertical
|
||||
? Alignment.topCenter
|
||||
: Alignment.centerLeft,
|
||||
end: widget.gradientDirection == GradientDirection.vertical
|
||||
? Alignment.bottomCenter
|
||||
: Alignment.centerRight,
|
||||
)
|
||||
: null,
|
||||
borderRadius: BorderRadius.circular(widget.borderRadius),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.fromLTRB(0.rpx, 0.rpx, 0.rpx, 5.rpx),
|
||||
padding: EdgeInsets.fromLTRB(0.rpx, 0.rpx, 0.rpx, 0.rpx),
|
||||
child: widget.child,
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user