diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 03ccfff..805fbca 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,4 +1,5 @@ - + diff --git a/android/app/src/main/java/com/huanmeng/talk/MainActivity.java b/android/app/src/main/java/com/huanmeng/talk/MainActivity.java index 1cff07d..7f9531b 100644 --- a/android/app/src/main/java/com/huanmeng/talk/MainActivity.java +++ b/android/app/src/main/java/com/huanmeng/talk/MainActivity.java @@ -111,6 +111,10 @@ public class MainActivity extends FlutterActivity { String orderInfoZfb = call.argument("orderInfoZfb"); Alipay(orderInfoZfb); + break; + + case "playAd"://看广告 + break; case "test1": Log.d("TAG1", "onMethodCall: 66666666666"); diff --git a/assets/images/ic_ad.png b/assets/images/ic_ad.png new file mode 100644 index 0000000..5255ee4 Binary files /dev/null and b/assets/images/ic_ad.png differ diff --git a/assets/images/ic_open_f.png b/assets/images/ic_open_f.png new file mode 100644 index 0000000..8ecd804 Binary files /dev/null and b/assets/images/ic_open_f.png differ diff --git a/assets/images/ic_open_n.png b/assets/images/ic_open_n.png new file mode 100644 index 0000000..f1b4e33 Binary files /dev/null and b/assets/images/ic_open_n.png differ diff --git a/assets/images/img_add.png b/assets/images/img_add.png new file mode 100644 index 0000000..19d7a19 Binary files /dev/null and b/assets/images/img_add.png differ diff --git a/lib/beans/user_info_bean.dart b/lib/beans/user_info_bean.dart index c5aa76d..f6eca61 100644 --- a/lib/beans/user_info_bean.dart +++ b/lib/beans/user_info_bean.dart @@ -5,7 +5,7 @@ import 'me_character_info_bean.dart'; part 'user_info_bean.g.dart'; -///标签 +///用户信息 @JsonSerializable(explicitToJson: true) class UserInfoBean { int? currency; diff --git a/lib/dialog/cancel_dialog.dart b/lib/dialog/cancel_dialog.dart index feb5ba7..6447e45 100644 --- a/lib/dialog/cancel_dialog.dart +++ b/lib/dialog/cancel_dialog.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; class CancelDialog extends StatefulWidget { - Function onTap; + final Function onTap; CancelDialog({required this.onTap}); @@ -10,12 +10,6 @@ class CancelDialog extends StatefulWidget { } class _CancelDialogState extends State { - @override - void initState() { - // TODO: implement initState - super.initState(); - } - @override Widget build(BuildContext context) { return Material( diff --git a/lib/dialog/create_character_dialog.dart b/lib/dialog/create_character_dialog.dart new file mode 100644 index 0000000..ebecea6 --- /dev/null +++ b/lib/dialog/create_character_dialog.dart @@ -0,0 +1,87 @@ +import 'package:flutter/material.dart'; + +class CreateCharacterDialog extends StatefulWidget { + Function onTap; + + CreateCharacterDialog({super.key, required this.onTap}); + + @override + State createState() => _CreateCharacterDialogState(); +} + +class _CreateCharacterDialogState extends State { + @override + Widget build(BuildContext context) { + return Material( + type: MaterialType.transparency, //透明类型 + color: Color(0x1A000000), + child: Container( + decoration: const BoxDecoration( + color: Color(0xFF19191A), + borderRadius: BorderRadius.only( + topLeft: Radius.circular(7), + topRight: Radius.circular(7), + )), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + width: 25, + height: 3, + margin: EdgeInsets.only(top: 14), + decoration: BoxDecoration(color: Color(0xFF272734)), + ), + GestureDetector( + onTap: () { + Navigator.of(context).pop(); + widget.onTap(); + }, + child: Container( + width: double.infinity, + height: 76.67, + margin: EdgeInsets.only(left: 16, right: 16, top: 23), + decoration: BoxDecoration(color: Color(0xFF252526), borderRadius: BorderRadius.all(Radius.circular(7))), + child: Stack( + alignment: Alignment.center, + children: [ + Positioned( + left: 13, + child: Container( + width: 47, + height: 47, + color: Colors.lightBlueAccent, + )), + Positioned( + left: 78, + top: 20, + child: Text( + "创建个人模型", + style: TextStyle(color: Color(0xFFE1E1E1), fontSize: 16), + )), + Positioned( + left: 78, + top: 44, + child: Text( + "本周剩余(10/10)", + style: TextStyle(color: Color(0xFF4D4D4D), fontSize: 12), + )) + ], + ), + ), + ), + Container( + width: double.infinity, + height: 119.63, + alignment: Alignment.center, + margin: EdgeInsets.only(left: 16, right: 16, top: 23, bottom: 19), + decoration: BoxDecoration(color: Color(0xFF252526), borderRadius: BorderRadius.all(Radius.circular(7))), + child: Text( + '拉新人banner', + style: TextStyle(color: Color(0xFFE1E1E1), fontSize: 16), + ), + ), + ], + ), + )); + } +} diff --git a/lib/dialog/create_type_dialog.dart b/lib/dialog/create_type_dialog.dart new file mode 100644 index 0000000..04add20 --- /dev/null +++ b/lib/dialog/create_type_dialog.dart @@ -0,0 +1,102 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class CreateTypeDialog extends StatefulWidget { + Function onTap; + + CreateTypeDialog({super.key, required this.onTap}); + + @override + State createState() => _CreateTypeDialogState(); +} + +class _CreateTypeDialogState extends State { + List typeList = [1, 2, 3, 4, 5, 6]; + + String type = ""; + + @override + void initState() { + // TODO: implement initState + super.initState(); + type = "类型${typeList[0]}"; + } + + @override + Widget build(BuildContext context) { + return Material( + type: MaterialType.transparency, //透明类型 + color: Color(0x1A000000), + child: Container( + decoration: const BoxDecoration( + color: Color(0xFF19191A), + borderRadius: BorderRadius.only( + topLeft: Radius.circular(7), + topRight: Radius.circular(7), + )), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + margin: EdgeInsets.symmetric(horizontal: 16, vertical: 16), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + GestureDetector( + onTap: () { + Navigator.pop(context); + }, + child: Text( + "取消", + style: TextStyle(color: Colors.white, fontSize: 10), + ), + ), + Text( + "选择分类", + style: TextStyle(color: Colors.white, fontSize: 10), + ), + GestureDetector( + onTap: () { + Navigator.pop(context); + widget.onTap(type); + }, + child: Text( + "确定", + style: TextStyle(color: Colors.white, fontSize: 10), + ), + ), + ], + ), + ), + Container( + width: 90, + height: 150, + alignment: Alignment.center, + child: CupertinoPicker( + itemExtent: 35.0, + onSelectedItemChanged: (index) { + setState(() { + type = "类型${typeList[index]}"; + print(typeList[index]); + }); + }, + children: _typeItem(), + ), + ), + ], + ), + )); + } + + _typeItem() { + return typeList.map((res) { + return Container( + alignment: Alignment.center, + child: Text( + "类型$res", + style: TextStyle(fontSize: 14, color: Colors.white), + ), + ); + }).toList(); + } +} diff --git a/lib/main.dart b/lib/main.dart index 522f4cb..20c80a7 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -4,7 +4,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; -import 'package:talk/tools/home/test_page.dart'; +import 'package:talk/tools/creat/create_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'; @@ -95,7 +95,6 @@ class _ChatAppState extends State { '/ProblemPage': (BuildContext context) => const ProblemPage(), '/ShopPage': (BuildContext context) => const ShopPage(), '/SettingPage': (BuildContext context) => const SettingPage(), - '/TestPage': (BuildContext context) => const TestPage(), '/AboutPage': (BuildContext context) => const AboutPage(), '/ReportPage': (BuildContext context) => const ReportPage(), '/TeenageModePage': (BuildContext context) => const TeenageModePage(), @@ -103,6 +102,7 @@ class _ChatAppState extends State { '/CloseTeenageModePage': (BuildContext context) => const CloseTeenageModePage(), '/TeenageRetrievePasswordPage': (BuildContext context) => const TeenageRetrievePasswordPage(), '/AlgorithmFilingPage': (BuildContext context) => const AlgorithmFilingPage(), + '/CreatePage': (BuildContext context) => const CreatePage(), }, debugShowMaterialGrid: false, //显示网格 diff --git a/lib/tools/creat/create_page.dart b/lib/tools/creat/create_page.dart new file mode 100644 index 0000000..0d138d5 --- /dev/null +++ b/lib/tools/creat/create_page.dart @@ -0,0 +1,497 @@ +import 'package:flutter/material.dart'; + +import '../../common/func.dart'; +import '../../dialog/create_type_dialog.dart'; + +class CreatePage extends StatefulWidget { + const CreatePage({super.key}); + + @override + State createState() => _CreatePageState(); +} + +class _CreatePageState extends State { + final TextEditingController _textBgController = TextEditingController(); + + int gender = 1; //性别类型 1:男 0:女 3:其他 + + String nameText = ""; //人物名字 + void _textNameChanged(String str) { + nameText = str; + } + + String bgText = ""; //人物背景 + void _textBgChanged(String str) { + bgText = str; + } + + String imageText = ""; //人物形象 + void _textImageChanged(String str) { + imageText = str; + } + + int currentStyleIndex = 0; //风格 + + List styleList = [1, 2, 3, 4, 5, 6, 7, 8, 9]; + + String type = ""; //分类 + + @override + void initState() { + // TODO: implement initState + super.initState(); + } + + @override + Widget build(BuildContext context) { + final size = MediaQuery.of(context).size; + 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: SingleChildScrollView( + child: Container( + margin: EdgeInsets.symmetric(horizontal: 16), + child: Column( + children: [ + Container( + alignment: Alignment.center, + child: Text( + "角色信息", + style: TextStyle(color: Color(0xFFFF9000), fontSize: 15), + ), + ), + Container( + margin: EdgeInsets.only(top: 15), + alignment: Alignment.centerLeft, + child: Text( + "角色昵称", + style: TextStyle(color: Colors.white, fontSize: 14), + ), + ), + TextField( + cursorColor: const Color(0xFFFF9000), + style: const TextStyle(color: Colors.white), + onChanged: _textNameChanged, + decoration: const InputDecoration( + hintText: '给角色取个名字', + hintStyle: TextStyle(color: Color(0xFF4C4C4C), fontSize: 13), + border: UnderlineInputBorder( + borderSide: BorderSide(color: Color(0xFF3A3A3A)), // 设置下划线颜色 + ), + focusedBorder: UnderlineInputBorder( + borderSide: BorderSide(color: Color(0xFFFF9000)), + ), + ), + maxLength: 8, + ), + Container( + margin: const EdgeInsets.only(top: 10), + alignment: Alignment.centerLeft, + child: const Text( + "性别", + style: TextStyle(color: Colors.white, fontSize: 14), + ), + ), + Container( + margin: const EdgeInsets.only(top: 17), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + GestureDetector( + onTap: () { + gender = 1; + setState(() {}); + }, + child: Container( + width: 93, + height: 32, + alignment: Alignment.center, + decoration: BoxDecoration( + border: Border.all(color: Color(gender == 1 ? 0xFFFF9000 : 0xFF686868), width: 1), + borderRadius: const BorderRadius.all(Radius.circular(7))), + child: Text( + "男", + style: TextStyle(fontSize: 13, color: Color(gender == 1 ? 0xFFFF9000 : 0xFF686868)), + ), + ), + ), + GestureDetector( + onTap: () { + gender = 2; + setState(() {}); + }, + child: Container( + width: 93, + height: 32, + alignment: Alignment.center, + decoration: BoxDecoration( + border: Border.all(color: Color(gender == 2 ? 0xFFFF9000 : 0xFF686868), width: 1), + borderRadius: BorderRadius.all(Radius.circular(7))), + child: Text( + "女", + style: TextStyle(fontSize: 13, color: Color(gender == 2 ? 0xFFFF9000 : 0xFF686868)), + ), + ), + ), + GestureDetector( + onTap: () { + gender = 3; + setState(() {}); + }, + child: Container( + width: 93, + height: 32, + alignment: Alignment.center, + decoration: BoxDecoration( + border: Border.all(color: Color(gender == 3 ? 0xFFFF9000 : 0xFF686868), width: 1), + borderRadius: BorderRadius.all(Radius.circular(7))), + child: Text( + "其他", + style: TextStyle(fontSize: 13, color: Color(gender == 3 ? 0xFFFF9000 : 0xFF686868)), + ), + ), + ), + ], + ), + ), + Container( + margin: EdgeInsets.only(top: 20), + alignment: Alignment.centerLeft, + child: Text( + "身份背景", + style: TextStyle(color: Colors.white, fontSize: 14), + ), + ), + Container( + alignment: Alignment.center, + margin: EdgeInsets.only(top: 20), + padding: const EdgeInsets.only(left: 9, top: 5, right: 9), + decoration: BoxDecoration( + color: Color(0xFF262626), + borderRadius: BorderRadius.all(Radius.circular(6.6)), + ), + child: TextField( + controller: _textBgController, + keyboardType: TextInputType.name, + cursorColor: Color(0xFFFF9000), + // focusNode: _commentFocus, + decoration: + InputDecoration.collapsed(hintText: '描述越详细,越接近你心目中的形象', hintStyle: const TextStyle(fontSize: 12.0, color: Color(0xFF535353))), + textAlign: TextAlign.left, + maxLines: 6, + style: const TextStyle(fontSize: 14.0, color: Colors.white), + onChanged: _textBgChanged, + autofocus: false, + maxLength: 500, + ), + ), + Container( + margin: EdgeInsets.only(top: 15), + alignment: Alignment.centerLeft, + child: Text( + "开场白", + style: TextStyle(color: Colors.white, fontSize: 14), + ), + ), + TextField( + cursorColor: const Color(0xFFFF9000), + style: const TextStyle(color: Colors.white), + onChanged: _textNameChanged, + decoration: const InputDecoration( + hintText: '它的开场第一句话', + hintStyle: TextStyle(color: Color(0xFF4C4C4C), fontSize: 13), + border: UnderlineInputBorder( + borderSide: BorderSide(color: Color(0xFF3A3A3A)), // 设置下划线颜色 + ), + focusedBorder: UnderlineInputBorder( + borderSide: BorderSide(color: Color(0xFFFF9000)), + ), + ), + maxLength: 50, + ), + GestureDetector( + onTap: () { + FunctionUtil.bottomSheetDialog(context, CreateTypeDialog( + onTap: (type) { + this.type = type; + setState(() {}); + }, + )); + }, + child: Container( + width: double.infinity, + height: 45, + margin: EdgeInsets.only(top: 10), + decoration: BoxDecoration( + color: Color(0xFF202020), + borderRadius: BorderRadius.all(Radius.circular(7)), + ), + child: Stack( + alignment: Alignment.center, + children: [ + Positioned( + left: 10, + child: Text( + "分类", + style: TextStyle(color: Colors.white), + ), + ), + Positioned( + right: 10, + child: Text( + type == "" ? "添加" : type, + style: TextStyle(color: type == "" ? Colors.white : Color(0xFFFF9000)), + ), + ), + ], + ), + ), + ), + Container( + width: double.infinity, + height: 45, + margin: EdgeInsets.only(top: 17), + decoration: BoxDecoration( + color: Color(0xFF202020), + borderRadius: BorderRadius.all(Radius.circular(7)), + ), + child: Container(), + ), + Container( + alignment: Alignment.center, + margin: EdgeInsets.only(top: 41), + child: Text( + "角色形象", + style: TextStyle(color: Color(0xFFFF9000), fontSize: 15), + ), + ), + Container( + margin: EdgeInsets.only(top: 15), + alignment: Alignment.centerLeft, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + "形象描述", + style: TextStyle(color: Colors.white, fontSize: 14), + ), + Text( + "随机生成", + style: TextStyle(color: Color(0xFFFF9000), fontSize: 10), + ), + ], + ), + ), + Container( + alignment: Alignment.center, + margin: EdgeInsets.only(top: 20), + padding: const EdgeInsets.only(left: 9, top: 5, right: 9), + decoration: BoxDecoration( + color: Color(0xFF262626), + borderRadius: BorderRadius.all(Radius.circular(6.6)), + ), + child: TextField( + // controller: _textBgController, + keyboardType: TextInputType.name, + cursorColor: Color(0xFFFF9000), + // focusNode: _commentFocus, + decoration: InputDecoration.collapsed(hintText: '长相,场景,衣服', hintStyle: const TextStyle(fontSize: 12.0, color: Color(0xFF535353))), + textAlign: TextAlign.left, + maxLines: 3, + style: const TextStyle(fontSize: 14.0, color: Colors.white), + onChanged: _textImageChanged, + autofocus: false, + maxLength: 100, + ), + ), + Container( + margin: EdgeInsets.only(top: 15), + alignment: Alignment.centerLeft, + child: Text( + "风格选择", + style: TextStyle(color: Colors.white, fontSize: 14), + ), + ), + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Container( + // width: 500, + alignment: Alignment.centerLeft, + margin: EdgeInsets.only(top: 21), + height: 154, + child: GridView.count( + shrinkWrap: true, + //水平子Widget之间间距 + crossAxisSpacing: 12.0, + //垂直子Widget之间间距 + mainAxisSpacing: 9.0, + //GridView内边距 + padding: EdgeInsets.zero, + //一行的Widget数量 + crossAxisCount: 2, + //子Widget宽高比例 + childAspectRatio: 1.0, + //子Widget列表 + children: _item(styleList), + physics: const NeverScrollableScrollPhysics(), + //类似 cellForRow 函数 + scrollDirection: Axis.horizontal)), + ), + Container( + margin: EdgeInsets.only(top: 15), + alignment: Alignment.centerLeft, + child: Text( + "选择参考图像", + style: TextStyle(color: Colors.white, fontSize: 14), + ), + ), + Container( + width: double.infinity, + height: 118, + margin: EdgeInsets.only(top: 17), + decoration: BoxDecoration( + color: Color(0xFF202020), + borderRadius: BorderRadius.all(Radius.circular(7)), + ), + child: Stack( + alignment: Alignment.center, + children: [ + Positioned( + top: 38, + child: Image(width: 18, height: 18, image: AssetImage('assets/images/img_add.png')), + ), + Positioned( + top: 77, + child: Text( + "将基于上传的参考图片生成基础模型", + style: TextStyle(color: Color(0xFF6F6F6F), fontSize: 10), + )) + ], + ), + ), + Container( + margin: EdgeInsets.only(top: 35), + width: size.width, + height: 30, + child: Stack( + alignment: Alignment.center, + children: [ + Positioned( + left: 0, + child: Text( + "是否公开", + style: TextStyle(color: Colors.white, fontSize: 14), + )), + Positioned( + left: 70, + child: Text( + "审核中....", + style: TextStyle(color: Color(0xFF696969), fontSize: 12), + )), + Positioned( + right: 0, + child: Image(width: 52, height: 21, image: AssetImage('assets/images/ic_open_f.png')), + ) + ], + ), + ), + Container( + margin: EdgeInsets.symmetric(vertical: 48), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + width: 116, + height: 37, + alignment: Alignment.center, + decoration: + BoxDecoration(border: Border.all(color: Color(0xFFFF9000), width: 1), borderRadius: BorderRadius.all(Radius.circular(7))), + child: Text( + "智能一键生成", + style: TextStyle(fontSize: 14, color: Color(0xFFFF9000)), + ), + ), + Container( + width: 191, + height: 37, + alignment: Alignment.center, + decoration: BoxDecoration( + color: Color(0xFFFF9000), + borderRadius: BorderRadius.all(Radius.circular(7)), + ), + child: Text( + "立即生成", + style: TextStyle(fontSize: 14, color: Colors.black), + ), + ), + ], + ), + ), + ], + ), + ), + ), + ); + } + + _item(List list) { + final size = MediaQuery.of(context).size; + final w113 = size.width / 3.185840707964602; + final h159 = size.width / 2.264150943396226; + final w105 = size.width / 3.428571428571429; + + return list.map((res) { + int index = styleList.indexOf(res); + return GestureDetector( + onTap: () { + currentStyleIndex = index; + setState(() {}); + }, + child: Container( + alignment: Alignment.center, + child: Stack( + children: [ + // ClipRRect( + // borderRadius: BorderRadius.all(Radius.circular(15)), + // child: CachedNetworkImage( + // width: w113, + // height: h159, + // fit: BoxFit.cover, + // imageUrl: res.imageUrl!, + // errorWidget: (context, url, error) => const Icon(Icons.error), + // ), + // ), + Container( + width: 72, + height: 72, + decoration: BoxDecoration( + color: Colors.grey, + borderRadius: BorderRadius.all(Radius.circular(7)), + border: Border.all(color: Color(0xFFFF9000), width: currentStyleIndex == index ? 1 : 0), + ), + ) + ], + ), + ), + ); + }).toList(); + } +} diff --git a/lib/tools/home/test_page.dart b/lib/tools/home/test_page.dart deleted file mode 100644 index c38e9c7..0000000 --- a/lib/tools/home/test_page.dart +++ /dev/null @@ -1,60 +0,0 @@ -import 'package:flutter/material.dart'; - -import '../../custom/custom_popup.dart'; - -class TestPage extends StatefulWidget { - const TestPage({super.key}); - - @override - State createState() => _TestPageState(); -} - -class _TestPageState extends State { - @override - Widget build(BuildContext context) { - return Scaffold( - body: Stack( - children: [ - Positioned( - top: 400, - left: 50, - child: CustomPopup( - menuBuilder: () { - return Container( - width: 50, - height: 150, - color: Colors.lightBlue, - ); - }, - pressType: PressType.singleClick, - child: Container( - width: 50, - height: 50, - color: Colors.black, - ), - ), - ), - Positioned( - top: 400, - left: 150, - child: CustomPopup( - menuBuilder: () { - return Container( - width: 50, - height: 150, - color: Colors.lightBlue, - ); - }, - pressType: PressType.singleClick, - child: Container( - width: 50, - height: 50, - color: Colors.black, - ), - ), - ), - ], - ), - ); - } -} diff --git a/lib/tools/home_page.dart b/lib/tools/home_page.dart index 55a1434..fb89067 100644 --- a/lib/tools/home_page.dart +++ b/lib/tools/home_page.dart @@ -8,6 +8,8 @@ import 'package:talk/tools/home/my_home_page.dart'; import 'package:talk/tools/me/me_page.dart'; import 'package:talk/tools/message/message_page.dart'; +import '../common/func.dart'; +import '../dialog/create_character_dialog.dart'; import '../network/NetworkConfig.dart'; import 'find/find_page.dart'; @@ -154,20 +156,29 @@ class _HomePageState extends State with SingleTickerProviderStateMixin currentIndex = index; }); _tabController.animateTo(index); - // switch (index) { + // case 0: + // case 1: + // currentIndex = index; + // _tabController.animateTo(currentIndex); + // break; // case 2: + // FunctionUtil.bottomSheetDialog(context, CreateCharacterDialog( + // onTap: () { + // Navigator.pushNamed(context, "/CreatePage"); + // }, + // )); // break; // case 3: - // _tabController.animateTo(2); + // currentIndex = 2; + // _tabController.animateTo(currentIndex); // break; // case 4: - // _tabController.animateTo(3); - // break; - // default: - // _tabController.animateTo(index); + // currentIndex = 3; + // _tabController.animateTo(currentIndex); // break; // } + // setState(() {}); }, ), ), diff --git a/lib/tools/login/login_page.dart b/lib/tools/login/login_page.dart index 4edf936..af46ff7 100644 --- a/lib/tools/login/login_page.dart +++ b/lib/tools/login/login_page.dart @@ -41,7 +41,7 @@ class _LoginPageState extends State { int _timeLeft = 60; // 倒计时时间,单位为秒 bool _isCountingDown = false; - Timer? _timer; + Timer? _timer; ///获取验证码 void getCode() { @@ -87,7 +87,7 @@ class _LoginPageState extends State { break; case "login": EasyLoading.showToast(newData['data']); - if(_timer!=null){ + if (_timer != null) { _timer!.cancel(); } Navigator.pushReplacementNamed(context, "/HomePage"); @@ -265,7 +265,7 @@ class _LoginPageState extends State { children: [ Expanded( child: Container( - padding: const EdgeInsets.only(left: 17, bottom: 6), + padding: const EdgeInsets.only(left: 17), child: TextField( controller: _codeController, onChanged: _codeChanged, @@ -305,7 +305,7 @@ class _LoginPageState extends State { height: h43, width: w288, alignment: Alignment.center, - padding: const EdgeInsets.only(left: 17, bottom: 6), + padding: const EdgeInsets.only(left: 17), decoration: const BoxDecoration( color: Color(0x33FFFFFF), borderRadius: BorderRadius.all(Radius.circular(7)), diff --git a/lib/tools/me/me_page.dart b/lib/tools/me/me_page.dart index 7fa3f79..81f0790 100644 --- a/lib/tools/me/me_page.dart +++ b/lib/tools/me/me_page.dart @@ -2,11 +2,13 @@ import 'dart:async'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:talk/tools/me/me_model.dart'; import '../../beans/me_character_info_bean.dart'; import '../../beans/user_info_bean.dart'; import '../../common/EventBusUtil.dart'; +import '../../common/Global.dart'; import '../../network/NetworkConfig.dart'; import '../chat/chat_page.dart'; @@ -161,28 +163,30 @@ class _MePageState extends State { // style: TextStyle(color: Color(0xFF4D4D4D), fontSize: 12), // ), // ), - Text( - '${userInfoBean.hasTalked}', - style: TextStyle(color: Colors.white, fontSize: 16), - ), + Container( - margin: EdgeInsets.only(left: 6, right: 10), + margin: EdgeInsets.only(left: 6, right: 2), child: Text( '聊过', style: TextStyle(color: Color(0xFF4D4D4D), fontSize: 12), ), ), + Text( + '${userInfoBean.hasTalked}', + style: TextStyle(color: Color(0xFFFF9000), fontSize: 16), + ), + + Container( + margin: EdgeInsets.only(left: 25, right: 2), + child: Text( + '剩余聊天次数', + style: TextStyle(color: Color(0xFF4D4D4D), fontSize: 12), + ), + ), Text( '${userInfoBean.remainingChatCount}', - style: TextStyle(color: Colors.white, fontSize: 16), - ), - Container( - margin: EdgeInsets.only(left: 6), - child: Text( - '剩余聊天次数', - style: TextStyle(color: Color(0xFF4D4D4D), fontSize: 12), - ), + style: const TextStyle(color: Color(0xFFFF9000), fontSize: 17), ), ], ), @@ -298,6 +302,52 @@ class _MePageState extends State { ) : Container(), + ///看广告 + GestureDetector( + onTap: () { + Map map = { + "playAd": "playAd", + }; + invokeNativeMethod("playAd", map); + }, + child: Container( + width: size.width, + height: 62, + margin: EdgeInsets.only(left: 15, right: 15, top: 20), + decoration: const BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(10)), + gradient: LinearGradient( + begin: Alignment.centerLeft, + end: Alignment.centerRight, + colors: [ + Color(0xFFB0B6D3), + Color(0xFF96A5F5), + ], + ), + ), + child: const Stack( + alignment: Alignment.center, + children: [ + Positioned( + top: 15, + left: 12, + child: Text( + "看广告获得聊天次数", + style: TextStyle(fontSize: 12, color: Color(0xFF3248B6)), + )), + Positioned( + top: 34, + left: 12, + child: Text( + "看一次广告可获得10次聊天", + style: TextStyle(fontSize: 15, color: Color(0xFF3248B5)), + )), + Positioned(right: 15, child: Image(width: 36, height: 36, image: AssetImage('assets/images/ic_ad.png'))) + ], + ), + ), + ), + // Container( // height: h50, // margin: EdgeInsets.symmetric(horizontal: 16), @@ -409,4 +459,12 @@ class _MePageState extends State { ); }).toList(); } + + // 获取原生的值 + invokeNativeMethod(String method, Map map) async { + dynamic args; + try { + args = await Global.method.invokeMethod(method, map); + } on PlatformException catch (e) {} + } } diff --git a/lib/tools/start_page.dart b/lib/tools/start_page.dart index f188036..1d9b693 100644 --- a/lib/tools/start_page.dart +++ b/lib/tools/start_page.dart @@ -19,7 +19,7 @@ class StartPage extends StatefulWidget { class _StartPageState extends State { late StreamSubscription subscription; - LoginModel _viewmodel = new LoginModel(); + final LoginModel _viewmodel = LoginModel(); @override void initState() { diff --git a/pubspec.yaml b/pubspec.yaml index 2d6135c..efe4044 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -19,7 +19,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.1+2 environment: - sdk: '>=3.4.1 <4.0.0' + sdk: '>=2.17.1 <3.0.0' dependencies: @@ -42,7 +42,7 @@ dependencies: image_picker: ^0.8.4 permission_handler: ^10.4.5 image_gallery_saver: ^2.0.3 - web_socket_channel: ^3.0.0 + web_socket_channel: ^2.0.0 flutter_client_sse: ^2.0.1 expandable_text: ^2.3.0 card_swiper: ^3.0.1 @@ -59,7 +59,7 @@ dev_dependencies: sdk: flutter flutter_lints: ^3.0.0 - build_runner: ^2.4.11 + build_runner: ^2.2.0 json_serializable: ^6.8.0