Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
book-app
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
book-app
Commits
047a73da
提交
047a73da
authored
2月 27, 2024
作者:
maodou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
订单评价
上级
54488db0
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
287 行增加
和
98 行删除
+287
-98
controller.dart
lib/pages/user_order_evaluate/controller.dart
+13
-5
view.dart
lib/pages/user_order_evaluate/view.dart
+119
-93
input.dart
lib/widgets/input.dart
+155
-0
没有找到文件。
lib/pages/user_order_evaluate/controller.dart
浏览文件 @
047a73da
...
@@ -3,10 +3,11 @@ part of user_order_evaluate;
...
@@ -3,10 +3,11 @@ part of user_order_evaluate;
/// 订单评价
/// 订单评价
class
UserOrderEvaluateController
extends
GetxController
{
class
UserOrderEvaluateController
extends
GetxController
{
OrderInfoModel
orderInfoModel
;
late
OrderInfoModel
orderInfoModel
=
OrderInfoModel
()
;
String
orderNum
;
String
orderNum
;
UserOrderEvaluateController
(
this
.
orderNum
,
this
.
orderInfoModel
);
// 已完成订单
UserOrderEvaluateController
(
this
.
orderNum
);
// 已完成订单
final
TextEditingController
commentsInput
=
TextEditingController
();
final
FocusNode
_focusNode
=
FocusNode
();
// 按钮是否可用
// 按钮是否可用
bool
_enable
=
false
;
bool
_enable
=
false
;
bool
get
enable
=>
_enable
;
bool
get
enable
=>
_enable
;
...
@@ -33,8 +34,8 @@ class UserOrderEvaluateController extends GetxController {
...
@@ -33,8 +34,8 @@ class UserOrderEvaluateController extends GetxController {
}
}
}
}
void
setCanClick
(
num
double
){
void
setCanClick
(
{
num
double
=
0
}
){
if
(
double
>
0
){
if
(
double
>
0
||
commentsInput
.
text
!=
''
){
_enable
=
true
;
_enable
=
true
;
}
}
else
{
else
{
...
@@ -42,4 +43,11 @@ class UserOrderEvaluateController extends GetxController {
...
@@ -42,4 +43,11 @@ class UserOrderEvaluateController extends GetxController {
}
}
update
();
update
();
}
}
@override
void
onClose
()
{
commentsInput
.
dispose
();
_focusNode
.
dispose
();
super
.
onClose
();
}
}
}
lib/pages/user_order_evaluate/view.dart
浏览文件 @
047a73da
...
@@ -16,96 +16,91 @@ class UserOrderEvaluatePage extends StatefulWidget {
...
@@ -16,96 +16,91 @@ class UserOrderEvaluatePage extends StatefulWidget {
}
}
class
_UserOrderEvaluatePageState
extends
State
<
UserOrderEvaluatePage
>
with
AutomaticKeepAliveClientMixin
{
class
_UserOrderEvaluatePageState
extends
State
<
UserOrderEvaluatePage
>
with
AutomaticKeepAliveClientMixin
{
late
UserOrderEvaluateController
myController
;
// late UserOrderEvaluateController myController;
List
<
TextEditingController
>
controllers
=
[];
List
<
OrderEvaluate
>
orderEvaluates
=
[];
List
<
OrderEvaluate
>
orderEvaluates
=
[];
List
<
double
>
ratings
=
[];
List
<
double
>
ratings
=
[];
@override
@override
void
initState
()
{
void
initState
()
{
myController
=
Get
.
put
(
UserOrderEvaluateController
(
widget
.
orderNum
,
widget
.
orderInfoModel
));
// myController = Get.put(UserOrderEvaluateController(widget.orderNum
));
super
.
initState
();
super
.
initState
();
}
}
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
super
.
build
(
context
);
// super.build(context);
return
Scaffold
(
return
appBar:
AppBar
(
GetBuilder
<
UserOrderEvaluateController
>(
centerTitle:
true
,
init:
UserOrderEvaluateController
(
widget
.
orderNum
),
title:
const
Text
(
'订单评价'
),
builder:
(
controller
)
=>
Scaffold
(
),
appBar:
AppBar
(
body:
FutureBuilder
(
centerTitle:
true
,
future:
myController
.
getOrderInfo
(),
title:
const
Text
(
'订单评价'
),
builder:
(
context
,
snapshot
)
{
),
if
(
snapshot
.
connectionState
==
ConnectionState
.
waiting
){
body:
(
controller
.
orderInfoModel
==
null
||
controller
.
orderInfoModel
.
bookList
==
null
)?
return
Container
(
Container
(
alignment:
Alignment
.
center
,
alignment:
Alignment
.
center
,
child:
const
CircularProgressIndicator
(),
child:
const
CircularProgressIndicator
(),):
);
// 加载中的指示
Column
(
}
else
{
children:
[
return
Column
(
Expanded
(
children:
[
child:
Container
(
child:
SingleChildScrollView
(
Expanded
(
child:
Column
(
child:
SingleChildScrollView
(
children:
[
child:
Column
(
ListView
.
builder
(
children:
[
physics:
const
NeverScrollableScrollPhysics
(),
ListView
.
builder
(
shrinkWrap:
true
,
physics:
const
NeverScrollableScrollPhysics
(),
itemBuilder:
(
BuildContext
context
,
int
index
)
{
shrinkWrap:
true
,
return
listItem
(
itemBuilder:
(
BuildContext
context
,
int
index
)
{
controller
.
orderInfoModel
.
bookList
![
index
],
index
,
controller
return
listItem
(
/*orderEvaluates,*//*controllers*/
);
myController
.
orderInfoModel
.
bookList
![
index
],
},
orderEvaluates
,
controllers
);
itemCount:
},
controller
.
orderInfoModel
.
bookList
?.
length
,
itemCount:
),
myController
.
orderInfoModel
.
bookList
?.
length
,
],
),
],
),
),
),
SizedBox
(
height:
26
.
w
,
),
Container
(
margin:
EdgeInsets
.
symmetric
(
horizontal:
10
.
w
),
child:
CustomGradientButton
(
text:
'提交评价'
,
isEnabled:
myController
.
enable
,
onPressed:
()
{
for
(
int
i
=
0
;
i
<
orderEvaluates
.
length
;
i
++){
orderEvaluates
[
i
].
comments
=
controllers
[
i
].
text
.
toString
();
}
print
(
jsonEncode
(
orderEvaluates
));
myController
.
UpOrderEvaluate
(
jsonEncode
(
orderEvaluates
));
},
),
),
),),
),
SizedBox
(
height:
26
.
w
,
),
Container
(
margin:
EdgeInsets
.
symmetric
(
horizontal:
10
.
w
),
child:
CustomGradientButton
(
text:
'提交评价'
,
isEnabled:
controller
.
enable
,
onPressed:
()
{
controller
.
_focusNode
.
unfocus
();
for
(
int
i
=
0
;
i
<
orderEvaluates
.
length
;
i
++){
// orderEvaluates[i].comments=controllers[i].text.toString();
}
print
(
jsonEncode
(
orderEvaluates
));
controller
.
UpOrderEvaluate
(
jsonEncode
(
orderEvaluates
));
},
),
),
SizedBox
(
),
height:
41
.
w
,
SizedBox
(
)
height:
41
.
w
,
],
)
);
],
}
),
},
),
);
),);
}
}
Widget
listItem
(
BookListModel
bookListModel
,
Widget
listItem
(
BookListModel
bookListModel
,
int
index
,
UserOrderEvaluateController
myController
)
{
List
<
OrderEvaluate
>
orderEvaluates
,
List
<
TextEditingController
>
controllers
)
{
int
indexToUpdate
=
orderEvaluates
.
indexWhere
((
obj
)
=>
obj
.
recordId
==
bookListModel
.
recordId
);
int
indexToUpdate
=
orderEvaluates
.
indexWhere
((
obj
)
=>
obj
.
recordId
==
bookListModel
.
recordId
);
// TextEditingController textFieldController= TextEditingController();
myController
.
commentsInput
.
text
=
bookListModel
.
comments
.
toString
();
// if(indexToUpdate==-1){
if
(
indexToUpdate
==-
1
){
// OrderEvaluate evaluate = OrderEvaluate(recordId: bookListModel.recordId);
OrderEvaluate
evaluate
=
OrderEvaluate
(
recordId:
bookListModel
.
recordId
,
rating:
bookListModel
.
rating
,
comments:
bookListModel
.
comments
);
// orderEvaluates.add(evaluate);
orderEvaluates
.
add
(
evaluate
);
// controllers.add(textFieldController);
}
// }else{
// textFieldController = controllers[indexToUpdate];
// }
int
index
=
orderEvaluates
.
length
-
1
;
return
Container
(
return
Container
(
margin:
margin:
EdgeInsets
.
only
(
left:
10
.
w
,
top:
10
.
w
,
right:
10
.
w
),
EdgeInsets
.
only
(
left:
10
.
w
,
top:
10
.
w
,
right:
10
.
w
),
...
@@ -196,39 +191,70 @@ class _UserOrderEvaluatePageState extends State<UserOrderEvaluatePage> with Auto
...
@@ -196,39 +191,70 @@ class _UserOrderEvaluatePageState extends State<UserOrderEvaluatePage> with Auto
absorbing:
false
,
absorbing:
false
,
child:
CustomRating
(
child:
CustomRating
(
max:
5
,
max:
5
,
score:
0
,
score:
bookListModel
.
rating
!=
null
?
bookListModel
.
rating
!.
toDouble
():
0
,
star:
Star
(
star:
Star
(
fat:
0.5
,
fat:
0.5
,
progress:
7
,
progress:
3
,
fillColor:
AppTheme
.
primary
,
fillColor:
AppTheme
.
primary
,
size:
16
.
w
,
size:
16
.
w
,
emptyColor:
Colours
.
cE2
,
emptyColor:
Colours
.
cE2
,
),
),
onRating:
(
double
)
{
onRating:
(
double
)
{
orderEvaluates
[
index
].
rating
=
double
;
orderEvaluates
[
index
].
rating
=
double
;
myController
.
setCanClick
(
double
);
myController
.
setCanClick
(
double
:
double
);
print
(
double
);
print
(
double
);
},
},
),
),
),
),
],
],
),
),
Expanded
(
TextField
(
// color: Colors.red,
controller:
myController
.
commentsInput
,
child:
CustomInput
(
style:
decoration:
InputDecoration
(
TextStyle
(
fontSize:
14
.
w
,
color:
Colours
.
c3
),
focusedBorder:
InputBorder
.
none
,
decoration:
InputDecoration
(
border:
InputBorder
.
none
,
focusedBorder:
InputBorder
.
none
,
enabledBorder:
InputBorder
.
none
,
border:
InputBorder
.
none
,
errorBorder:
InputBorder
.
none
,
enabledBorder:
InputBorder
.
none
,
fillColor:
Colors
.
white
,
errorBorder:
InputBorder
.
none
,
hintStyle:
TextStyle
(
fillColor:
Colors
.
white
,
fontSize:
14
.
w
,
height:
1.5
,
color:
Colours
.
c6
)),
hintText:
'请简要描述'
,
hintStyle:
TextStyle
(
fontSize:
14
.
w
,
height:
1.5
,
color:
Colours
.
c6
)),
maxLines:
5
,
maxLines:
5
,
// controller: textFieldController,
onChanged:
(
text
){
hintText:
'请简要描述'
,
myController
.
setCanClick
();
),
orderEvaluates
[
index
].
comments
=
myController
.
commentsInput
.
text
;
},
focusNode:
myController
.
_focusNode
,
// onTap: () {
// // 在文本框获取焦点时,将光标移动到文本末尾
// myController.commentsInput.selection = TextSelection.fromPosition(
// TextPosition(offset: myController.commentsInput.text.length),
// );
// },
),
),
// CustomInputCommands(
// decoration: InputDecoration(
// focusedBorder: InputBorder.none,
// border: InputBorder.none,
// enabledBorder: InputBorder.none,
// errorBorder: InputBorder.none,
// fillColor: Colors.white,
// hintStyle: TextStyle(
// fontSize: 14.w, height: 1.5, color: Colours.c6)),
// maxLines: 5,
// controller: myController.commentsInput,
// hintText: '请简要描述',
// onChanged: (text){
// myController.setCanClick();
// print(myController.commentsInput.text);
// orderEvaluates[index].comments=myController.commentsInput.text;
// },
// focusNode: myController._focusNode,
// ),
],
],
),
),
),
),
...
...
lib/widgets/input.dart
浏览文件 @
047a73da
...
@@ -433,4 +433,159 @@ class CustomInputSearch extends StatelessWidget {
...
@@ -433,4 +433,159 @@ class CustomInputSearch extends StatelessWidget {
}
}
}
}
class
CustomInputCommands
extends
StatelessWidget
{
final
TextEditingController
?
controller
;
final
String
?
label
;
final
String
?
helper
;
final
String
?
hintText
;
final
String
?
error
;
final
bool
required
;
final
bool
readOnly
;
final
bool
obscureText
;
final
Widget
?
iconData
;
final
int
?
minLines
;
final
int
?
maxLines
;
final
void
Function
()?
onTap
;
final
void
Function
()?
onIcon
;
final
ValueChanged
<
String
>?
onChanged
;
final
InputDecoration
decoration
;
final
TextInputType
?
keyboardType
;
final
bool
autofocus
;
final
FocusNode
focusNode
;
final
List
<
TextInputFormatter
>?
inputFormatters
;
const
CustomInputCommands
({
Key
?
key
,
this
.
controller
,
this
.
label
,
this
.
helper
,
this
.
hintText
,
this
.
error
,
this
.
required
=
false
,
this
.
readOnly
=
false
,
this
.
obscureText
=
false
,
this
.
onTap
,
this
.
onIcon
,
this
.
iconData
,
this
.
onChanged
,
this
.
decoration
=
const
InputDecoration
(),
this
.
minLines
,
this
.
maxLines
=
1
,
this
.
keyboardType
,
this
.
autofocus
=
false
,
this
.
inputFormatters
,
required
this
.
focusNode
,
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
final
theme
=
Theme
.
of
(
context
);
final
decorationTheme
=
theme
.
inputDecorationTheme
;
return
Column
(
mainAxisSize:
MainAxisSize
.
min
,
crossAxisAlignment:
CrossAxisAlignment
.
stretch
,
children:
[
if
(
label
!=
null
||
required
)
Padding
(
padding:
EdgeInsets
.
symmetric
(
horizontal:
(
decorationTheme
.
contentPadding
?.
horizontal
??
0
)
/
2
,
vertical:
10
.
w
,
).
copyWith
(
top:
0
),
child:
RichText
(
text:
TextSpan
(
text:
label
,
style:
decorationTheme
.
labelStyle
,
children:
[
if
(
required
)
TextSpan
(
text:
label
!=
null
?
' *'
:
'*'
,
style:
const
TextStyle
(
color:
AppTheme
.
error
),
),
],
),
),
),
DecoratedBox
(
decoration:
const
BoxDecoration
(
boxShadow:
[
// BoxShadow(
// color: theme.colorScheme.shadow,
// offset: Offset(0, 20.w),
// blurRadius: 10.w,
// spreadRadius: -10.w,
// ),
],
),
child:
TextField
(
focusNode:
focusNode
,
autofocus:
autofocus
,
controller:
controller
,
readOnly:
readOnly
,
onTap:
onTap
,
obscureText:
obscureText
,
onChanged:
onChanged
,
minLines:
minLines
,
maxLines:
maxLines
,
inputFormatters:
inputFormatters
,
keyboardType:
keyboardType
,
style:
TextStyle
(
// fontFamily: 'Sans',
fontSize:
15
.
w
,
height:
1.2
,
// fontWeight: FontWeight.w600,
),
decoration:
decoration
.
copyWith
(
hintText:
hintText
,
hintStyle:
const
TextStyle
(
fontWeight:
FontWeight
.
normal
,
color:
Colours
.
c9
,
fontSize:
13
),
suffixIconConstraints:
const
BoxConstraints
(),
suffixIcon:
_suffixIcon
(
decorationTheme
),
),
),
),
AnimatedSize
(
duration:
const
Duration
(
milliseconds:
180
),
alignment:
Alignment
.
topCenter
,
child:
error
!=
null
?
Padding
(
padding:
EdgeInsets
.
only
(
top:
10
.
w
),
// child: CustomAlert.error(
// size: CustomAlertSize.mini,
// text: Text(error!),
// ),
)
:
const
SizedBox
.
shrink
(),
),
if
(
helper
!=
null
)
Padding
(
padding:
EdgeInsets
.
symmetric
(
horizontal:
(
decorationTheme
.
contentPadding
?.
horizontal
??
0
)
/
2
,
vertical:
10
.
w
,
).
copyWith
(
bottom:
0
),
child:
Text
(
helper
!,
style:
decorationTheme
.
helperStyle
,
),
)
],
);
}
Widget
?
_suffixIcon
(
InputDecorationTheme
decorationTheme
)
{
if
(
iconData
==
null
)
return
null
;
return
Padding
(
padding:
EdgeInsetsDirectional
.
only
(
end:
(
decorationTheme
.
contentPadding
?.
horizontal
??
0
)
/
2
,
),
child:
GestureDetector
(
onTap:
onIcon
,
child:
SizedBox
(
width:
24
,
height:
24
,
child:
iconData
,
)
),
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论