diff --git a/assets/translations/en-US.json b/assets/translations/en-US.json index 14c7e4a..5ff03f8 100644 --- a/assets/translations/en-US.json +++ b/assets/translations/en-US.json @@ -303,10 +303,10 @@ "general-board-post" : "General Board New Post", "market-board-post": "Market Board New Post", - "Brand_New": "Brand New", - "Almost_New": "Almost New", - "Slight_Defect": "Slight Defect", - "Used": "Used", - "sale": "For sale" + "Brand_New": "BRAND_NEW", + "Almost_New": "ALMOST_NEW", + "Slight_Defect": "SLIGHT_DEFECT", + "Used": "USED", + "sale": "SELL" } \ No newline at end of file diff --git a/lib/apis/apis.dart b/lib/apis/apis.dart index fbf27c8..1e506b4 100644 --- a/lib/apis/apis.dart +++ b/lib/apis/apis.dart @@ -1580,7 +1580,6 @@ class APIs { } } - /*장터 게시판 게시글 상세 조회*/ static Future getMarketArticle(int articleId) async { final _url = 'http://3.34.2.246:8080/api/v2/market-articles/${articleId}'; @@ -1807,48 +1806,44 @@ class APIs { /* 특정 판매글 찜 등록*/ - static Future addMarketArticleBookmark(int articleId) async { - try { - var jwtToken = await storage.read(key: 'token'); - final accessToken = json.decode(jwtToken!)['data']['accessToken']; + static Future marketbookmark(int articleId) async { + var url = 'http://3.34.2.246:8080/api/v2/community-articles/${articleId}/bookmarks'; - final url = Uri.parse( - 'http://3.34.2.246:8080/api/v2/market-articles/$articleId/bookmarks'); + //토큰 읽어오기 + var jwtToken = await storage.read(key: 'token'); - final response = await http.post( - url, - headers: { - 'Authorization': 'Bearer $accessToken', - 'Content-Type': 'application/json', - }, - ); + //accessToken만 보내기 + jwtToken = json.decode(jwtToken!)['data']['accessToken']; - if (response.statusCode == 200) { - final responseBody = json.decode(utf8.decode(response.bodyBytes)); - final message = responseBody['message']; - return message; - } else { - final responseBody = json.decode(utf8.decode(response.bodyBytes)); - final errorCode = responseBody['code']; + var response = await http.post(Uri.parse(url), + headers: { + 'Authorization': 'Bearer $jwtToken', + 'Content-Type': 'application/json'}, + ); + + //success + if (response.statusCode == 200) { + print(json.decode(utf8.decode(response.bodyBytes))); + return json.decode(utf8.decode(response.bodyBytes))['data']['likeCount']; + //fail + } else { + print(json.decode(utf8.decode(response.bodyBytes))); + if(json.decode(utf8.decode(response.bodyBytes))['code'] == 'AT-C-002'){ + print('액세스 토큰 만료'); + throw 'AT-C-002'; + } else if(json.decode(utf8.decode(response.bodyBytes))['code'] == 'AT-C-007'){ + print('로그아웃된 토큰'); + throw 'AT-C-007'; + }else{ - if (errorCode == 'AT-C-002') { - throw '액세스 토큰 만료'; - } else if (errorCode == 'AT-C-007') { - throw '로그아웃된 토큰'; - } else { - throw Exception('북마크 등록 오류'); - } } - } catch (error) { - print('Error adding market article bookmark: $error'); - throw Exception('북마크 등록 오류'); + return -1; } } /*상품 판매글 댓글 전체 조회*/ - static Future> getMarketArticleComments( - int marketArticleId) async { + static Future> getMarketArticleComments(int marketArticleId) async { try { var jwtToken = await storage.read(key: 'token'); final accessToken = json.decode(jwtToken!)['data']['accessToken']; @@ -1871,6 +1866,8 @@ class APIs { return body.map((dynamic item) => MarketComment.fromJson(item)) .toList(); } else { + print(json.decode(utf8.decode(response.bodyBytes))); + final responseBody = json.decode(utf8.decode(response.bodyBytes)); final errorCode = responseBody['code']; @@ -1890,42 +1887,41 @@ class APIs { /*상품 판매글 부모 댓글 등록*/ - static Future createMarketArticleComment(int articleCommentId, - String content) async { - try { - var jwtToken = await storage.read(key: 'token'); - final accessToken = json.decode(jwtToken!)['data']['accessToken']; + static Future createMarketArticleComment(String content, int articleId) async { + var url = 'http://3.34.2.246:8080/api/v2/market-articles/$articleId/market-article-comments'; - final url = Uri.parse( - 'http://3.34.2.246:8080/api/v2/market-articles/$articleCommentId/market-article-comments'); + //토큰 읽어오기 + var jwtToken = await storage.read(key: 'token'); - final response = await http.post( - url, + //accessToken만 보내기 + jwtToken = json.decode(jwtToken!)['data']['accessToken']; + + var response = await http.post(Uri.parse(url), headers: { - 'Authorization': 'Bearer $accessToken', - 'Content-Type': 'application/json', - }, - body: json.encode({'content': content}), - ); + 'Authorization': 'Bearer $jwtToken', + 'Content-Type': 'application/json'}, + body: jsonEncode({ + "content": content, + })); - if (response.statusCode == 201) { - print(json.decode(utf8.decode(response.bodyBytes))); - return true; + //success + if (response.statusCode == 200) { + print(json.decode(utf8.decode(response.bodyBytes))); + return true; + //fail + } else { + print(json.decode(utf8.decode(response.bodyBytes))); + if (json.decode(utf8.decode(response.bodyBytes))['code'] == 'AT-C-002') { + print('액세스 토큰 만료'); + throw 'AT-C-002'; + } else + if (json.decode(utf8.decode(response.bodyBytes))['code'] == 'AT-C-007') { + print('로그아웃된 토큰'); + throw 'AT-C-007'; } else { - final responseBody = json.decode(utf8.decode(response.bodyBytes)); - final errorCode = responseBody['code']; - if (errorCode == 'AT-C-002') { - throw '액세스 토큰 만료'; - } else if (errorCode == 'AT-C-007') { - throw '로그아웃된 토큰'; - } else { - throw Exception('댓글 생성 오류'); - } } - } catch (error) { - print('Error creating market article comment: $error'); - throw Exception('댓글 생성 오류'); + return false; } } @@ -1950,7 +1946,7 @@ class APIs { if (response.statusCode == 200) { final responseBody = json.decode(utf8.decode(response.bodyBytes)); final message = responseBody['message']; - return message; + return true; } else { final responseBody = json.decode(utf8.decode(response.bodyBytes)); final errorCode = responseBody['code']; @@ -1971,14 +1967,13 @@ class APIs { /*특정 상품 판매글 댓글에 대댓글 등록*/ - static Future addMarketArticleCommentReply(int articleCommentId, - int ArticleCommentId, String content) async { + static Future addMarketArticleCommentReply(String content, int commentId, int articleId) async { try { var jwtToken = await storage.read(key: 'token'); final accessToken = json.decode(jwtToken!)['data']['accessToken']; final url = Uri.parse( - 'http://3.34.2.246:8080/api/v2/market-articles/$articleCommentId/market-article-comments/$ArticleCommentId'); + 'http://3.34.2.246:8080/api/v2/market-articles/$articleId/market-article-comments/$commentId'); final response = await http.post( url, @@ -1990,9 +1985,10 @@ class APIs { ); if (response.statusCode == 200) { + print(json.decode(utf8.decode(response.bodyBytes))); final responseBody = json.decode(utf8.decode(response.bodyBytes)); final message = responseBody['message']; - return message; + return true; } else { final responseBody = json.decode(utf8.decode(response.bodyBytes)); final errorCode = responseBody['code']; diff --git a/lib/models/market_articles.dart b/lib/models/market_articles.dart index 623dc02..e492e1f 100644 --- a/lib/models/market_articles.dart +++ b/lib/models/market_articles.dart @@ -1,7 +1,7 @@ class MarketBoard { int? articleId; String? title; - String? status; + String? marketArticleStatus; int? price; String? productStatus; String? content; @@ -14,7 +14,7 @@ class MarketBoard { MarketBoard({ this.articleId, this.title, - this.status, + this.marketArticleStatus, this.price, this.productStatus, this.content, @@ -28,7 +28,7 @@ class MarketBoard { MarketBoard.fromJson(Map json) { articleId = json['articleId']; title = json['title']; - status = json['status']; + marketArticleStatus = json['marketArticleStatus']; price = json['price']; productStatus = json['productStatus']; content = json['content']; @@ -43,7 +43,7 @@ class MarketBoard { final Map data = {}; data['articleId'] = articleId; data['title'] = title; - data['status'] = status; + data['marketArticleStatus'] = marketArticleStatus; data['price'] = price; data['productStatus'] = productStatus; data['content'] = content; diff --git a/lib/providers/market_comment_provider.dart b/lib/providers/market_comment_provider.dart index 5d7ca29..761b443 100644 --- a/lib/providers/market_comment_provider.dart +++ b/lib/providers/market_comment_provider.dart @@ -14,30 +14,31 @@ class MarketCommentProvider with ChangeNotifier { bool loading = false; MarketComment? marketcomment; - getMarketComments(int articleCommentId) async { + getMarketComments(int articleId) async { loading = true; try { - commentListData = await APIs.getMarketArticleComments(articleCommentId); + commentListData = await APIs.getMarketArticleComments(articleId); } catch (e) { if (e == "AT-C-002") { await APIs.getAccessToken(); - commentListData = await APIs.getMarketArticleComments(articleCommentId); + commentListData = await APIs.getMarketArticleComments(articleId); } else { // 오류 처리 로직 } } loading = false; notifyListeners(); + } - addMarketComment(int articleId, String content) async { + addMarketComment(String content, int articleId) async { try { - await APIs.createMarketArticleComment(articleId, content); + await APIs.createMarketArticleComment(content,articleId); } catch (e) { if (e == "AT-C-002") { await APIs.getAccessToken(); - await APIs.createMarketArticleComment(articleId, content); + await APIs.createMarketArticleComment(content,articleId); } else { return false; } @@ -46,24 +47,26 @@ class MarketCommentProvider with ChangeNotifier { notifyListeners(); + getMarketComments(articleId); return true; } - addNestedMarketComment(int commentId, int ArticleCommentId, String content) async { + addNestedMarketComment(String content, int commentId, int articleId) async { try { - await APIs.addMarketArticleCommentReply(commentId, ArticleCommentId, content); + await APIs.addMarketArticleCommentReply(content, commentId,articleId ); } catch (e) { if (e == "AT-C-002") { await APIs.getAccessToken(); - await APIs.addMarketArticleCommentReply(commentId, ArticleCommentId, content); + await APIs.addMarketArticleCommentReply(content, commentId,articleId); } else { return false; } } //TODO fcm 전송 - notifyListeners(); + getMarketComments(articleId); + return true; } deleteMarketComment(int articleId) async { @@ -80,6 +83,8 @@ class MarketCommentProvider with ChangeNotifier { } loading = false; notifyListeners(); + getMarketComments(articleId); + return value; } diff --git a/lib/views/components/board_drawer_widget.dart b/lib/views/components/board_drawer_widget.dart index e361dca..7b89a73 100644 --- a/lib/views/components/board_drawer_widget.dart +++ b/lib/views/components/board_drawer_widget.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:aliens/models/chatRoom_model.dart'; +import 'package:aliens/models/memberDetails_model.dart'; import 'package:aliens/models/screenArgument.dart'; import 'package:aliens/repository/sql_message_database.dart'; import 'package:aliens/views/pages/board/article_writing_page.dart'; @@ -33,6 +34,7 @@ class BoardDrawerWidget extends StatefulWidget { final ScreenArguments screenArguments; final MarketBoard? marketBoard; + //final MemberDetails memberDetails; final bool isTotalBoard; final VoidCallback onpressd; @@ -449,7 +451,7 @@ class _BoardDrawerWidgetState extends State { Navigator.push( context, MaterialPageRoute( - builder: (context) => MarketBoardPage(screenArguments: widget.screenArguments, marketBoard: widget.marketBoard,)), + builder: (context) => MarketBoardPage(screenArguments: widget.screenArguments, marketBoard: widget.marketBoard)), ); } diff --git a/lib/views/components/marketcomment_dialog.dart b/lib/views/components/marketcomment_dialog.dart index 23aa7dd..19a3002 100644 --- a/lib/views/components/marketcomment_dialog.dart +++ b/lib/views/components/marketcomment_dialog.dart @@ -81,7 +81,7 @@ class MarketCommentDialog extends StatelessWidget{ InkWell( onTap: (){ //TODO 로딩 만들기 - // marketcommentProvider.deleteComment(marketcomment.articleCommentId!); + marketcommentProvider.deleteMarketComment(marketcomment.articleCommentId!); }, child: Container( padding: EdgeInsets.all(13).r, @@ -155,7 +155,7 @@ class MarketCommentDialog extends StatelessWidget{ InkWell( onTap: () { //TODO 로딩 만들기 - // marketcommentProvider.deleteComment(marketcomment.articleCommentId!); + marketcommentProvider.deleteMarketComment(marketcomment.articleCommentId!); }, child: Container( height: 80, diff --git a/lib/views/components/total_article_widget.dart b/lib/views/components/total_article_widget.dart index 6700a3d..76e8ea3 100644 --- a/lib/views/components/total_article_widget.dart +++ b/lib/views/components/total_article_widget.dart @@ -18,16 +18,19 @@ import 'dart:convert'; import '../../models/board_model.dart'; import '../../repository/board_provider.dart'; import '../pages/board/article_page.dart'; +import '../pages/board/market_board_page.dart'; import '../pages/board/market_detail_page.dart'; import 'board_dialog_widget.dart'; class TotalArticleWidget extends StatefulWidget { - TotalArticleWidget({super.key, required this.board, required this.nationCode, required this.screenArguments, required this.index}); + + TotalArticleWidget({super.key, required this.board, required this.nationCode, required this.screenArguments, required this.index, this.marketBoard}); final Board board; final String nationCode; final ScreenArguments screenArguments; + final MarketBoard? marketBoard; final int index; @override State createState() => _TotalArticleWidgetState(); @@ -280,7 +283,7 @@ class _TotalArticleWidgetState extends State{ //받아온 후 WidgetsBinding.instance!.addPostFrameCallback((_) {Navigator.push( context, - MaterialPageRoute(builder: (context) => MarketDetailPage(screenArguments: widget.screenArguments, marketBoard: data,)), + MaterialPageRoute(builder: (context) => MarketDetailPage(screenArguments: widget.screenArguments, marketBoard: data, productStatus: '',)), ); }); return Container( diff --git a/lib/views/pages/board/market_board_page.dart b/lib/views/pages/board/market_board_page.dart index 8ba3402..dc1d87f 100644 --- a/lib/views/pages/board/market_board_page.dart +++ b/lib/views/pages/board/market_board_page.dart @@ -1,7 +1,9 @@ import 'dart:async'; import 'package:aliens/apis/apis.dart'; +import 'package:aliens/mockdatas/mockdata_model.dart'; import 'package:aliens/models/chatRoom_model.dart'; +import 'package:aliens/models/memberDetails_model.dart'; import 'package:aliens/models/screenArgument.dart'; import 'package:aliens/repository/sql_message_database.dart'; import 'package:aliens/views/pages/board/market_detail_page.dart'; @@ -19,9 +21,10 @@ import '../../components/board_drawer_widget.dart'; class MarketBoardPage extends StatefulWidget { - const MarketBoardPage({super.key, required this.screenArguments, required this.marketBoard}); + const MarketBoardPage({super.key, required this.screenArguments, required this.marketBoard,}); final ScreenArguments screenArguments; final MarketBoard? marketBoard; + //final MemberDetails memberDetails; @@ -49,7 +52,10 @@ class _MarketBoardPageState extends State { setState(() { marketBoardList = fetchedData; // 불러온 데이터를 리스트에 할당 for (var marketBoard in marketBoardList) { - print('createdAt: ${marketBoard.createdAt}'); + // print('createdAt: ${marketBoard.createdAt}'); + // print('status: ${marketBoard.marketArticleStatus}'); + // print('productstatus: ${marketBoard.productStatus}'); + } }); @@ -121,7 +127,8 @@ class _MarketBoardPageState extends State { ), body: isDrawerStart - ? BoardDrawerWidget(screenArguments: widget.screenArguments, + ? BoardDrawerWidget( + screenArguments: widget.screenArguments, isTotalBoard: false, onpressd: () {}, ) @@ -188,6 +195,8 @@ class _MarketBoardPageState extends State { itemBuilder: (BuildContext context, int index) { MarketBoard marketBoard = marketBoardList[index]; + String productStatusText = getProductStatusText(marketBoard.productStatus); + return InkWell( onTap: () { Navigator.push( @@ -197,6 +206,8 @@ class _MarketBoardPageState extends State { MarketDetailPage( screenArguments: widget.screenArguments, marketBoard: marketBoard, + productStatus: getProductStatusText(marketBoard.productStatus), + // memberDetails: widget.memberDetails, ), ), ); @@ -226,7 +237,7 @@ class _MarketBoardPageState extends State { left: 10.w, right: 10.w, top: 2.h, bottom: 2.h), height: 21.spMin, child: Text( - marketBoard.productStatus ?? "", // 상품 상태 정보 + '[$productStatusText]', // 상품 상태 정보 style: TextStyle( fontSize: 10.spMin, color: Colors.white), textAlign: TextAlign.center, @@ -251,7 +262,7 @@ class _MarketBoardPageState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - '[${marketBoard.status ?? ""}]', // 상태 정보 사용 + '[${marketBoard.marketArticleStatus ?? ""}]', // 상태 정보 사용 style: TextStyle( color: Color(0xff616161), fontSize: 16.spMin, @@ -361,6 +372,28 @@ class _MarketBoardPageState extends State { }, itemCount: marketBoardList.length, ); + } +} + +String getProductStatusText(String? productStatus) { + List whatStatus = [ + 'Brand_New'.tr(), + 'Almost_New'.tr(), + 'Slight_Defect'.tr(), + 'Used'.tr(), + ]; + switch (productStatus) { + case '새 것': + return whatStatus[0]; + case '거의 새 것': + return whatStatus[1]; + case '약간의 하자': + return whatStatus[2]; + case '사용감 있음': + return whatStatus[3]; + default: + return ''; + } } diff --git a/lib/views/pages/board/market_detail_page.dart b/lib/views/pages/board/market_detail_page.dart index ab6c915..95a1429 100644 --- a/lib/views/pages/board/market_detail_page.dart +++ b/lib/views/pages/board/market_detail_page.dart @@ -1,7 +1,9 @@ import 'dart:async'; +import 'package:aliens/apis/apis.dart'; import 'package:aliens/mockdatas/board_mockdata.dart'; import 'package:aliens/models/chatRoom_model.dart'; import 'package:aliens/models/market_articles.dart'; +import 'package:aliens/models/memberDetails_model.dart'; import 'package:aliens/models/screenArgument.dart'; import 'package:aliens/repository/sql_message_database.dart'; import 'package:aliens/views/pages/chatting/chatting_page.dart'; @@ -31,9 +33,11 @@ import '../home_page.dart'; class MarketDetailPage extends StatefulWidget { const MarketDetailPage( - {super.key, required this.screenArguments, required this.marketBoard}); + {super.key, required this.screenArguments, required this.marketBoard, required this.productStatus}); final ScreenArguments screenArguments; final MarketBoard marketBoard; + //final MemberDetails memberDetails; + final String productStatus; @@ -46,7 +50,8 @@ class _MarketDetailPageState extends State { final _controller = TextEditingController(); var _newComment = ''; bool isNestedComments = false; - int parentsCommentIndex = -1; + int parentsCommentId = -1; + bool showLoading = false; void sendComment() async { updateUi(); @@ -72,36 +77,37 @@ class _MarketDetailPageState extends State { return nationCode; } + void initState() { + super.initState(); + final marketcommentProvider = Provider.of(context, listen: false); + marketcommentProvider.getMarketComments(widget.marketBoard.articleId!); + } @override Widget build(BuildContext context) { //print('Data from marketBoard: ${widget.marketBoard.createdAt}'); - final double screenWidth = MediaQuery.of(context).size.height; - final bool isSmallScreen = screenWidth <= 700; - List whatStatus = [ 'Brand_New'.tr(), 'Almost_New'.tr(), 'Slight_Defect'.tr(), 'Used'.tr() ]; String productStatus = '${widget.marketBoard.productStatus}'; - final marketcommentProvider = Provider.of(context, listen: false); - marketcommentProvider.getMarketComments(widget.marketBoard.articleId!); + final marketcommentProvider = Provider.of(context); - bool showLoading = marketcommentProvider.loading; + /* bool showLoading = marketcommentProvider.loading; if (showLoading) { Future.delayed(Duration(seconds: 3), () { setState(() { showLoading = false; }); }); - } + }*/ return GestureDetector( onTap: (){ FocusScope.of(context).unfocus(); setState(() { isNestedComments = false; - parentsCommentIndex = -1; + parentsCommentId = -1; }); }, child: Scaffold( @@ -182,7 +188,7 @@ class _MarketDetailPageState extends State { child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text('${widget.marketBoard.status}', + Text('${widget.marketBoard.marketArticleStatus}', textAlign: TextAlign.center, style: TextStyle( color: Color(0xff888888), @@ -225,7 +231,7 @@ class _MarketDetailPageState extends State { child: Row( children: whatStatus.map((condition) { - final bool isSelected = productStatus == + final bool isSelected = getProductStatusText(productStatus) == condition; return Padding( padding: EdgeInsets.symmetric( @@ -313,13 +319,16 @@ class _MarketDetailPageState extends State { ), Row( children: [ - Padding( - padding: const EdgeInsets.all(4.0).r, - child: SvgPicture.asset( - 'assets/icon/ICON_good.svg', - width: 18.r, - height: 18.r, - color: Color(0xffc1c1c1), + InkWell( + onTap: (){}, + child: Padding( + padding: const EdgeInsets.all(4.0).r, + child: SvgPicture.asset( + 'assets/icon/ICON_good.svg', + width: 18.r, + height: 18.r, + color: Color(0xffc1c1c1), + ), ), ), Padding( @@ -355,19 +364,17 @@ class _MarketDetailPageState extends State { ), Divider(thickness: 1.2.h,color: Color(0xffE5EBFF),), - //댓글 - showLoading - ? Container( - alignment: Alignment.center, - child: Image( - image: AssetImage("assets/illustration/loading_01.gif"), - ), - ) + marketcommentProvider.loading || marketcommentProvider.commentListData == null? + Container( + alignment: Alignment.center, + child: Image( + image: AssetImage( + "assets/illustration/loading_01.gif"))) : Column( children: [ - for(int index = 0; index < 5; index++) + for(int index = 0; index < marketcommentProvider.commentListData!.length; index++) Container( child: Column( children: [ @@ -423,11 +430,13 @@ class _MarketDetailPageState extends State { return MarketCommentDialog(context: context, onpressed: (){ setState(() { isNestedComments = true; - parentsCommentIndex = index; + parentsCommentId = marketcommentProvider.commentListData![index].articleCommentId!; }); Navigator.pop(context); }, - isNestedComment: false, marketcomment: marketcommentProvider.commentListData![index]); + isNestedComment: false, + marketcomment: marketcommentProvider.commentListData![index], + ); }); }, child: Padding( @@ -525,7 +534,8 @@ class _MarketDetailPageState extends State { }); Navigator.pop(context); }, - isNestedComment: true,marketcomment: marketcommentProvider.commentListData![index]); + isNestedComment: true, + marketcomment: marketcommentProvider.commentListData![index]); }); }, child: Padding( @@ -577,80 +587,85 @@ class _MarketDetailPageState extends State { child: Container( decoration: BoxDecoration( color: Color(0xffefefef), - borderRadius: BorderRadius.circular(10).r, - ), - padding: EdgeInsets.symmetric(horizontal: 10).w, - child: Row( - children: [ - Expanded( - child: TextField( - maxLines: null, - inputFormatters: [ - LengthLimitingTextInputFormatter(255), - ], - keyboardType: TextInputType.multiline, - decoration: InputDecoration( - hintText: isNestedComments? "comment2".tr() : "comment1".tr(), - hintStyle: TextStyle(color: Color(0xffb1b1b1)), - border: InputBorder.none, - ), - onTap: () { - if (_newComment.trim().isEmpty) {} - }, - controller: _controller, - onChanged: (value) { - setState(() { - _newComment = value; - }); - }, - )), - IconButton( - onPressed: () { - if(isNestedComments){ - MarketComment newValue = MarketComment( - articleCommentId: 1, - content: _newComment, - createdAt: DateTime.now().toString(), - childs: [], - member: MarketCommentMember( - name: "daisy", - nationality: "Japan", - profileImageUrl: "" - ) - ); - //CommentRepository.addCommentChilds(parentsCommentIndex, newValue); - parentsCommentIndex = -1; - isNestedComments = false; - } - else{ - MarketComment newValue = MarketComment( - articleCommentId: 1, - content: _newComment, - createdAt: DateTime.now().toString(), - childs: [], - member: MarketCommentMember( - name: "daisy", - nationality: "Japan", - profileImageUrl: "" - ) - ); - //CommentRepository.addComment(newValue); - } - updateUi(); - }, - icon: SvgPicture.asset( - 'assets/icon/ICON_send.svg', - height: 22.r, - color: _newComment.trim().isEmpty - ? Color(0xffc1c1c1) - : Color(0xff7898ff), - ), + borderRadius: BorderRadius.circular(10).r, ), - ], - )), - ), + padding: EdgeInsets.symmetric(horizontal: 10).w, + child: Row( + children: [ + Expanded( + child: TextField( + maxLines: null, + inputFormatters: [ + LengthLimitingTextInputFormatter(255), + ], + keyboardType: TextInputType.multiline, + decoration: InputDecoration( + hintText: isNestedComments? "comment2".tr() : "comment1".tr(), + hintStyle: TextStyle(color: Color(0xffb1b1b1)), + border: InputBorder.none, + ), + onTap: () { + if (_newComment.trim().isEmpty) {} + }, + controller: _controller, + onChanged: (value) { + setState(() { + _newComment = value; + }); + }, + )), + IconButton( + onPressed: () { + print('${parentsCommentId}'); + if(_newComment != ''){ + if(isNestedComments){ + marketcommentProvider.addNestedMarketComment(_newComment, parentsCommentId, widget.marketBoard.articleId!); + //여기 페이지 재로드하는거나 marketcommentprovider 재로드를 넣어야할거같아 + parentsCommentId = -1; + isNestedComments = false; + + } + else{ + marketcommentProvider.addMarketComment(_newComment, widget.marketBoard.articleId!); + } + updateUi(); + } + + }, + icon: SvgPicture.asset( + 'assets/icon/ICON_send.svg', + height: 22.r, + color: _newComment.trim().isEmpty + ? Color(0xffc1c1c1) + : Color(0xff7898ff), + ), + ), + ], + )), + ), ]), ), ); } } +String getProductStatusText(String? productStatus) { + List whatStatus = [ + 'Brand_New'.tr(), + 'Almost_New'.tr(), + 'Slight_Defect'.tr(), + 'Used'.tr(), + ]; + + switch (productStatus) { + case '새 것': + return whatStatus[0]; + case '거의 새 것': + return whatStatus[1]; + case '약간의 하자': + return whatStatus[2]; + case '사용감 있음': + return whatStatus[3]; + default: + return ''; + } +} \ No newline at end of file