diff --git a/assets/images/ic_launcher.png b/assets/images/ic_launcher.png new file mode 100644 index 0000000..2da766c Binary files /dev/null and b/assets/images/ic_launcher.png differ diff --git a/assets/images/ic_memory.png b/assets/images/ic_memory.png index 587a366..0f86e2c 100644 Binary files a/assets/images/ic_memory.png and b/assets/images/ic_memory.png differ diff --git a/lib/dialog/restart_chat_dialog.dart b/lib/dialog/restart_chat_dialog.dart new file mode 100644 index 0000000..0f9a322 --- /dev/null +++ b/lib/dialog/restart_chat_dialog.dart @@ -0,0 +1,93 @@ +import 'package:flutter/material.dart'; + +class RestartChatDialog extends StatefulWidget { + Function onTap; + + RestartChatDialog({required this.onTap}); + + @override + State createState() => _RestartChatDialogState(); +} + +class _RestartChatDialogState extends State { + @override + void initState() { + // TODO: implement initState + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Material( + type: MaterialType.transparency, //透明类型 + color: Color(0x1A000000), + child: Center( + child: ClipRRect( + borderRadius: BorderRadius.circular(7.0), + child: Container( + width: 247, + color: Color(0xFF272727), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + margin: EdgeInsets.only(top: 28), + child: Text( + '确认重启聊天吗?\n聊天记录都将清空!', + textAlign: TextAlign.center, + style: TextStyle(fontSize: 15, color: Color(0xFFBABABA)), + ), + ), + Container( + margin: EdgeInsets.only(top: 38, left: 22, right: 22, bottom: 19), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + GestureDetector( + onTap: () { + Navigator.pop(context); + }, + child: Container( + width: 80, + height: 28, + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(14)), + border: Border.all(color: Color(0xFFFF9000), width: 1), + ), + child: Text( + '取消', + style: TextStyle(color: Color(0xFFFF9000), fontSize: 12), + ), + ), + ), + GestureDetector( + onTap: () { + Navigator.pop(context); + widget.onTap(); + }, + child: Container( + width: 80, + height: 28, + alignment: Alignment.center, + decoration: BoxDecoration( + color: Color(0xFFFF9000), + borderRadius: BorderRadius.all(Radius.circular(14)), + ), + child: Text( + '确定', + style: TextStyle(color: Colors.black, fontSize: 12), + ), + ), + ), + ], + ), + ), + ], + ), + ), + ), + ), + ); + } +} diff --git a/lib/main.dart b/lib/main.dart index d3b3dc8..6c2e395 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -7,6 +7,7 @@ import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:talk/tools/home/test_page.dart'; import 'package:talk/tools/home_page.dart'; import 'package:talk/tools/login/login_page.dart'; +import 'package:talk/tools/me/about_page.dart'; import 'package:talk/tools/me/setting_page.dart'; import 'package:talk/tools/search/search_page.dart'; import 'package:talk/tools/shop/account_page.dart'; @@ -45,6 +46,8 @@ class _ChatAppState extends State { void initState() { // TODO: implement initState super.initState(); + //白色 + SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light); } @override @@ -62,6 +65,7 @@ class _ChatAppState extends State { '/ShopPage': (BuildContext context) => const ShopPage(), '/SettingPage': (BuildContext context) => const SettingPage(), '/TestPage': (BuildContext context) => const TestPage(), + '/AboutPage': (BuildContext context) => const AboutPage(), }, debugShowMaterialGrid: false, //显示网格 diff --git a/lib/tools/chat/chat_page.dart b/lib/tools/chat/chat_page.dart index eefd79f..6e50366 100644 --- a/lib/tools/chat/chat_page.dart +++ b/lib/tools/chat/chat_page.dart @@ -10,7 +10,10 @@ import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart'; import '../../beans/character_info_bean.dart'; import '../../beans/chat_info_bean.dart'; import '../../beans/send_message_bean.dart'; +import '../../common/func.dart'; import '../../custom/custom_popup.dart'; +import '../../dialog/delete_dialog.dart'; +import '../../dialog/restart_chat_dialog.dart'; import 'chat_info_page.dart'; import 'chat_model.dart'; @@ -174,6 +177,15 @@ class _ChatPageState extends State { @override Widget build(BuildContext context) { + final size = MediaQuery.of(context).size; + final h311 = size.width / 1.1575562700964; + final h30 = size.width / 12; + final h35 = size.width / 10.285714285714; + final h23 = size.width / 15.652173913043; + final w27 = size.width / 13.333333333333; + final h70 = size.width / 5.1428571428571; + final l50 = size.width / 7.2; + return Scaffold( backgroundColor: Color(0xFF121213), body: Stack( @@ -191,7 +203,7 @@ class _ChatPageState extends State { bottom: 0, child: Container( width: MediaQuery.of(context).size.width, - height: 311.67, + height: h311, decoration: BoxDecoration( gradient: LinearGradient( colors: [Color(0x00000000), Color(0xFF0C0909)], // 三色渐变数组 @@ -222,7 +234,7 @@ class _ChatPageState extends State { ///title Container( width: double.infinity, - height: 30, + height: h30, margin: EdgeInsets.only(top: 10, left: 16, right: 16), child: Stack( alignment: Alignment.center, @@ -236,7 +248,7 @@ class _ChatPageState extends State { Positioned( left: 0, child: Container( - height: 30, + height: h30, decoration: BoxDecoration(color: Color(0x33000000), borderRadius: BorderRadius.all(Radius.circular(14))), child: Row( crossAxisAlignment: CrossAxisAlignment.center, @@ -274,7 +286,7 @@ class _ChatPageState extends State { mainAxisSize: MainAxisSize.min, children: [ SizedBox( - width: 35, + width: h35, child: Text( "${characterInfoBean?.characterName}", overflow: TextOverflow.ellipsis, @@ -282,7 +294,7 @@ class _ChatPageState extends State { ), ), SizedBox( - width: 35, + width: h35, child: Text( '${characterInfoBean?.lookCount} 聊过', style: TextStyle(fontSize: 7, color: Colors.white), @@ -436,8 +448,8 @@ class _ChatPageState extends State { Container( margin: const EdgeInsets.only(right: 7), child: text == "" - ? const Image( - width: 27, + ? Image( + width: w27, image: AssetImage('assets/images/ic_send_n.png'), ) : GestureDetector( @@ -453,7 +465,7 @@ class _ChatPageState extends State { setState(() {}); }, child: Image( - width: 27, + width: w27, image: AssetImage('assets/images/ic_send.png'), ), ), @@ -485,7 +497,7 @@ class _ChatPageState extends State { child: Container( margin: EdgeInsets.only(left: 14), child: Image( - width: 27, + width: w27, image: AssetImage('assets/images/ic_more.png'), ), ), @@ -496,37 +508,42 @@ class _ChatPageState extends State { isMore ? Container( - height: 50, + height: h70, alignment: Alignment.centerLeft, - margin: const EdgeInsets.only(left: 16, right: 16, bottom: 20), + margin: EdgeInsets.only(left: 16, right: 16, bottom: 20), child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ + // Container( + // margin: EdgeInsets.only(left: 23), + // child: Column( + // mainAxisSize: MainAxisSize.min, + // children: [ + // Image(width: 26, image: AssetImage('assets/images/ic_album.png')), + // Container( + // margin: EdgeInsets.only(top: 9), + // child: Text( + // '角色相册', + // style: TextStyle(fontSize: 10, color: Color(0xFFA2A2A2)), + // ), + // ), + // ], + // ), + // ), Container( - margin: EdgeInsets.only(left: 23), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Image(width: 26, image: AssetImage('assets/images/ic_album.png')), - Container( - margin: EdgeInsets.only(top: 9), - child: Text( - '角色相册', - style: TextStyle(fontSize: 10, color: Color(0xFFA2A2A2)), - ), - ), - ], - ), - ), - Container( - margin: EdgeInsets.only(left: 23), + margin: EdgeInsets.only(left: h23), child: GestureDetector( onTap: () { setState(() { isMore = false; }); - EasyLoading.show(status: 'loading...'); - _viewmodel.delChat(widget.characterId); + + FunctionUtil.popDialog(context, RestartChatDialog( + onTap: () { + EasyLoading.show(status: 'loading...'); + _viewmodel.delChat(widget.characterId); + }, + )); }, child: Column( mainAxisSize: MainAxisSize.min, @@ -544,7 +561,7 @@ class _ChatPageState extends State { ), ), Container( - margin: EdgeInsets.only(left: 23), + margin: EdgeInsets.only(left: l50), child: GestureDetector( onTap: () { setState(() { @@ -592,7 +609,7 @@ class _ChatPageState extends State { return Center( key: key, child: Container( - margin: EdgeInsets.only(left: 16, right: 16, bottom: 20), + margin: EdgeInsets.only(left: 12, right: 12, bottom: 20), padding: EdgeInsets.only(left: 20, right: 20, top: 12, bottom: 12), decoration: BoxDecoration(color: Color(0x99000000), borderRadius: BorderRadius.all(Radius.circular(13))), child: ExpandableText( @@ -675,7 +692,7 @@ class _ChatPageState extends State { margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 12), padding: const EdgeInsets.all(11.0), decoration: const BoxDecoration( - color: Color(0x99FF9000), + color: Color(0xFFFF9000), borderRadius: BorderRadius.only( topRight: Radius.circular(16.0), bottomLeft: Radius.circular(16.0), bottomRight: Radius.circular(16.0)), ), @@ -683,7 +700,7 @@ class _ChatPageState extends State { chatList[index].content!, style: const TextStyle( fontSize: 14, - color: Color(0xFFE8E8E8), + color: Colors.black, ), ), ), @@ -766,9 +783,9 @@ class _ChatPageState extends State { Expanded( child: GestureDetector( onTap: () { + customController.hideMenu(); EasyLoading.showToast("内容已复制"); Clipboard.setData(ClipboardData(text: content)); - customController.hideMenu(); }, child: Column( mainAxisAlignment: MainAxisAlignment.center, @@ -788,7 +805,11 @@ class _ChatPageState extends State { child: GestureDetector( onTap: () { customController.hideMenu(); - deleteChat(id, index); + FunctionUtil.popDialog(context, DeleteDialog( + onTap: () { + deleteChat(id, index); + }, + )); }, child: Column( mainAxisAlignment: MainAxisAlignment.center, diff --git a/lib/tools/find/multiplex_page.dart b/lib/tools/find/multiplex_page.dart index 63c2e87..c2bcfe9 100644 --- a/lib/tools/find/multiplex_page.dart +++ b/lib/tools/find/multiplex_page.dart @@ -75,15 +75,27 @@ class _MultiplexPageState extends State { } _item(index, CategoryInfoListBean data) { + final size = MediaQuery.of(context).size; + final w130 = size.width / 2.7692307692307; + final h50 = size.width / 7.2; + final b23 = size.width / 15.652173913043; + final w83 = size.width / 4.3373493975903; + final h115 = size.width / 3.1304347826086; + final l101 = size.width / 3.5643564356435; + final t45 = size.width / 8; + final w200 = size.width / 1.8; + final l102 = size.width / 3.5294117647058; + final h70 = size.width / 5.1428571428571; + return GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { goChatPage(data.id.toString()); }, child: Container( - height: 130, - width: 50, - margin: EdgeInsets.only(bottom: 23), + height: w130, + width: h50, + margin: EdgeInsets.only(bottom: b23), decoration: BoxDecoration( color: Color(0xFF202021), borderRadius: BorderRadius.all(Radius.circular(7)), @@ -94,30 +106,29 @@ class _MultiplexPageState extends State { children: [ Positioned( left: 7, - child: - ClipRRect( - borderRadius: BorderRadius.all(Radius.circular(15)), - child: CachedNetworkImage( - width: 83, - height: 115, - fit: BoxFit.cover, - imageUrl: data.iconImage!, - errorWidget: (context, url, error) => const Icon(Icons.error), - ), + child: ClipRRect( + borderRadius: BorderRadius.all(Radius.circular(15)), + child: CachedNetworkImage( + width: w83, + height: h115, + fit: BoxFit.cover, + imageUrl: data.bgImage!, + errorWidget: (context, url, error) => const Icon(Icons.error), ), + ), ), Positioned( - left: 101, + left: l101, top: 19, child: Text( '${data.name}', style: TextStyle(color: Colors.white, fontSize: 14), )), Positioned( - left: 101, - top: 45, + left: l101, + top: t45, child: SizedBox( - width: 200, + width: w200, height: 16, child: ListView.builder( itemCount: data.label?.length, @@ -127,7 +138,8 @@ class _MultiplexPageState extends State { alignment: Alignment.center, padding: EdgeInsets.symmetric(horizontal: 11), margin: EdgeInsets.only(right: 5), - decoration: BoxDecoration(border: Border.all(color: Color(0xFFFF9000)), borderRadius: BorderRadius.all(Radius.circular(7))), + decoration: BoxDecoration( + border: Border.all(color: Color(0xFFFF9000), width: 0.33), borderRadius: BorderRadius.all(Radius.circular(7))), child: Text( '${data.label?[index].name}', style: TextStyle(fontSize: 10, color: Color(0xFFFF9000)), @@ -136,10 +148,10 @@ class _MultiplexPageState extends State { }), )), Positioned( - left: 102, - top: 70, + left: l102, + top: h70, child: Container( - width: 200, + width: w200, child: Text( maxLines: 3, '${data.biography}', diff --git a/lib/tools/find/recommend_page.dart b/lib/tools/find/recommend_page.dart index 1a32906..958a086 100644 --- a/lib/tools/find/recommend_page.dart +++ b/lib/tools/find/recommend_page.dart @@ -285,7 +285,12 @@ class _RecommendPageState extends State with AutomaticKeepAliveCl alignment: Alignment.center, padding: EdgeInsets.symmetric(horizontal: 11), margin: EdgeInsets.only(right: 5), - decoration: BoxDecoration(border: Border.all(color: Color(0xFFFF9000)), borderRadius: BorderRadius.all(Radius.circular(7))), + decoration: BoxDecoration( + border: Border.all( + color: Color(0xFFFF9000), + width: 0.33, + ), + borderRadius: BorderRadius.all(Radius.circular(7))), child: Text( '${data.label?[index].name}', style: TextStyle(fontSize: 10, color: Color(0xFFFF9000)), diff --git a/lib/tools/home/home_chat_page.dart b/lib/tools/home/home_chat_page.dart index a5bae2b..340977a 100644 --- a/lib/tools/home/home_chat_page.dart +++ b/lib/tools/home/home_chat_page.dart @@ -13,6 +13,7 @@ import '../../beans/send_message_bean.dart'; import '../../common/func.dart'; import '../../custom/custom_popup.dart'; import '../../dialog/delete_dialog.dart'; +import '../../dialog/restart_chat_dialog.dart'; import '../../network/NetworkConfig.dart'; import '../chat/chat_info_page.dart'; import '../chat/chat_model.dart'; @@ -181,8 +182,11 @@ class _HomeChatPageState extends State with AutomaticKeepAliveClie final h311 = size.width / 1.1575562700964; final h30 = size.width / 12; final h35 = size.width / 10.285714285714; + final h23 = size.width / 15.652173913043; + final w27 = size.width / 13.333333333333; + final h70 = size.width / 5.1428571428571; + final l50 = size.width / 7.2; - super.build(context); return Scaffold( resizeToAvoidBottomInset: false, backgroundColor: Color(0xFF121213), @@ -230,7 +234,7 @@ class _HomeChatPageState extends State with AutomaticKeepAliveClie left: 0, child: Container( height: h30, - decoration: BoxDecoration(color: Color(0x33000000), borderRadius: BorderRadius.all(Radius.circular(14))), + decoration: BoxDecoration(color: Color(0x33000000), borderRadius: BorderRadius.all(Radius.circular(20))), child: Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, @@ -250,8 +254,8 @@ class _HomeChatPageState extends State with AutomaticKeepAliveClie margin: EdgeInsets.only(left: 2), child: ClipOval( child: CachedNetworkImage( - width: 23, - height: 23, + width: h23, + height: h23, imageUrl: '${characterInfoBean.icon}', errorWidget: (context, url, error) => const Icon(Icons.error), ), @@ -432,8 +436,8 @@ class _HomeChatPageState extends State with AutomaticKeepAliveClie Container( margin: const EdgeInsets.only(right: 7), child: text == "" - ? const Image( - width: 27, + ? Image( + width: w27, image: AssetImage('assets/images/ic_send_n.png'), ) : GestureDetector( @@ -453,7 +457,7 @@ class _HomeChatPageState extends State with AutomaticKeepAliveClie setState(() {}); }, child: Image( - width: 27, + width: w27, image: AssetImage('assets/images/ic_send.png'), ), ), @@ -489,7 +493,7 @@ class _HomeChatPageState extends State with AutomaticKeepAliveClie child: Container( margin: EdgeInsets.only(left: 14), child: Image( - width: 27, + width: w27, image: !isMore ? AssetImage('assets/images/ic_more.png') : AssetImage('assets/images/ic_more_no.png'), ), ), @@ -500,40 +504,42 @@ class _HomeChatPageState extends State with AutomaticKeepAliveClie isMore ? Container( - height: 70, + height: h70, alignment: Alignment.centerLeft, - margin: EdgeInsets.only( - left: 16, - right: 16, - ), + margin: EdgeInsets.only(left: 16, right: 16, bottom: 20), child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ + // Container( + // margin: EdgeInsets.only(left: 23), + // child: Column( + // mainAxisSize: MainAxisSize.min, + // children: [ + // Image(width: 26, image: AssetImage('assets/images/ic_album.png')), + // Container( + // margin: EdgeInsets.only(top: 9), + // child: Text( + // '角色相册', + // style: TextStyle(fontSize: 10, color: Color(0xFFA2A2A2)), + // ), + // ), + // ], + // ), + // ), Container( - margin: EdgeInsets.only(left: 23), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Image(width: 26, image: AssetImage('assets/images/ic_album.png')), - Container( - margin: EdgeInsets.only(top: 9), - child: Text( - '角色相册', - style: TextStyle(fontSize: 10, color: Color(0xFFA2A2A2)), - ), - ), - ], - ), - ), - Container( - margin: EdgeInsets.only(left: 23), + margin: EdgeInsets.only(left: h23), child: GestureDetector( onTap: () { setState(() { isMore = false; }); - EasyLoading.show(status: 'loading...'); - _viewmodel.delChat(widget.characterId); + + FunctionUtil.popDialog(context, RestartChatDialog( + onTap: () { + EasyLoading.show(status: 'loading...'); + _viewmodel.delChat(widget.characterId); + }, + )); }, child: Column( mainAxisSize: MainAxisSize.min, @@ -551,7 +557,7 @@ class _HomeChatPageState extends State with AutomaticKeepAliveClie ), ), Container( - margin: EdgeInsets.only(left: 23), + margin: EdgeInsets.only(left: l50), child: GestureDetector( onTap: () { setState(() { @@ -589,6 +595,11 @@ class _HomeChatPageState extends State with AutomaticKeepAliveClie ///聊天条目 _item(index) { + final size = MediaQuery.of(context).size; + final b20 = size.width / 18; + final l50 = size.width / 7.2; + final w135 = size.width / 2.666666666; + final h40 = size.width / 9; // if (index == 0) { // return Container(); // } @@ -633,6 +644,7 @@ class _HomeChatPageState extends State with AutomaticKeepAliveClie }, child: Container( padding: const EdgeInsets.only(left: 9, right: 9, top: 6, bottom: 6), + margin: EdgeInsets.only(bottom: b20), decoration: const BoxDecoration( color: Color(0xCC000000), borderRadius: BorderRadius.all(Radius.circular(15)), @@ -640,7 +652,7 @@ class _HomeChatPageState extends State with AutomaticKeepAliveClie child: Row( mainAxisSize: MainAxisSize.min, children: [ - Text(chatList[index].content!, style: TextStyle(color: Color(0xFFB6B6B6), fontSize: 10)), + Text(chatList[index].content!, style: const TextStyle(color: Color(0xFFB6B6B6), fontSize: 10)), Container( margin: const EdgeInsets.only(left: 10), child: const Text("立即增加", style: TextStyle(color: Color(0xFFFF9000), fontSize: 10)), @@ -666,12 +678,12 @@ class _HomeChatPageState extends State with AutomaticKeepAliveClie children: [ ConstrainedBox( constraints: BoxConstraints( - maxWidth: MediaQuery.of(context).size.width - 50, // 确保不超过屏幕宽度 + maxWidth: MediaQuery.of(context).size.width - l50, // 确保不超过屏幕宽度 ), child: CustomPopup( controller: customController, menuBuilder: () { - return popupView(chatList[index].id!, chatList[index].content!, index, customController); + return popupView(chatList[index].id!, chatList[index].content!, index, customController, w135, h40); }, barrierColor: Colors.transparent, //触发方式 @@ -680,7 +692,7 @@ class _HomeChatPageState extends State with AutomaticKeepAliveClie margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 12), padding: const EdgeInsets.all(11.0), decoration: const BoxDecoration( - color: Color(0x99FF9000), + color: Color(0xFFFF9000), borderRadius: BorderRadius.only( topRight: Radius.circular(16.0), bottomLeft: Radius.circular(16.0), bottomRight: Radius.circular(16.0)), ), @@ -688,7 +700,7 @@ class _HomeChatPageState extends State with AutomaticKeepAliveClie chatList[index].content!, style: const TextStyle( fontSize: 14, - color: Color(0xFFE8E8E8), + color: Colors.black, ), ), ), @@ -733,7 +745,7 @@ class _HomeChatPageState extends State with AutomaticKeepAliveClie children: [ ConstrainedBox( constraints: BoxConstraints( - maxWidth: MediaQuery.of(context).size.width - 50, // 确保不超过屏幕宽度 + maxWidth: MediaQuery.of(context).size.width - l50, // 确保不超过屏幕宽度 ), child: Container( margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 12), @@ -757,10 +769,10 @@ class _HomeChatPageState extends State with AutomaticKeepAliveClie ); } - popupView(int id, String content, index, customController) { + popupView(int id, String content, index, customController, w135, h40) { return Container( - width: 135, - height: 40, + width: w135, + height: h40, decoration: BoxDecoration( color: Color(0xFF222222), borderRadius: BorderRadius.all(Radius.circular(2)), diff --git a/lib/tools/home_page.dart b/lib/tools/home_page.dart index 5a13732..eb708fb 100644 --- a/lib/tools/home_page.dart +++ b/lib/tools/home_page.dart @@ -53,79 +53,6 @@ class _HomePageState extends State with SingleTickerProviderStateMixin MePage(), ], ), - // Positioned( - // bottom: 0, - // child: Container( - // width: MediaQuery.of(context).size.width, - // height: 60, - // color: Color(currentIndex != 0 ? 0xFF121213 : 0x121213), - // child: Row( - // mainAxisAlignment: MainAxisAlignment.spaceAround, - // children: [ - // GestureDetector( - // onTap: () { - // currentIndex = 0; - // _tabController.animateTo(0); - // setState(() {}); - // }, - // child: Text( - // '首页', - // style: TextStyle(color: Color(currentIndex == 0 ? 0xFFFFFFFF : 0xFF7E7E7E)), - // ), - // ), - // GestureDetector( - // onTap: () { - // if (NetworkConfig.userId == "") { - // Navigator.of(context).pushNamed('/LoginPage'); - // return; - // } - // - // currentIndex = 1; - // _tabController.animateTo(1); - // setState(() {}); - // }, - // child: Text( - // '发现', - // style: TextStyle(color: Color(currentIndex == 1 ? 0xFFFFFFFF : 0xFF7E7E7E)), - // ), - // ), - // Image( - // width: 32, - // image: AssetImage('assets/images/ic_create.png'), - // ), - // GestureDetector( - // onTap: () { - // if (NetworkConfig.userId == "") { - // Navigator.of(context).pushNamed('/LoginPage'); - // return; - // } - // currentIndex = 2; - // _tabController.animateTo(2); - // setState(() {}); - // }, - // child: Text( - // '消息', - // style: TextStyle(color: Color(currentIndex == 2 ? 0xFFFFFFFF : 0xFF7E7E7E)), - // ), - // ), - // GestureDetector( - // onTap: () { - // if (NetworkConfig.userId == "") { - // Navigator.of(context).pushNamed('/LoginPage'); - // return; - // } - // currentIndex = 3; - // _tabController.animateTo(3); - // setState(() {}); - // }, - // child: Text( - // '我的', - // style: TextStyle(color: Color(currentIndex == 3 ? 0xFFFFFFFF : 0xFF7E7E7E)), - // ), - // ), - // ], - // ), - // )) ], ), bottomNavigationBar: Theme( diff --git a/lib/tools/me/about_page.dart b/lib/tools/me/about_page.dart new file mode 100644 index 0000000..4740fbd --- /dev/null +++ b/lib/tools/me/about_page.dart @@ -0,0 +1,72 @@ +import 'package:flutter/material.dart'; +import 'package:package_info_plus/package_info_plus.dart'; + +class AboutPage extends StatefulWidget { + const AboutPage({super.key}); + + @override + State createState() => _AboutPageState(); +} + +class _AboutPageState extends State { + String version = ''; + + @override + void initState() { + // TODO: implement initState + super.initState(); + + getCode(); + } + + getCode() async { + PackageInfo packageInfo = await PackageInfo.fromPlatform(); + + String appName = packageInfo.appName; + String packageName = packageInfo.packageName; + version = packageInfo.version; + String buildNumber = packageInfo.buildNumber; + setState(() {}); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Color(0xFF121213), + appBar: AppBar( + backgroundColor: Color(0xFF121213), + scrolledUnderElevation: 0.0, + title: Text( + '关于', + style: TextStyle(fontSize: 16, color: Colors.white), + ), + centerTitle: true, + leading: IconButton( + iconSize: 18, + icon: Icon(Icons.arrow_back_ios_sharp), + color: Colors.white, + onPressed: () { + // 处理返回操作 + Navigator.pop(context); + }, + ), + ), + body: Column( + children: [ + Container( + alignment: Alignment.center, + margin: EdgeInsets.only(top: 68), + child: Image(width: 70, height: 70, image: AssetImage('assets/images/ic_launcher.png')), + ), + Container( + margin: EdgeInsets.only(top: 17), + child: Text( + version, + style: TextStyle(fontSize: 12, color: Color(0xFF858585)), + ), + ) + ], + ), + ); + } +} diff --git a/lib/tools/me/agreement_page.dart b/lib/tools/me/agreement_page.dart new file mode 100644 index 0000000..5b2bb94 --- /dev/null +++ b/lib/tools/me/agreement_page.dart @@ -0,0 +1,75 @@ +import 'package:flutter/material.dart'; +import 'package:webview_flutter/webview_flutter.dart'; + +///协议 +class AgreementPage extends StatefulWidget { + String title; + String url; + + AgreementPage({required this.title, required this.url}); + + @override + State createState() => _AgreementPageState(); +} + +class _AgreementPageState extends State { + late WebViewController controller; + + @override + void initState() { + // TODO: implement initState + super.initState(); + controller = WebViewController() + ..setJavaScriptMode(JavaScriptMode.unrestricted) + ..setBackgroundColor(const Color(0x00000000)) + ..setNavigationDelegate( + NavigationDelegate( + onProgress: (int progress) { + // Update loading bar. + }, + onPageStarted: (String url) {}, + onPageFinished: (String url) {}, + onHttpError: (HttpResponseError error) {}, + onWebResourceError: (WebResourceError error) {}, + onNavigationRequest: (NavigationRequest request) { + // if (request.url.startsWith('https://www.youtube.com/')) { + // return NavigationDecision.prevent; + // } + return NavigationDecision.navigate; + }, + ), + ) + ..loadRequest(Uri.parse(widget.url)); + } + + @override + void dispose() { + // TODO: implement dispose + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: Color(0xFF121213), + scrolledUnderElevation: 0.0, + title: Text( + widget.title, + style: TextStyle(fontSize: 16, color: Colors.white), + ), + centerTitle: true, + leading: IconButton( + iconSize: 18, + icon: Icon(Icons.arrow_back_ios_sharp), + color: Colors.white, + onPressed: () { + // 处理返回操作 + Navigator.pop(context); + }, + ), + ), + body: WebViewWidget(controller: controller), + ); + } +} diff --git a/lib/tools/me/me_page.dart b/lib/tools/me/me_page.dart index 2b7fe43..f91aaba 100644 --- a/lib/tools/me/me_page.dart +++ b/lib/tools/me/me_page.dart @@ -59,6 +59,13 @@ class _MePageState extends State { @override Widget build(BuildContext context) { + final size = MediaQuery.of(context).size; + final w21 = size.width / 17.142857142857; + final t38 = size.width / 9.4736842105263; + final w58 = size.width / 6.2068965517241; + final l80 = size.width / 4.5; + final h50 = size.width / 7.2; + return Scaffold( backgroundColor: Color(0xFF121213), body: SingleChildScrollView( @@ -87,8 +94,8 @@ class _MePageState extends State { Navigator.pushNamed(context, '/SettingPage'); }, child: Image( - width: 21, - height: 21, + width: w21, + height: w21, image: AssetImage('assets/images/ic_setting.png'), ), )) @@ -98,27 +105,27 @@ class _MePageState extends State { Container( width: double.infinity, - margin: EdgeInsets.only(left: 18, right: 18, top: 38), + margin: EdgeInsets.only(left: 18, right: 18, top: t38), child: Stack( children: [ ClipOval( child: CachedNetworkImage( - width: 58, - height: 58, + width: w58, + height: w58, imageUrl: userInfoBean.userIconUrl!, errorWidget: (context, url, error) => const Icon(Icons.error), ), ), Positioned( top: 5, - left: 80, + left: l80, child: Text( '${userInfoBean.nickName}', style: TextStyle(fontSize: 15, color: Color(0xFFE1E1E1)), )), Positioned( bottom: 6, - left: 80, + left: l80, child: Text( 'id ${userInfoBean.userId}', style: TextStyle(fontSize: 13, color: Color(0xFF4D4D4D)), @@ -141,12 +148,9 @@ class _MePageState extends State { // style: TextStyle(color: Color(0xFF4D4D4D), fontSize: 12), // ), // ), - Container( - // margin: EdgeInsets.only(left: 18), - child: Text( - '${userInfoBean.remainingChatCount}', - style: TextStyle(color: Colors.white, fontSize: 16), - ), + Text( + '${userInfoBean.remainingChatCount}', + style: TextStyle(color: Colors.white, fontSize: 16), ), Container( margin: EdgeInsets.only(left: 6), @@ -171,7 +175,7 @@ class _MePageState extends State { Navigator.pushNamed(context, '/AccountPage'); }, child: Container( - height: 38, + height: t38, decoration: BoxDecoration(color: Color(0xFF2A2A2A), borderRadius: BorderRadius.all(Radius.circular(13))), child: Row( children: [ @@ -202,7 +206,7 @@ class _MePageState extends State { Navigator.pushNamed(context, '/ShopPage'); }, child: Container( - height: 38, + height: t38, decoration: BoxDecoration(color: Color(0xFF2A2A2A), borderRadius: BorderRadius.all(Radius.circular(13))), child: Row( children: [ @@ -215,9 +219,9 @@ class _MePageState extends State { ), ), Container( - margin: EdgeInsets.only(left: 24), + margin: EdgeInsets.only(left: 35), child: Text( - '货币商城', + '商城', style: TextStyle(color: Color(0xFFE1E1E1), fontSize: 13), ), ), @@ -231,7 +235,7 @@ class _MePageState extends State { ), Container( - height: 50, + height: h50, margin: EdgeInsets.symmetric(horizontal: 16), child: GestureDetector( onTap: () { diff --git a/lib/tools/me/setting_page.dart b/lib/tools/me/setting_page.dart index e41c14e..fe27f65 100644 --- a/lib/tools/me/setting_page.dart +++ b/lib/tools/me/setting_page.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; +import 'agreement_page.dart'; + class SettingPage extends StatefulWidget { const SettingPage({super.key}); @@ -37,60 +39,92 @@ class _SettingApgeState extends State { child: Column( mainAxisSize: MainAxisSize.min, children: [ - Container( - height: 50, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - '关于', - style: TextStyle(fontSize: 13, color: Colors.white), - ), - Icon( - Icons.keyboard_arrow_right, - color: Color(0xFF6F6F6F), - ), - ], + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + Navigator.pushNamed(context, '/AboutPage'); + }, + child: SizedBox( + height: 50, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + '关于', + style: TextStyle(fontSize: 13, color: Colors.white), + ), + Icon( + Icons.keyboard_arrow_right, + color: Color(0xFF6F6F6F), + ), + ], + ), ), ), Container( height: 0.33, color: Color(0xFF3A3A3A), ), - Container( - height: 50, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - '用户协议', - style: TextStyle(fontSize: 13, color: Colors.white), - ), - Icon( - Icons.keyboard_arrow_right, - color: Color(0xFF6F6F6F), - ), - ], + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => AgreementPage( + title: "用户协议", + url: "https://shhuanmeng.com/yonghuxieyi.html", + )), + ); + }, + child: Container( + height: 50, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + '用户协议', + style: TextStyle(fontSize: 13, color: Colors.white), + ), + Icon( + Icons.keyboard_arrow_right, + color: Color(0xFF6F6F6F), + ), + ], + ), ), ), Container( height: 0.33, color: Color(0xFF3A3A3A), ), - Container( - height: 50, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - '隐私协议', - style: TextStyle(fontSize: 13, color: Colors.white), - ), - Icon( - Icons.keyboard_arrow_right, - color: Color(0xFF6F6F6F), - ), - ], + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => AgreementPage( + title: "隐私协议", + url: "https://shhuanmeng.com/yinsixieyi.html", + )), + ); + }, + child: Container( + height: 50, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + '隐私协议', + style: TextStyle(fontSize: 13, color: Colors.white), + ), + Icon( + Icons.keyboard_arrow_right, + color: Color(0xFF6F6F6F), + ), + ], + ), ), ), Container( diff --git a/lib/tools/message/message_model.dart b/lib/tools/message/message_model.dart index 5a8b864..f720f77 100644 --- a/lib/tools/message/message_model.dart +++ b/lib/tools/message/message_model.dart @@ -39,4 +39,27 @@ class MessageModel { print("errorEntity==${errorEntity.message}"); }); } + + ///清空聊天信息(重启聊天) + Future delChat(characterId) async { + RequestCenter.instance.request(NetworkConfig.delChat, { + "characterId": characterId, + }, (BaseEntity dataEntity) { + print("dataEntity==$dataEntity"); + + if (dataEntity.code == 0) { + streamController.sink.add({ + 'code': "delChat", //有数据 + 'data': dataEntity.data + }); + } else { + streamController.sink.add({ + 'code': "-1", //有数据 + 'data': dataEntity.message + }); + } + }, (ErrorEntity errorEntity) { + print("errorEntity==${errorEntity.message}"); + }); + } } diff --git a/lib/tools/message/message_page.dart b/lib/tools/message/message_page.dart index 07743d0..4cafc33 100644 --- a/lib/tools/message/message_page.dart +++ b/lib/tools/message/message_page.dart @@ -4,9 +4,12 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_slidable/flutter_slidable.dart'; +import 'package:intl/intl.dart'; import 'package:talk/beans/message_bean.dart'; import 'package:talk/tools/message/message_model.dart'; +import '../../common/func.dart'; +import '../../dialog/restart_chat_dialog.dart'; import '../chat/chat_page.dart'; ///消息列表 @@ -24,6 +27,8 @@ class _MessagePageState extends State { final MessageModel _viewmodel = MessageModel(); + int delIndex = 0; + @override void initState() { // TODO: implement initState @@ -36,8 +41,12 @@ class _MessagePageState extends State { case "getChatHistoryList": messageList = newData['data']; break; + case "delChat": //重启对话 + if (newData['data']) { + messageList.removeAt(delIndex); + } + break; default: - EasyLoading.dismiss(); EasyLoading.showToast(newData['data']); break; } @@ -84,7 +93,7 @@ class _MessagePageState extends State { child: ListView.builder( itemCount: messageList.length, itemBuilder: (BuildContext context, int index) { - return _item(messageList[index], context); + return _item(messageList[index], context, index); }), ), )) @@ -95,14 +104,22 @@ class _MessagePageState extends State { ); } - _item(MessageBean data, BuildContext context) { + _item(MessageBean data, BuildContext context, index) { + final size = MediaQuery.of(context).size; + final h50 = size.width / 7.2; + final b20 = size.width / 18; + final w40 = size.width / 9; + final l68 = size.width / 5.2941176470588; + final t25 = size.width / 14.4; + final w160 = size.width / 2.25; + return Slidable( //左滑划出的菜单 endActionPane: ActionPane( key: Key(UniqueKey().toString()), // 菜单宽度 extentRatio: 0.3, - dragDismissible: false, + // dragDismissible: false, // 滑动动效 // DrawerMotion() StretchMotion() // motion: ScrollMotion(), @@ -110,7 +127,15 @@ class _MessagePageState extends State { motion: BehindMotion(), children: [ SlidableAction( - onPressed: doNothing(context, data.id), + onPressed: (BuildContext context) { + FunctionUtil.popDialog(context, RestartChatDialog( + onTap: () { + delIndex = index; + EasyLoading.show(status: 'loading...'); + _viewmodel.delChat(data.id); + }, + )); + }, backgroundColor: Color(0xFFFF9000), foregroundColor: Colors.black, label: '删除', @@ -130,8 +155,8 @@ class _MessagePageState extends State { ); }, child: Container( - height: 50, - margin: EdgeInsets.only(bottom: 10), + height: h50, + margin: EdgeInsets.only(bottom: b20), child: Stack( alignment: Alignment.center, children: [ @@ -140,25 +165,25 @@ class _MessagePageState extends State { left: 16, child: ClipOval( child: CachedNetworkImage( - width: 40, - height: 40, + width: w40, + height: w40, imageUrl: data.iconImage!, errorWidget: (context, url, error) => const Icon(Icons.error), ), ), ), Positioned( - left: 68, + left: l68, top: 6, child: Text( data.name!, style: TextStyle(fontSize: 13, color: Color(0xFFE1E1E1)), )), Positioned( - left: 68, - top: 25, + left: l68, + top: t25, child: Container( - width: 160, + width: w160, child: Text( '${data.lastMessage}', maxLines: 1, @@ -171,7 +196,7 @@ class _MessagePageState extends State { top: 6, child: Container( child: Text( - '${data.lastContactTime}', + '${getHM(data.lastContactTime)}', style: TextStyle(fontSize: 10, color: Color(0xFF8D8D8D)), ), )), @@ -181,8 +206,38 @@ class _MessagePageState extends State { ), ); } -} -doNothing(BuildContext context, id) { - // EasyLoading.showToast("删除"); + doNothing(BuildContext context, id, index) { + print("object"); + delIndex = index; + EasyLoading.show(status: 'loading...'); + _viewmodel.delChat(id); + EasyLoading.showToast("status"); + } + + ///提取时间 + getHM(dateTimeString) { + DateTime inputDateTime = DateTime.parse(dateTimeString); + DateTime now = DateTime.now(); + + bool isToday = inputDateTime.year == now.year && inputDateTime.month == now.month && inputDateTime.day == now.day; + bool isThisYear = inputDateTime.year == now.year; + + String formattedDateTime; + if (isToday) { + // 当天内,只显示【时:分】 + final DateFormat timeFormatter = DateFormat('HH:mm'); + formattedDateTime = timeFormatter.format(inputDateTime); + } else if (isThisYear) { + // 超出当天但仍在今年内,显示【月-日 时:分】 + final DateFormat dateFormatter = DateFormat('MM-dd HH:mm'); + formattedDateTime = dateFormatter.format(inputDateTime); + } else { + // 超出今年,显示【年-月-日 时:分】 + final DateFormat fullDateFormatter = DateFormat('yyyy-MM-dd HH:mm'); + formattedDateTime = fullDateFormatter.format(inputDateTime); + } + + return formattedDateTime; + } } diff --git a/lib/tools/shop/shop_model.dart b/lib/tools/shop/shop_model.dart index bd1903e..b7041af 100644 --- a/lib/tools/shop/shop_model.dart +++ b/lib/tools/shop/shop_model.dart @@ -60,7 +60,7 @@ class ShopModel { }); } - ///交易记录 + ///货币商城 Future getMallItem() async { RequestCenter.instance.requestGet(NetworkConfig.getMallItem, {}, (BaseEntity dataEntity) { if (dataEntity.code == 0) { diff --git a/pubspec.yaml b/pubspec.yaml index 001a31f..1cb6182 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -28,6 +28,7 @@ dependencies: dio: ^5.4.3+1 + intl: ^0.19.0 cupertino_icons: ^1.0.6 flutter_easyloading: ^3.0.5 flutter_spinkit: ^5.2.1 @@ -47,6 +48,8 @@ dependencies: card_swiper: ^3.0.1 flutter_slidable: ^3.1.0 flutter_keyboard_visibility: ^6.0.0 + webview_flutter: ^4.8.0 + package_info_plus: ^8.0.0 dev_dependencies: flutter_test: