final
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
|
||||
|
||||
import 'package:badges/badges.dart';
|
||||
import 'package:badges/badges.dart' as badges;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:percent_indicator/linear_percent_indicator.dart';
|
||||
import 'package:smooth_star_rating/smooth_star_rating.dart';
|
||||
import 'package:smooth_star_rating_nsafe/smooth_star_rating.dart';
|
||||
|
||||
import '../../events/eventbus.dart';
|
||||
import '../../events/events.dart';
|
||||
@@ -19,9 +19,8 @@ import '../../utils/utils.dart';
|
||||
|
||||
|
||||
class MobileNewComment extends StatefulWidget {
|
||||
final Key key;
|
||||
final int orderId;
|
||||
const MobileNewComment(this.orderId, {this.key});
|
||||
const MobileNewComment(this.orderId, {Key? key});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
@@ -31,13 +30,13 @@ class MobileNewComment extends StatefulWidget {
|
||||
}
|
||||
|
||||
class MobileNewCommentState extends State<MobileNewComment> {
|
||||
Comment comment;
|
||||
Comment? comment;
|
||||
|
||||
bool _showProgress;
|
||||
bool _showProgress = false;
|
||||
|
||||
double _progress;
|
||||
double? _progress;
|
||||
|
||||
double rating;
|
||||
double? rating;
|
||||
|
||||
bool isSubmitting = false;
|
||||
|
||||
@@ -112,13 +111,8 @@ class MobileNewCommentState extends State<MobileNewComment> {
|
||||
padding: EdgeInsets.only(left: 20.0, right: 20.0, top: 16.0, bottom: 16.0),
|
||||
child: SmoothStarRating(
|
||||
allowHalfRating: false,
|
||||
onRated: (v) {
|
||||
setState(() {
|
||||
rating = v;
|
||||
});
|
||||
},
|
||||
starCount: 5,
|
||||
rating: rating,
|
||||
rating: rating!,
|
||||
size: 40.0,
|
||||
filledIconData: Icons.star,
|
||||
color: Colors.green,
|
||||
@@ -167,13 +161,13 @@ class MobileNewCommentState extends State<MobileNewComment> {
|
||||
children: <Widget>[],
|
||||
);
|
||||
|
||||
if (comment != null && comment.images.length > 0) {
|
||||
for (ProductImage image in comment.images) {
|
||||
if (comment != null && comment!.images.length > 0) {
|
||||
for (ProductImage image in comment!.images) {
|
||||
row.children.add(
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 10.0),
|
||||
child: Badge(
|
||||
position: BadgePosition.topEnd(top: -10.0, end: -6.0),
|
||||
child: badges.Badge(
|
||||
position: badges.BadgePosition.topEnd(top: -10.0, end: -6.0),
|
||||
badgeContent: Container(
|
||||
child: Text(
|
||||
'-',
|
||||
@@ -210,7 +204,7 @@ class MobileNewCommentState extends State<MobileNewComment> {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
primary: Theme.of(context).primaryColor,
|
||||
foregroundColor: Theme.of(context).primaryColor,
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
@@ -239,7 +233,7 @@ class MobileNewCommentState extends State<MobileNewComment> {
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
size: 60.0,
|
||||
color: comment == null || comment.images.length < 3 ? Colors.lightBlue : Colors.black12,
|
||||
color: comment == null || comment!.images.length < 3 ? Colors.lightBlue : Colors.black12,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white70,
|
||||
@@ -264,13 +258,13 @@ class MobileNewCommentState extends State<MobileNewComment> {
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
if (comment == null || comment.images.length < 3) {
|
||||
if (comment == null || comment!.images.length < 3) {
|
||||
showDialog(
|
||||
context: mainContext,
|
||||
barrierDismissible: true,
|
||||
builder: (BuildContext context) {
|
||||
return Util().getPicture(mainContext, store.state.user,
|
||||
commentId: comment != null ? comment.id : 0,
|
||||
return Util().getPicture(mainContext, store.state.user!,
|
||||
commentId: comment != null ? comment!.id : 0,
|
||||
orderId: widget.orderId);
|
||||
}
|
||||
);
|
||||
@@ -290,7 +284,7 @@ class MobileNewCommentState extends State<MobileNewComment> {
|
||||
visible: _showProgress,
|
||||
child: LinearPercentIndicator(
|
||||
lineHeight: 10.0,
|
||||
percent: _progress,
|
||||
percent: _progress!,
|
||||
backgroundColor: Colors.transparent,
|
||||
progressColor: Colors.blue,
|
||||
linearStrokeCap: LinearStrokeCap.butt,
|
||||
@@ -329,7 +323,7 @@ class MobileNewCommentState extends State<MobileNewComment> {
|
||||
}
|
||||
},
|
||||
queryParameters: {
|
||||
'comment_id': comment != null ? comment.id : 0,
|
||||
'comment_id': comment != null ? comment!.id : 0,
|
||||
},
|
||||
).catchError((error) {
|
||||
Utils.showMessageDialog(context, error);
|
||||
@@ -356,9 +350,9 @@ class MobileNewCommentState extends State<MobileNewComment> {
|
||||
isFormData: true,
|
||||
body: {
|
||||
'order_id': widget.orderId,
|
||||
'comment_id': comment != null ? comment.id : 0,
|
||||
'comment_id': comment != null ? comment!.id : 0,
|
||||
'content': commentController.text,
|
||||
'rating': rating.round(),
|
||||
'rating': rating!.round(),
|
||||
},
|
||||
).catchError((error) {
|
||||
if (isSubmitting) {
|
||||
|
||||
Reference in New Issue
Block a user