Commit 0c8e0312 authored by 关振斌's avatar 关振斌

完成

parent f6538347
......@@ -10,14 +10,37 @@ import '../../entity/square_entity.dart';
class NewsAPI {
/// 翻页
/// refresh 是否刷新
static Future<List<SearchRecordEntity>> newsPageList(
static Future<NewsPageListResponseEntity> newsPageList(
Map<String, int> params) async {
var response = await HttpUtil().get(
'/searchRecord/getSearchRecord/${params['page']}/${params['size']}',
);
return searchRecordEntityFromList(response.data);
return NewsPageListResponseEntity.fromJson(response['data']);
// searchRecordEntityFromList(response.data);
}
static Future<String> sendMessage(Map<String, String> params) async {
var response = await HttpUtil().post('/openAi/aiAnswer', data: params);
return response['data'];
}
// /// 翻页
// /// refresh 是否刷新
// static Future<NewsPageListResponseEntity> newsPageList({
// NewsPageListRequestEntity? params,
// bool refresh = false,
// bool cacheDisk = false,
// }) async {
// var response = await HttpUtil().get(
// '/news',
// queryParameters: params?.toJson(),
// refresh: refresh,
// cacheDisk: cacheDisk,
// cacheKey: STORAGE_INDEX_NEWS_CACHE_KEY,
// );
// return NewsPageListResponseEntity.fromJson(response);
// }
/// 翻页
/// refresh 是否刷新
static Future<List<MessageEntity>?> bannerList() async {
......
import 'package:chart/common/entities/entities.dart';
import 'package:chart/common/utils/utils.dart';
import '../../entity/user_entity.dart';
/// 用户
class UserAPI {
/// 登录
......@@ -14,6 +16,38 @@ class UserAPI {
return UserLoginResponseEntity.fromJson(response);
}
// /pay/notifyApplePay
static Future<ApplePayEntity> notifyApplePay(
Map<String, dynamic> parameters) async {
var response = await HttpUtil().post(
'/pay/notifyApplePay',
data: parameters,
// data: params?.toJson(),
);
// print(response + '1response');
return ApplePayEntity.fromMap(response['data']);
// UserLoginResponseEntity.fromJson(response);
}
// Future<ApplePayEntity>? applePayCallBack(Map<String, dynamic> parameters) {
// return HttpUtil.instance
// ?.post(AppUrls.applePayCallBack, parameters: parameters)
// .then((result) {
// return ApplePayEntity.fromMap(result['data']);
// });
/// 获取当前进入用户的可用积分
static Future<IntegralEntity> getUserIntegral() async {
var response = await HttpUtil().get(
'/user/getUserIntegral',
// data: params?.toJson(),
);
// print(response + '1response');
return IntegralEntity.fromMap(response['data']);
// UserLoginResponseEntity.fromJson(response);
}
/// 注册
static Future<UserRegisterRequestEntity> register({
UserRegisterRequestEntity? params,
......
import 'dart:convert';
// "detailParamsEntityList": [
// {
// "id": 1,
// "label": "职位",
// "placeHolder": "例如:产品经理",
// "detailId": 1,
// "createTime": "2023-02-14T15:56:57.000+00:00",
// "updateTime": "2023-02-14T15:56:57.000+00:00",
// "isDelete": 0,
// "isShow": 1,
// "value": null,
// "sort": 1
// },
class DetialItem {
// int? id;
String? label;
String? placeHolder;
// String? thumbnail;
// int? likes;
// int? forward;
// DateTime? createTime;
DetialItem({this.label, this.placeHolder
// this.id,
// this.question,
// this.answer,
// this.thumbnail,
// this.likes,
// this.forward,
// this.createTime,
});
factory DetialItem.fromJson(Map<String, dynamic> json) => DetialItem(
label: json["label"],
placeHolder: json["placeHolder"],
// answer: json["answer"],
// thumbnail: json["thumbnail"],
// likes: json["likes"],
// forward: json["forward"],
// // DateTime.parse(),
// createTime: DateTime.parse(json["createTime"]),
);
Map<String, dynamic> toJson() => {
"placeHolder": placeHolder,
"label": label,
};
static fromMap(x) {}
}
class ClassifyDetialEntity {
ClassifyDetialEntity({
required this.id,
......@@ -7,6 +59,7 @@ class ClassifyDetialEntity {
required this.detailDesc,
required this.isShow,
required this.template,
required this.detailParamsEntityList,
});
final int id;
......@@ -14,6 +67,7 @@ class ClassifyDetialEntity {
final String detailDesc;
final int isShow;
final String template;
final List<dynamic> detailParamsEntityList;
factory ClassifyDetialEntity.fromJson(String str) =>
ClassifyDetialEntity.fromMap(json.decode(str));
......@@ -26,13 +80,23 @@ class ClassifyDetialEntity {
detailName: json["detailName"],
detailDesc: json["detailDesc"],
template: json['template'],
isShow: json['isShow']);
isShow: json['isShow'],
// List<PlanEntity>.from(data.map((x) => PlanEntity.fromMap(x)));
detailParamsEntityList: json['detailParamsEntityList'],
// List<DetialItem>.from(
// json['detailParamsEntityList'].map((x) => DetialItem.fromMap(x)))
// tags: List<String>.from(json["tags"]?.map((x) => x) ?? []),
// detailParamsEntityList: json["detailParamsEntityList"],
);
// detailParamsEntityList:json['detailParamsEntityList'];
Map<String, dynamic> toMap() => {
"id": id,
"detailName": detailName,
"detailDesc": detailDesc,
"isShow": isShow,
"template": template,
"detailParamsEntityList": detailParamsEntityList,
};
}
......
......@@ -28,80 +28,81 @@ class NewsPageListRequestEntity {
/// 新闻分页 response
class NewsPageListResponseEntity {
int? counts;
int? pagesize;
int? total;
int? size;
int? pages;
int? page;
List<NewsItem>? items;
int? current;
List<NewsItem>? records;
NewsPageListResponseEntity({
this.counts,
this.pagesize,
this.total,
this.size,
this.pages,
this.page,
this.items,
this.current,
this.records,
});
factory NewsPageListResponseEntity.fromJson(Map<String, dynamic> json) =>
NewsPageListResponseEntity(
counts: json["counts"],
pagesize: json["pagesize"],
total: json["total"],
size: json["pagesize"],
pages: json["pages"],
page: json["page"],
items: json["items"] == null
current: json["current"],
records: json["records"] == null
? []
: List<NewsItem>.from(
json["items"].map((x) => NewsItem.fromJson(x))),
json["records"].map((x) => NewsItem.fromJson(x))),
);
Map<String, dynamic> toJson() => {
"counts": counts ?? 0,
"pagesize": pagesize ?? 0,
"total": total ?? 0,
"pagesize": size ?? 0,
"pages": pages ?? 0,
"page": page ?? 0,
"items": items == null
"page": current ?? 0,
"records": records == null
? []
: List<dynamic>.from(items!.map((x) => x.toJson())),
: List<dynamic>.from(records!.map((x) => x.toJson())),
};
}
class NewsItem {
String? id;
String? title;
String? category;
int? id;
String? question;
String? answer;
String? thumbnail;
String? author;
DateTime? addtime;
String? url;
int? likes;
int? forward;
DateTime? createTime;
NewsItem({
this.id,
this.title,
this.category,
this.question,
this.answer,
this.thumbnail,
this.author,
this.addtime,
this.url,
this.likes,
this.forward,
this.createTime,
});
factory NewsItem.fromJson(Map<String, dynamic> json) => NewsItem(
id: json["id"],
title: json["title"],
category: json["category"],
question: json["question"],
answer: json["answer"],
thumbnail: json["thumbnail"],
author: json["author"],
addtime: DateTime.parse(json["addtime"]),
url: json["url"],
likes: json["likes"],
forward: json["forward"],
// DateTime.parse(),
createTime: DateTime.parse(json["createTime"]),
);
Map<String, dynamic> toJson() => {
"id": id,
"title": title,
"category": category,
"question": question,
"answer": answer,
"thumbnail": thumbnail,
"author": author,
"addtime": addtime?.toIso8601String(),
"url": url,
"likes": likes,
"forward": forward,
"createTime": createTime?.toIso8601String(),
};
}
......
......@@ -44,27 +44,27 @@ class UserLoginRequestEntity {
// 登录返回
class UserLoginResponseEntity {
String? accessToken;
String? displayName;
List<String>? channels;
int? id;
String? username;
String? token;
UserLoginResponseEntity({
this.accessToken,
this.displayName,
this.channels,
this.id,
this.username,
this.token,
});
factory UserLoginResponseEntity.fromJson(Map<String, dynamic> json) =>
UserLoginResponseEntity(
accessToken: json["access_token"],
displayName: json["display_name"],
channels: List<String>.from(json["channels"].map((x) => x)),
id: json["id"], username: json["username"], token: json['token']
// channels: List<String>.from(json["channels"].map((x) => x)),
);
Map<String, dynamic> toJson() => {
"access_token": accessToken,
"display_name": displayName,
"channels":
channels == null ? [] : List<dynamic>.from(channels!.map((x) => x)),
"access_token": id,
"display_name": username,
"token": token
// "channels":
// channels == null ? [] : List<dynamic>.from(channels!.map((x) => x)),
};
}
......@@ -6,4 +6,7 @@ class AppRoutes {
static const Application = '/application';
static const Category = '/category';
static const CHAT_PAGE = '/chat_page';
static const PRODUCT_PAGE = '/product';
static const PAY_LIST = '/pay';
}
import 'package:chart/pages/chat/view.dart';
import 'package:chart/pages/frame/notfound/index.dart';
import 'package:chart/pages/frame/pay_list/view.dart';
import 'package:flutter/material.dart';
import 'package:chart/common/middlewares/middlewares.dart';
import 'package:chart/pages/application/index.dart';
......@@ -5,10 +8,13 @@ import 'package:chart/pages/category/index.dart';
import 'package:chart/pages/frame/sign_in/index.dart';
import 'package:chart/pages/frame/sign_up/index.dart';
import 'package:chart/pages/frame/welcome/index.dart';
import 'package:chart/pages/chat/index.dart';
import 'package:chart/pages/frame/product/index.dart';
import 'package:chart/pages/frame/notfound/index.dart';
// import 'package:chart/pages/home/home_page.dart';
import 'package:get/get.dart';
import '../../pages/frame/pay_list/bindings.dart';
import 'routes.dart';
class AppPages {
......@@ -27,6 +33,9 @@ class AppPages {
// ],
// ),
// 需要登录
// 分类列表
GetPage(
name: AppRoutes.INITIAL,
page: () => WelcomePage(), //ApplicationPage(),
......@@ -34,6 +43,9 @@ class AppPages {
middlewares: [
// RouteAuthMiddleware(priority: 1),
],
// children: [
// ]
),
GetPage(
......@@ -47,6 +59,18 @@ class AppPages {
binding: SignUpBinding(),
),
GetPage(
name: AppRoutes.CHAT_PAGE,
page: () => ChatNewPage(),
binding: ChatNewBinding(),
),
GetPage(
name: AppRoutes.PAY_LIST,
page: () => PayListPage(),
binding: PayListBinding(),
),
// PAY_LIST
// 需要登录
GetPage(
name: AppRoutes.Application,
......@@ -55,9 +79,22 @@ class AppPages {
middlewares: [
// RouteAuthMiddleware(priority: 1),
],
// children: [
// ]
),
// product
// 分类列表
GetPage(
name: AppRoutes.PRODUCT_PAGE,
page: () => ProductPage(),
binding: ProductBinding(),
middlewares: [
// RouteAuthMiddleware(priority: 1),
],
),
GetPage(
name: AppRoutes.Category,
page: () => CategoryPage(),
......
......@@ -6,18 +6,22 @@ import 'package:chart/common/services/services.dart';
import 'package:chart/common/values/values.dart';
import 'package:get/get.dart';
import '../../entity/user_entity.dart';
class UserStore extends GetxController {
static UserStore get to => Get.find();
static UserStore get to => Get.put(UserStore());
// Get.find();
// static StorageService get to => Get.put(StorageService());
// 是否登录
final _isLogin = false.obs;
// 令牌 token
String token = '';
// 用户 profile
final _profile = UserLoginResponseEntity().obs;
final _profile = IntegralEntity(id: 0, token: '', username: '').obs;
bool get isLogin => _isLogin.value;
UserLoginResponseEntity get profile => _profile.value;
IntegralEntity get profile => _profile.value;
bool get hasToken => token.isNotEmpty;
@override
......@@ -26,8 +30,33 @@ class UserStore extends GetxController {
token = StorageService.to.getString(STORAGE_USER_TOKEN_KEY);
var profileOffline = StorageService.to.getString(STORAGE_USER_PROFILE_KEY);
if (profileOffline.isNotEmpty) {
_profile(UserLoginResponseEntity.fromJson(jsonDecode(profileOffline)));
var l = jsonDecode(profileOffline);
Map<String, dynamic> map = json.decode(l);
_profile(IntegralEntity.fromMap(map));
// _profile(IntegralEntity.fromMap();
// IntegralEntity.fromMap(result['data']);
// _profile(UserLoginResponseEntity.fromJson(jsonDecode(profileOffline)));
}
}
getUserInfo(IntegralEntity userInfo) async {
await setToken(userInfo.token);
await saveProfile(userInfo);
// token = StorageService.to.getString(STORAGE_USER_TOKEN_KEY);
// if (token.isNotEmpty) {
// return;
// }
// IntegralEntity userInfo = await UserAPI.getUserIntegral();
// print("$userInfo");
// var info = await UserAPI.getUserIntegral();
// if (token.isEmpty) {
// }
}
// 保存 token
......@@ -38,18 +67,24 @@ class UserStore extends GetxController {
// 获取 profile
Future<void> getProfile() async {
if (token.isEmpty) return;
var result = await UserAPI.profile();
_profile(result);
_isLogin.value = true;
StorageService.to.setString(STORAGE_USER_PROFILE_KEY, jsonEncode(result));
// print("objectobjectobjectobjectobjectobject");
// if (token.isEmpty) return;
// var result = await UserAPI.profile();
// _profile(result);
// _isLogin.value = true;
// StorageService.to.setString(STORAGE_USER_PROFILE_KEY, jsonEncode(result));
}
// 保存 profile
Future<void> saveProfile(UserLoginResponseEntity profile) async {
Future<void> saveProfile(IntegralEntity profile) async {
_isLogin.value = true;
StorageService.to.setString(STORAGE_USER_PROFILE_KEY, jsonEncode(profile));
}
// // 保存 profile
// Future<void> saveProfile(UserLoginResponseEntity profile) async {
// _isLogin.value = true;
// StorageService.to.setString(STORAGE_USER_PROFILE_KEY, jsonEncode(profile));
// }
// 注销
Future<void> onLogout() async {
......
......@@ -36,7 +36,7 @@ class HttpUtil {
connectTimeout: 10000,
// 响应流上前后两次接受到数据的间隔,单位为毫秒。
receiveTimeout: 5000,
receiveTimeout: 45000,
// Http请求头.
headers: {},
......@@ -66,6 +66,21 @@ class HttpUtil {
// 添加拦截器
dio.interceptors.add(InterceptorsWrapper(
onRequest: (options, handler) {
String token = UserStore.to.token;
if (token.isNotEmpty) {
options.headers['Authorization'] = token;
}
// await SharedPreferencesUtil.getInstance()
// ?.getString(AppStrings.token)
// .then((token) {
// if (token != null && token.isNotEmpty) {
// options.headers['Authorization'] = token;
// // ["Authorization"] = token;
// print("token=$token");
// }
// });
// Do something before request is sent
return handler.next(options); //continue
// 如果你想完成请求并返回一些自定义数据,你可以resolve一个Response对象 `handler.resolve(response)`。
......
// baidu yapi
// const SERVER_API_URL = 'https://yapi.baidu.com/mock/41008';
// const SERVER_API_URL = 'https://yapi.ducafecat.tech/mock/11';
const SERVER_API_URL = 'http://192.168.110.1:8083/api';
const SERVER_API_URL = 'http://101.34.153.228:8083/api';
// AppRoutes.PRODUCT_PAGE
// static const String baseUrl = 'http://101.34.153.228:8083'; // 基础接口地址
......
......@@ -2,7 +2,7 @@
const String STORAGE_USER_PROFILE_KEY = 'user_profile';
/// 用户 - 配置信息
const String STORAGE_USER_TOKEN_KEY = 'user_token';
const String STORAGE_USER_TOKEN_KEY = 'Authorization';
/// 设备是否第一次打开
const String STORAGE_DEVICE_FIRST_OPEN_KEY = 'device_first_open';
......
......@@ -9,15 +9,11 @@ AppBar transparentAppBar({
List<Widget>? actions,
}) {
return AppBar(
backgroundColor: Colors.transparent,
backgroundColor: Color.fromRGBO(41, 45, 62, 1.00),
elevation: 0,
title: title != null
? Center(
child: title,
)
: null,
leading: leading,
actions: actions,
title: title,
leading: leading ?? null,
// actions: actions,
);
}
......
......@@ -105,7 +105,7 @@ class IntegralEntity {
IntegralEntity(
{required this.id, required this.username, required this.token});
final int id;
final dynamic id;
final String username;
final String token;
......@@ -118,7 +118,7 @@ class IntegralEntity {
id: json["id"], username: json["username"], token: json['token']);
Map<String, dynamic> toMap() =>
{"isd": id, "username": username, "token": token};
{"id": id, "username": username, "token": token};
}
// To parse this JSON data, do
......
......@@ -11,7 +11,7 @@ class Global {
static Future init() async {
WidgetsFlutterBinding.ensureInitialized();
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
Get.updateLocale(Locale("zh", "CN"));
setSystemUi();
Loading();
......
......@@ -50,7 +50,7 @@ void main() async {
class ChartApp extends StatelessWidget {
ChartApp({Key? key}) : super(key: key) {
final router = FluroRouter();
Routers.configureRoutes(router);
// Routers.configureRoutes(router);
Application.router = router;
}
......
import 'package:chart/pages/frame/product/bindings.dart';
import 'package:flutter/material.dart';
import 'package:chart/common/langs/translation_service.dart';
import 'package:chart/common/routers/pages.dart';
......@@ -13,6 +14,7 @@ import 'package:pull_to_refresh/pull_to_refresh.dart';
void main() async {
await Global.init();
runApp(ChatApp());
}
......@@ -24,10 +26,11 @@ class ChatApp extends StatelessWidget {
return ScreenUtilInit(
designSize: Size(375, 812),
builder: (context, child) => GetMaterialApp(
title: 'News',
title: 'GPT大师傅',
theme: AppTheme.light,
debugShowCheckedModeBanner: false,
initialRoute: AppPages.INITIAL,
// initialBinding: AllControllerBinding(),
getPages: AppPages.routes,
builder: EasyLoading.init(),
translations: TranslationService(),
......@@ -57,31 +60,42 @@ class ChatApp extends StatelessWidget {
}
}
// () => RefreshConfiguration(
// headerBuilder: () => ClassicHeader(),
// footerBuilder: () => ClassicFooter(),
// hideFooterWhenNotFull: true,
// headerTriggerDistance: 80,
// maxOverScrollExtent: 100,
// footerTriggerDistance: 150,
// child: GetMaterialApp(
// title: 'News',
// theme: AppTheme.light,
// debugShowCheckedModeBanner: false,
// initialRoute: AppPages.INITIAL,
// getPages: AppPages.routes,
// builder: EasyLoading.init(),
// translations: TranslationService(),
// navigatorObservers: [AppPages.observer],
// localizationsDelegates: [
// GlobalMaterialLocalizations.delegate,
// GlobalWidgetsLocalizations.delegate,
// GlobalCupertinoLocalizations.delegate,
// ],
// supportedLocales: ConfigStore.to.languages,
// locale: ConfigStore.to.locale,
// fallbackLocale: Locale('en', 'US'),
// enableLog: true,
// logWriterCallback: Logger.write,
// ),
// ),
\ No newline at end of file
// () => RefreshConfiguration(
// headerBuilder: () => ClassicHeader(),
// footerBuilder: () => ClassicFooter(),
// hideFooterWhenNotFull: true,
// headerTriggerDistance: 80,
// maxOverScrollExtent: 100,
// footerTriggerDistance: 150,
// child: GetMaterialApp(
// title: 'News',
// theme: AppTheme.light,
// debugShowCheckedModeBanner: false,
// initialRoute: AppPages.INITIAL,
// getPages: AppPages.routes,
// builder: EasyLoading.init(),
// translations: TranslationService(),
// navigatorObservers: [AppPages.observer],
// localizationsDelegates: [
// GlobalMaterialLocalizations.delegate,
// GlobalWidgetsLocalizations.delegate,
// GlobalCupertinoLocalizations.delegate,
// ],
// supportedLocales: ConfigStore.to.languages,
// locale: ConfigStore.to.locale,
// fallbackLocale: Locale('en', 'US'),
// enableLog: true,
// logWriterCallback: Logger.write,
// ),
// ),
/// 所有的Binding层
class AllControllerBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut(() => ProductBinding());
///Get.lazyPut(() => OneController());
///Get.lazyPut(() => TwoController());
}
}
......@@ -2,6 +2,7 @@ import 'package:chart/pages/category/index.dart';
import 'package:chart/pages/main/index.dart';
import 'package:get/get.dart';
import '../chat/index.dart';
import 'controller.dart';
class ApplicationBinding implements Bindings {
......@@ -10,5 +11,6 @@ class ApplicationBinding implements Bindings {
Get.lazyPut<ApplicationController>(() => ApplicationController());
Get.lazyPut<MainController>(() => MainController());
Get.lazyPut<CategoryController>(() => CategoryController());
// Get.lazyPut<ChatPageController>(() => ChatPageController());
}
}
......@@ -9,6 +9,7 @@ import 'package:chart/common/values/values.dart';
import 'package:get/get.dart';
// import 'package:uni_links/uni_links.dart';
import '../../common/store/config.dart';
import 'index.dart';
class ApplicationController extends GetxController {
......@@ -84,6 +85,13 @@ class ApplicationController extends GetxController {
}
}
// 跳转 注册界面
handleChat() async {
Get.toNamed(AppRoutes.CHAT_PAGE);
// await ConfigStore.to.saveAlreadyOpen();
// Get.offAndToNamed(AppRoutes.CHAT_PAGE);
}
/// 生命周期
@override
......@@ -94,7 +102,7 @@ class ApplicationController extends GetxController {
// handleIncomingLinks();
// 准备一些静态数据
tabTitles = ['Welcome', 'Cagegory', 'Account'];
tabTitles = ['首页', '信息广场', '个人中心'];
bottomTabs = <BottomNavigationBarItem>[
new BottomNavigationBarItem(
icon: Icon(
......
......@@ -3,6 +3,7 @@ import 'package:chart/common/values/values.dart';
import 'package:chart/common/widgets/widgets.dart';
import 'package:chart/pages/category/index.dart';
import 'package:chart/pages/main/index.dart';
import 'package:chart/pages/user/index.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
// import '../dashboard/dashboard_page.dart';
......@@ -15,21 +16,22 @@ class ApplicationPage extends GetView<ApplicationController> {
title: Obx(() => Text(
controller.tabTitles[controller.state.page],
style: TextStyle(
color: AppColors.primaryText,
color: AppColors.primaryElementText,
fontFamily: 'Montserrat',
fontSize: 18.sp,
fontWeight: FontWeight.w600,
),
)),
actions: <Widget>[
IconButton(
icon: Icon(
Icons.search,
color: AppColors.primaryText,
),
onPressed: () {},
)
]);
// actions: <Widget>[
// IconButton(
// icon: Icon(
// Icons.search,
// color: AppColors.primaryElementText,
// ),
// onPressed: () {},
// )
// ],
);
}
// 内容页
......@@ -43,8 +45,9 @@ class ApplicationPage extends GetView<ApplicationController> {
// Text("da"),
// MainPage(),
CategoryPage(),
Text('BookmarksPage'),
Text('AccountPage'),
UserDetailPage()
// Text('BookmarksPage'),
// Text('AccountPage'),
],
controller: controller.pageController,
onPageChanged: controller.handlePageChanged,
......@@ -117,6 +120,13 @@ class ApplicationPage extends GetView<ApplicationController> {
appBar: controller.state.page == 0 ? null : _buildAppBar(),
body: _buildPageView(),
bottomNavigationBar: _buildBottomNavigationBar(),
floatingActionButton: FloatingActionButton(
// elevation: 6.0,
// highlightElevation: 12.0,
child: Icon(Icons.chat),
onPressed: controller.handleChat,
),
floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
));
}
}
......@@ -19,8 +19,8 @@ class CategoryController extends GetxController {
/// 成员变量
String categoryCode = '';
int curPage = 1;
int pageSize = 20;
int total = 20;
int pageSize = 10;
int total = 0;
/// 事件
......@@ -48,23 +48,20 @@ class CategoryController extends GetxController {
// 拉取数据
Future<void> fetchNewsList({bool isRefresh = false}) async {
// var result = await NewsAPI.newsPageList(
// params: NewsPageListRequestEntity(
// categoryCode: categoryCode,
// pageNum: curPage + 1,
// pageSize: pageSize,
// ),
// );
var result =
await NewsAPI.newsPageList({'page': curPage, "size": pageSize});
// if (isRefresh == true) {
// curPage = 1;
// total = result.counts!;
// state.newsList.clear();
// } else {
// curPage++;
// }
if (isRefresh == true) {
curPage = 1;
total = result.total!;
state.newsList.clear();
} else {
curPage++;
}
state.newsList.addAll(result.records!);
// state.newsList.addAll(result.items!);
print("${state.newsList.length}");
}
/// 生命周期
......
This diff is collapsed.
......@@ -33,9 +33,9 @@ class _NewsPageListState extends State<NewsPageList>
child: CustomScrollView(
slivers: [
SliverPadding(
padding: EdgeInsets.symmetric(
vertical: 0.w,
horizontal: 0.w,
padding: const EdgeInsets.symmetric(
vertical: 16,
horizontal: 16,
),
sliver: SliverList(
delegate: SliverChildBuilderDelegate(
......
import 'package:get/get.dart';
import 'controller.dart';
class ChatBinding implements Bindings {
@override
void dependencies() {
// print('ChatPageControllerChatPageControllerChatPageController');
// Get.lazyPut<ChatPageController>(() => ChatPageController());
}
}
import 'package:chart/common/apis/apis.dart';
// import 'package:chart/common/entities/entities.dart';
// import 'package:chart/models/user_model.dart';
import 'package:get/get.dart';
// import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:flutter_chat_types/flutter_chat_types.dart' as types;
import 'package:uuid/uuid.dart';
import '../../common/store/user.dart';
import 'index.dart';
import 'package:chart/service/message_service.dart';
class ChatPageController extends GetxController {
ChatPageController();
/// 响应式成员变量
// final state = ChatPageState();
RxList<types.Message> messageList = <types.Message>[].obs;
final _count = 0.obs;
get count => _count;
set count(value) => _count.value = value;
// set categories(value) => _categories.value = value;
final _user = const types.User(
id: '82091008-a4aa-4a89-ae75-a22bf8d6f3aa',
);
final receiveUser = const types.User(
id: '82091008-a484-4a89-ae75-a22bf8d6f3aa',
firstName: "GPT",
lastName: '大师',
imageUrl:
"https://imgb15.photophoto.cn/20201124/jiqirentupian-39852917_3.jpg"
// imageUrl: "assets/images/300.jpg",
);
/// 事件
void sendMessage(types.PartialText message) async {
// if (state.messageList.isNotEmpty) {
// // data = !_messages.every((element) => element.status != Status.sending);
// }
// if (data) {
// Fluttertoast.showToast(
// msg: "操作太快了 你上个问题还没问完呢",
// toastLength: Toast.LENGTH_SHORT,
// gravity: ToastGravity.CENTER,
// timeInSecForIosWeb: 1,
// backgroundColor: Colors.red,
// textColor: Colors.white,
// fontSize: 16.0);
// return;
// }
final textMessage = types.TextMessage(
author: _user,
createdAt: DateTime.now().millisecondsSinceEpoch,
id: const Uuid().v4(),
text: "${message.text}",
);
// final loadingMessage = types.TextMessage(
// author: receiveUser,
// createdAt: DateTime.now().millisecondsSinceEpoch,
// id: const Uuid().v4(),
// text: "loading",
// status: types.Status.sending,
// // "sending",
// );
_addMessage(textMessage);
// _addMessage(loadingMessage);
try {
String? result = await NewsAPI.sendMessage(
{"question": message.text, "id": "${UserStore.to.profile.id}"});
// _cancelLoading();
final receiveMessage = types.TextMessage(
author: receiveUser,
createdAt: DateTime.now().millisecondsSinceEpoch,
id: const Uuid().v4(),
text: "$result",
);
_addMessage(receiveMessage);
} catch (e) {
print("eeeeeeee$e");
// _cancelLoading();
final receiveErrorMessage = types.TextMessage(
author: receiveUser,
createdAt: DateTime.now().millisecondsSinceEpoch,
id: const Uuid().v4(),
text: "当前用户太多了,请稍等再试",
);
_addMessage(receiveErrorMessage);
}
}
void _addMessage(types.Message message) {
// state.messageList = [message]
// state.messageList.add(message);
messageList.insert(0, message);
}
void addCount() {
count.value = count.value + 1;
}
// 方法
// 拉取数据
Future<void> fetchNewsList({bool isRefresh = false}) async {
// var result =
// await NewsAPI.newsPageList({'page': curPage, "size": pageSize});
// if (isRefresh == true) {
// curPage = 1;
// total = result.total!;
// state.newsList.clear();
// } else {
// curPage++;
// }
// state.newsList.addAll(result.records!);
// print("${state.newsList.length}");
}
/// 生命周期
@override
void onInit() {
super.onInit();
ever(messageList, (value) {
print("messageListmessageListmessageListmessageList$value");
});
}
///dispose 释放内存
@override
void dispose() {
super.dispose();
// dispose 释放对象
// refreshController.dispose();
}
// obx(Map map) {}
}
library category;
export './state.dart';
export './controller.dart';
export './bindings.dart';
export './view.dart';
// import 'dart:ffi';
import 'package:chart/common/entities/entities.dart';
import 'package:get/get.dart';
import 'package:flutter_chat_types/flutter_chat_types.dart' as types;
class ChatPageState {
// 新闻翻页 // List<types.Message>
RxList<types.Message> messageList = <types.Message>[].obs;
// get _messageList =>
// final _page = 0.obs;
// set page(value) => this._page.value = value;
// get page => this._page.value;
// RxList<NewsItem> newsList = <NewsItem>[].obs;
}
import 'package:flutter/material.dart';
import 'package:flutter_chat_ui/flutter_chat_ui.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:babstrap_settings_screen/babstrap_settings_screen.dart';
import '../../common/values/colors.dart';
import '../../common/widgets/app.dart';
import 'index.dart';
import './widgets/widgets.dart';
import 'package:flutter_chat_types/flutter_chat_types.dart' as types;
// import 'widgets/widgets.dart';
import './controller.dart';
class ChatPage extends GetView<ChatPageController> {
@override
Widget build(BuildContext context) {
final controller = Get.put(ChatPageController());
// final controller = Get.find<ChatPageController>();
// ignore: unused_local_variable
// controller controller1 =
// Get.put(ChatPageController()); // Rather Controller controller = Controller();
// // final Controller c = Get.put(Controller());
// final c = Get.put(ChatPageController());
return Scaffold(
appBar: transparentAppBar(
title: Text(
"${controller.messageList.length}",
style: TextStyle(
color: AppColors.primaryElementText,
fontFamily: 'Montserrat',
fontSize: 18.sp,
fontWeight: FontWeight.w600,
),
),
actions: [
IconButton(
icon: Icon(
Icons.search,
color: AppColors.primaryElementText,
),
onPressed: () {
// controller.count = 3;
controller.addCount();
// controller.messageList.length = 2;
},
)
],
),
body: Text("${controller.count}", style: TextStyle())
// Obx(() => )),
);
}
}
final _user = const types.User(
id: '82091008-a4aa-4a89-ae75-a22bf8d6f3aa',
);
// Container(
// height: double.infinity,
// width: double.infinity,
// decoration: BoxDecoration(
// image: DecorationImage(
// image: Image.asset("assets/images/bg.png").image,
// fit: BoxFit.cover),
// ),
// child: Chat(
// // onAttachmentPressed: _handleAttachmentPressed,
// // bubbleBuilder: _bubbleBuilder,
// theme: const DefaultChatTheme(
// // #1e1c39//#1e1c39#1e1c39#1e1c39
// // rgba(30, 28, 57, 1.00)
// backgroundColor: Color.fromRGBO(30, 28, 57, 0),
// // inputBackgroundColor: Colors.red,
// ),
// messages: controller.messageList,
// // messages: controller.state.messageList,
// // onAttachmentPressed: _handleAttachmentPressed,
// // onMessageTap: _handleMessageTap,
// // onPreviewDataFetched: _handlePreviewDataFetched,
// // onSendPressed: _handleSendPressed,
// showUserAvatars: true,
// showUserNames: true,
// // UserStore.to.isLogin
// // user: _user,
// l10n: const ChatL10nEn(
// inputPlaceholder: '请输入你的问题,并寻求解答...',
// attachmentButtonAccessibilityLabel: '继续',
// emptyChatPlaceholder: '暂无聊天信息',
// sendButtonAccessibilityLabel: '发送'),
// onSendPressed: controller.sendMessage, user: _user,
// )
\ No newline at end of file
import 'dart:math' as math;
import 'dart:ui';
import 'package:get/get.dart';
import 'package:flutter/material.dart';
import 'package:flutter_chat_ui/flutter_chat_ui.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:chart/constant/app_colors.dart';
import 'package:flutter_chat_types/flutter_chat_types.dart' as types;
import '../index.dart';
final _user = const types.User(
id: '82091008-a4aa-4a89-ae75-a22bf8d6f3aa',
);
class ChartComponent extends StatelessWidget {
// final controller = Get.find(ChatPageController);
final controller = Get.put(ChatPageController());
// controller.leadBoardModel != null
@override
Widget build(BuildContext context) {
// controller.
return Obx(() => Chat(
// onAttachmentPressed: _handleAttachmentPressed,
// bubbleBuilder: _bubbleBuilder,
theme: const DefaultChatTheme(
// #1e1c39//#1e1c39#1e1c39#1e1c39
// rgba(30, 28, 57, 1.00)
backgroundColor: Color.fromRGBO(30, 28, 57, 0),
// inputBackgroundColor: Colors.red,
),
messages: controller.messageList,
// messages: controller.state.messageList,
// onAttachmentPressed: _handleAttachmentPressed,
// onMessageTap: _handleMessageTap,
// onPreviewDataFetched: _handlePreviewDataFetched,
// onSendPressed: _handleSendPressed,
showUserAvatars: true,
showUserNames: true,
// UserStore.to.isLogin
// user: _user,
l10n: const ChatL10nEn(
inputPlaceholder: '请输入你的问题,并寻求解答...',
attachmentButtonAccessibilityLabel: '继续',
emptyChatPlaceholder: '暂无聊天信息',
sendButtonAccessibilityLabel: '发送'),
onSendPressed: controller.sendMessage, user: _user,
));
// Obx(
// () => true
// ? Text("1321")
// : Chat(
// // onAttachmentPressed: _handleAttachmentPressed,
// // bubbleBuilder: _bubbleBuilder,
// theme: const DefaultChatTheme(
// // #1e1c39//#1e1c39#1e1c39#1e1c39
// // rgba(30, 28, 57, 1.00)
// backgroundColor: Color.fromRGBO(30, 28, 57, 0),
// // inputBackgroundColor: Colors.red,
// ),
// messages: controller.messageList,
// // messages: controller.state.messageList,
// // onAttachmentPressed: _handleAttachmentPressed,
// // onMessageTap: _handleMessageTap,
// // onPreviewDataFetched: _handlePreviewDataFetched,
// // onSendPressed: _handleSendPressed,
// showUserAvatars: true,
// showUserNames: true,
// // UserStore.to.isLogin
// // user: _user,
// l10n: const ChatL10nEn(
// inputPlaceholder: '请输入你的问题,并寻求解答...',
// attachmentButtonAccessibilityLabel: '继续',
// emptyChatPlaceholder: '暂无聊天信息',
// sendButtonAccessibilityLabel: '发送'),
// onSendPressed: controller.sendMessage, user: _user,
// ),
// );
}
}
library widgets;
// export 'news_page_list.dart';
export 'news_item.dart';
import 'package:chart/models/user_model.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
// import '../size_confige.dart';
class DoctorAppBar extends StatelessWidget {
const DoctorAppBar(
this.userModel, {
Key? key,
}) : super(key: key);
final UserModel userModel;
// late final UserModel _userModel;
// @override
// didChangeDependencies() {
// super.didChangeDependencies();
// _userModel = Provider.of<UserModel>(context);
// }
@override
Widget build(BuildContext context) {
UserModel userViewModel = Provider.of<UserModel>(context);
// final text = Provider.of<String>(context);
// _userModel = Provider.of<UserModel>(context);
// ${userViewModel.integralEntity?.username}
print(userViewModel.integralEntity);
return Container(
// height: 300,
width: double.infinity,
child: Padding(
padding: EdgeInsets.only(left: 20, top: 60, right: 20, bottom: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
// ignore: prefer_const_literals_to_create_immutables
children: [
// ignore: prefer_const_constructors
Text(
"Hi, ${userViewModel.integralEntity?.username}",
// ignore: prefer_const_constructors
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w800,
fontSize: 20),
),
SizedBox(height: 30),
// ignore: prefer_const_constructors
Text(
"欢迎使用GPT大师傅,你可以收获很多",
style: TextStyle(color: Colors.white, fontSize: 12),
),
],
),
GestureDetector(
onTap: () => {Navigator.of(context).pushNamed('/goods')},
child: Container(
height: 60,
width: 60,
decoration: BoxDecoration(
// boxShadow: [
// BoxShadow(
// blurRadius: 3,
// offset: Offset(0, 4),
// color: Colors.black54,
// )
// ],
// color: Color(0xffA295FD),
borderRadius: BorderRadius.circular(5)),
child: ClipRRect(
borderRadius: BorderRadius.circular(5),
child: Image.asset("assets/images/dingyue.png")),
),
)
],
),
),
);
}
}
This diff is collapsed.
import 'package:flutter/material.dart';
const kLightTextColor = Color(0xffB5C8E7);
const kHardTextColor = Color(0xff586191);
const kPrimaryDarkColor = Color(0xff46BDFA);
const kPrimarylightColor = Color(0xff77E2FE);
const kBackgroundColor = Color(0xffEFF2F7);
const List<Color> kCategoriesPrimaryColor = [
Color(0xffFFCA8C),
Color(0xff5DF9D3),
Color(0xff85E4FD),
Color(0xffB8ACFF)
];
const List<Color> kCategoriesSecondryColor = [
Color(0xffFEA741),
Color(0xff31DFB5),
Color(0xff45BAFB),
Color(0xff9182F9)
];
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:glass_kit/glass_kit.dart';
import 'package:smooth_page_indicator/smooth_page_indicator.dart';
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
import 'package:glassmorphism/glassmorphism.dart';
import 'dart:math';
const List<Color> kCategoriesPrimaryColor = [
Color(0xffFFCA8C),
Color(0xff5DF9D3),
Color(0xff85E4FD),
Color(0xffB8ACFF)
];
const List<Color> kCategoriesSecondryColor = [
Color(0xffFEA741),
Color(0xff31DFB5),
Color(0xff45BAFB),
Color(0xff9182F9)
];
class Doctor {
final String name, speciality, image;
final int reviews;
final int reviewScore;
Doctor(
{required this.name,
required this.speciality,
required this.image,
required this.reviews,
required this.reviewScore});
}
final doctorsList = [
Doctor(
name: "通用型",
speciality: "通用聊天",
image: "assets/images/doctor_1.png",
reviews: 80,
reviewScore: 4),
Doctor(
name: "英汉互译",
speciality: "翻译高手",
image: "assets/images/doctor_2.png",
reviews: 67,
reviewScore: 5),
Doctor(
name: "面试官",
speciality: "谷歌面试官帮你面试",
image: "assets/images/doctor_3.png",
reviews: 19,
reviewScore: 4),
Doctor(
name: "知音",
speciality: "最懂你的女生",
image: "assets/images/doctor_2.png",
reviews: 19,
reviewScore: 5),
];
const kLightTextColor = Color(0xffB5C8E7);
const kHardTextColor = Color(0xff586191);
const kPrimaryDarkColor = Color(0xff46BDFA);
const kPrimarylightColor = Color(0xff77E2FE);
const kBackgroundColor = Color(0xffEFF2F7);
// import 'package:flutter_rating_bar/flutter_rating_bar.dart';
class ListPage extends StatefulWidget {
@override
ListPageState createState() => ListPageState();
}
class ListPageState extends State<ListPage> {
final controller = PageController(viewportFraction: 0.8, keepPage: true);
// final List<BankCardModel> cards = [
// BankCardModel('assets/images/bg_red_card.png', 'Hoang Cuu Long',
// '4221 5168 7464 2283', '08/20', 10000000),
// BankCardModel('assets/images/bg_blue_circle_card.png', 'Hoang Cuu Long',
// '4221 5168 7464 2283', '08/20', 10000000),
// BankCardModel('assets/images/bg_purple_card.png', 'Hoang Cuu Long',
// '4221 5168 7464 2283', '08/20', 10000000),
// BankCardModel('assets/images/bg_blue_card.png', 'Hoang Cuu Long',
// '4221 5168 7464 2283', '08/20', 10000000),
// ];
@override
Widget build(BuildContext context) {
// TODO: implement build
// final color = kCategoriesSecondryColor[
// (kCategoriesSecondryColor.length - index - 1)];
// final circleColor = kCategoriesPrimaryColor[
// (kCategoriesPrimaryColor.length - index - 1)];
// final cardWidth = getRelativeWidth(0.48);
return Container(
margin: const EdgeInsets.symmetric(vertical: 20.0),
height: 80.0,
child: ListView(
// This next line does the trick.
scrollDirection: Axis.horizontal,
children: List.generate(
4,
(index) => Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
GlassmorphicContainer(
width: 200,
height: 180.0,
borderRadius: 16,
padding: EdgeInsets.only(bottom: 16),
blur: 14,
alignment: Alignment.bottomCenter,
border: 2,
linearGradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFF0FFFF).withOpacity(0.2),
Color(0xFF0FFFF).withOpacity(0.2),
],
),
borderGradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFF0FFFF).withOpacity(1),
Color(0xFFFFFFF),
Color(0xFF0FFFF).withOpacity(1),
],
),
child: Container(
height: 180.0,
width: 200.0,
constraints: BoxConstraints(minWidth: 41),
decoration: BoxDecoration(
// color: Colors.white,
borderRadius: BorderRadius.circular(16),
),
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 14),
child: Row(
children: [
Container(
padding: EdgeInsets.all(14),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
kCategoriesPrimaryColor[index],
kCategoriesSecondryColor[index],
],
),
borderRadius: BorderRadius.circular(16)),
child: Icon(
Icons.headset_mic,
size: 20,
color: Colors.white,
),
),
SizedBox(width: 11),
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"写文案",
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
SizedBox(height: 5),
Text(
" 例如述职报告等",
style: TextStyle(
color: Colors.white, fontSize: 12),
),
],
),
],
),
),
)),
SizedBox(width: 20)
],
),
),
),
);
}
}
import 'package:flutter/material.dart';
import 'package:flutter_chat_ui/flutter_chat_ui.dart';
// import 'package:line_icons/line_icons.dart';
// import './size_confige.dart';
class SearchField extends StatelessWidget {
SearchField({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
height: 200,
child: Center(
child: TextField(
decoration: InputDecoration(
contentPadding: EdgeInsets.symmetric(vertical: 20),
fillColor: Colors.white,
filled: true,
hintText: "Search Doctor",
hintStyle: TextStyle(
fontSize: 12,
color: Colors.blueGrey.withOpacity(0.9),
),
// prefixIcon:
// Icon(
// LineIcons.search,
// color: Colors.blueGrey.withOpacity(0.9),
// size: getRelativeWidth(0.065),
// ),
suffixIcon: Padding(
padding: EdgeInsets.symmetric(horizontal: 30),
child: Container(
width: 100,
height: 60,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Color(0xffFBA473), Color(0xffFA7A30)]),
borderRadius: BorderRadius.circular(25),
),
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Filter",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 20),
),
Icon(
Icons.filter_list,
color: Colors.white,
size: 20,
)
],
),
),
),
),
border: outlineBorder,
enabledBorder: outlineBorder,
focusedBorder: outlineBorder),
),
),
);
}
final outlineBorder = OutlineInputBorder(
borderSide: BorderSide.none,
borderRadius: BorderRadius.circular(30),
);
}
import 'package:flutter/material.dart';
class SizeConfig {
static double screenWidth = double.infinity;
static double screenHeight = 550;
static initSize(BuildContext context) {
final mediaQuery = MediaQuery.of(context);
screenWidth = mediaQuery.size.width;
screenHeight = mediaQuery.size.height;
}
}
double getRelativeHeight(double percentage) {
return percentage * SizeConfig.screenHeight;
}
double getRelativeWidth(double percentage) {
return percentage * SizeConfig.screenWidth;
}
This diff is collapsed.
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:card_swiper/card_swiper.dart';
import 'package:smooth_page_indicator/smooth_page_indicator.dart';
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
import 'dart:math';
const List<Color> kCategoriesPrimaryColor = [
Color(0xffFFCA8C),
Color(0xff5DF9D3),
Color(0xff85E4FD),
Color(0xffB8ACFF)
];
const List<Color> kCategoriesSecondryColor = [
Color(0xffFEA741),
Color(0xff31DFB5),
Color(0xff45BAFB),
Color(0xff9182F9)
];
class Doctor {
final String name, speciality, image;
final int reviews;
final int reviewScore;
Doctor(
{required this.name,
required this.speciality,
required this.image,
required this.reviews,
required this.reviewScore});
}
const kLightTextColor = Color(0xffB5C8E7);
const kHardTextColor = Color(0xff586191);
const kPrimaryDarkColor = Color(0xff46BDFA);
const kPrimarylightColor = Color(0xff77E2FE);
const kBackgroundColor = Color(0xffEFF2F7);
// import 'package:flutter_rating_bar/flutter_rating_bar.dart';
class SwiperColunmPage extends StatefulWidget {
@override
SwiperColunmPageState createState() => SwiperColunmPageState();
}
class SwiperColunmPageState extends State<SwiperColunmPage> {
final controller = PageController(viewportFraction: 0.8, keepPage: true);
@override
Widget build(BuildContext context) {
// TODO: implement build
return Container(
height: 200,
child: Swiper(
// scrollDirection: Axis.vertical,
autoplay: true,
itemBuilder: (BuildContext context, int index) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
color: Colors.black.withAlpha(0),
// Color.fromRGBO(69, 185, 251, 1.00),
// rgba(69, 185, 251, 1.00)
),
child: ClipRRect(
borderRadius: BorderRadius.circular(16),
child: Image.network(
"https://img14.360buyimg.com/babel/s700x360_jfs/t1/4099/12/2578/101668/5b971b4bE65ae279d/89dd1764797acfd9.jpg!q90!cc_350x180",
fit: BoxFit.cover,
),
));
},
viewportFraction: 0.8,
scale: 0.9,
// layout: SwiperLayout.CUSTOM,
// customLayoutOption: CustomLayoutOption(startIndex: -1, stateCount: 3)
// ..addRotate([-45.0 / 180, 0.0, 45.0 / 180])
// ..addTranslate(
// [Offset(-370.0, -40.0), Offset(0.0, 0.0), Offset(370.0, -40.0)]),
// itemWidth: 300.0,
// itemHeight: 200.0,
itemCount: 3,
pagination: SwiperPagination(),
control: null,
),
);
}
}
import 'package:chart/constant/app_colors.dart';
import 'package:flutter/material.dart';
// import 'package:chart/constant/app_colors.dart';
// import 'package:chart/constant/app_dimens.dart';
import 'package:chart/constant/app_images.dart';
// import 'package:chart/constant/app_strings.dart';
import 'package:chart/models/user_model.dart';
import 'package:provider/provider.dart';
import 'package:responsive_grid_list/responsive_grid_list.dart';
import 'package:flutter/services.dart';
import 'package:flutter_chat_ui/flutter_chat_ui.dart';
import 'package:chart/pages/dashboard/components/banner.dart';
import 'package:chart/pages/dashboard/components/search.dart';
import 'package:chart/pages/dashboard/components/appbar.dart';
import 'package:chart/pages/dashboard/components/list.dart';
import 'package:chart/pages/dashboard/components/swiper.dart';
import 'package:chart/pages/dashboard/components/swiper_column.dart';
import 'package:flutter/cupertino.dart';
// import 'package:flutter/material.dart';
import 'package:smooth_page_indicator/smooth_page_indicator.dart';
import '../../models/app_model.dart';
//
// import 'package:chart/utils/navigator_util.dart';
// import 'package:flutter_screenutil/flutter_screenutil.dart';
class DashBoardPage extends StatefulWidget {
const DashBoardPage({Key? key}) : super(key: key);
@override
DashBoardPageState createState() => DashBoardPageState();
}
class DashBoardPageState extends State<DashBoardPage> {
var guides = [AppImages.guide1, AppImages.guide2, AppImages.guide3];
late UserModel _userModel;
late AppModel _appModel;
var _showButton = false;
@override
void didChangeDependencies() async {
super.didChangeDependencies();
_userModel = Provider.of<UserModel>(context);
_appModel = Provider.of<AppModel>(context);
// _appModel.getClassFyList();
}
// final FocusNode focusNode = FocusNode();
@override
Widget build(BuildContext context) {
UserModel().setIsFirstOpen(false);
// print("_appModel_appModel_appModel${_appModel._classFyList}");
return Scaffold(
backgroundColor: Color(0xFFF4F4F4),
body: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: Image.asset("assets/images/bg.png").image,
fit: BoxFit.cover),
),
child: SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(),
child: GestureDetector(
// onTap: () {
// // focusNode.unfocus();
// SystemChannels.textInput.invokeMethod('TextInput.hide');
// },
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
children: [
// DoctorAppBar(_userModel),
// SwiperPage(),
// // SwiperColunmPage(),
// BannerPage(),
// ListPage(),
],
),
),
),
),
)),
);
}
void _handleCancel() {}
List<Container> _getListData() {
var tempList = [
"护肤品推荐",
"答题助手",
"朋友圈文案",
"专业翻译",
].map((obj) {
return Container(
// 子元素
decoration: BoxDecoration(
// 边框
border: Border.all(
// 颜色
color: Color.fromRGBO(233, 233, 233, 0.8),
// 边框宽度
width: 1.0)),
// 子元素
child: Column(
// 子元素
children: <Widget>[
// 图片
// Image.network(obj['imageUrl']),
// 图片与文字的间隔使用
const SizedBox(height: 12),
// 文字
Text(obj,
textAlign: TextAlign.center, style: TextStyle(fontSize: 18)),
],
),
);
});
return tempList.toList();
}
}
class DismissKeyboardDemo extends StatelessWidget {
final FocusNode focusNode = FocusNode();
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
focusNode.unfocus();
},
child: Container(
color: Colors.transparent,
alignment: Alignment.center,
child: TextField(
focusNode: focusNode,
),
),
);
}
}
// return Scaffold(
// appBar: AppBar(title: const Text('Demo')),
// body: ,
// );
......@@ -2,9 +2,9 @@ import 'package:get/get.dart';
import 'controller.dart';
class NotfoundBinding implements Bindings {
class ChatNewBinding implements Bindings {
@override
void dependencies() {
Get.lazyPut<NotfoundController>(() => NotfoundController());
Get.lazyPut<ChatNewController>(() => ChatNewController());
}
}
import 'package:chart/common/apis/apis.dart';
import 'package:chart/common/store/store.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';
import 'package:uuid/uuid.dart';
import 'package:flutter_chat_types/flutter_chat_types.dart' as types;
import 'index.dart';
class NotfoundController extends GetxController {
NotfoundController();
class ChatNewController extends GetxController {
ChatNewController();
/// 响应式成员变量
final state = NotfoundState();
final state = ChatPageState();
/// 成员变量
/// 事件
// tap
void handleTap(int index) {
Get.snackbar(
"标题",
"消息",
final _user = const types.User(
id: '82091008-a4aa-4a89-ae75-a22bf8d6f3aa',
);
final receiveUser = const types.User(
id: '82091008-a484-4a89-ae75-a22bf8d6f3aa',
firstName: "GPT",
lastName: '大师',
imageUrl:
"https://imgb15.photophoto.cn/20201124/jiqirentupian-39852917_3.jpg"
// imageUrl: "assets/images/300.jpg",
);
/// 事件
void sendMessage(types.PartialText message) async {
// if (state.messageList.isNotEmpty) {
// // data = !_messages.every((element) => element.status != Status.sending);
// }
// if (data) {
// Fluttertoast.showToast(
// msg: "操作太快了 你上个问题还没问完呢",
// toastLength: Toast.LENGTH_SHORT,
// gravity: ToastGravity.CENTER,
// timeInSecForIosWeb: 1,
// backgroundColor: Colors.red,
// textColor: Colors.white,
// fontSize: 16.0);
// return;
// }
final textMessage = types.TextMessage(
author: _user,
createdAt: DateTime.now().millisecondsSinceEpoch,
id: const Uuid().v4(),
text: "${message.text}",
);
// final loadingMessage = types.TextMessage(
// author: receiveUser,
// createdAt: DateTime.now().millisecondsSinceEpoch,
// id: const Uuid().v4(),
// text: "loading",
// status: types.Status.sending,
// // "sending",
// );
_addMessage(textMessage);
// _addMessage(loadingMessage);
EasyLoading.showProgress(0.5, status: "正在思考中");
// ("正在思考中...");
try {
String? result = await NewsAPI.sendMessage(
{"question": message.text, "id": "${UserStore.to.profile.id}"});
// _cancelLoading();
final receiveMessage = types.TextMessage(
author: receiveUser,
createdAt: DateTime.now().millisecondsSinceEpoch,
id: const Uuid().v4(),
text: "$result",
);
_addMessage(receiveMessage);
EasyLoading.dismiss();
} catch (e) {
print("eeeeeeee$e");
// _cancelLoading();
final receiveErrorMessage = types.TextMessage(
author: receiveUser,
createdAt: DateTime.now().millisecondsSinceEpoch,
id: const Uuid().v4(),
text: "当前用户太多了,请稍等再试",
);
_addMessage(receiveErrorMessage);
EasyLoading.dismiss();
}
}
/// 生命周期
void _addMessage(types.Message message) {
state.messageList.insert(0, message);
// state.messageList = [message]
// state.messageList.add(message);
// state.messageList.add(message);
// updateState(state);
// update()
// update((state.messageList), {
// // state.messageList.value = [message]
// });
///在 widget 内存中分配后立即调用。
///你可以用它来为控制器初始化 initialize 一些东西。
@override
void onInit() {
super.onInit();
// new 对象
// 初始静态数据
// user.update((value) {
// value?.name = "123";
// });
// state.messageList.value = [message];
}
///在 onInit() 之后调用 1 帧。这是进入的理想场所
///导航事件,例如 snackbar、对话框或新route,或
///async 异步请求。
@override
void onReady() {
super.onReady();
// async 拉取数据
void addCount() {
// count.value = count.value + 1;
}
// 方法
// 拉取数据
Future<void> fetchNewsList({bool isRefresh = false}) async {
// var result =
// await NewsAPI.newsPageList({'page': curPage, "size": pageSize});
// if (isRefresh == true) {
// curPage = 1;
// total = result.total!;
// state.newsList.clear();
// } else {
// curPage++;
// }
// state.newsList.addAll(result.records!);
// print("${state.newsList.length}");
}
///在 [onDelete] 方法之前调用。 [onClose] 可能用于
///处理控制器使用的资源。就像 closing events 一样,
///或在控制器销毁之前的流。
///或者处置可能造成一些内存泄漏的对象,
///像 TextEditingControllers、AnimationControllers。
///将一些数据保存在磁盘上也可能很有用。
/// 生命周期
@override
void onClose() {
super.onClose();
// 1 stop & close 关闭对象
// 2 save 持久化数据
void onInit() {
print("initttinitttinitttinitttinitttinitttinittt");
super.onInit();
ever(Get.parameters['question'].obs, (value) {
print("messageListmessageListmessageListmessageList$value");
});
}
///dispose 释放内存
......@@ -59,5 +154,8 @@ class NotfoundController extends GetxController {
void dispose() {
super.dispose();
// dispose 释放对象
// refreshController.dispose();
}
// obx(Map map) {}
}
// import 'dart:ffi';
import 'package:chart/common/entities/entities.dart';
import 'package:get/get.dart';
import 'package:flutter_chat_types/flutter_chat_types.dart' as types;
class ChatPageState {
// 新闻翻页 // List<types.Message>
RxList<types.Message> messageList = <types.Message>[].obs;
class NotfoundState {
// title
final _title = "".obs;
set title(value) => this._title.value = value;
get title => this._title.value;
// get _messageList =>
// final _page = 0.obs;
// set page(value) => this._page.value = value;
// get page => this._page.value;
// RxList<NewsItem> newsList = <NewsItem>[].obs;
}
import 'package:chart/common/routers/routes.dart';
import 'package:chart/common/values/values.dart';
import 'package:flutter/material.dart';
import 'package:flutter_chat_ui/flutter_chat_ui.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:flutter_chat_types/flutter_chat_types.dart' as types;
import '../../../common/widgets/app.dart';
import '../../application/view.dart';
import 'index.dart';
import 'widgets/widgets.dart';
class NotfoundPage extends GetView<NotfoundController> {
class ChatNewPage extends GetView<ChatNewController> {
// 内容页
Widget _buildView() {
return HellowordWidget();
}
// Widget _buildView() {
// return HellowordWidget();
// }
@override
Widget build(BuildContext context) {
return Scaffold(
body: _buildView(),
appBar: transparentAppBar(
title: Text(
"Chat",
style: TextStyle(
color: AppColors.primaryElementText,
fontFamily: 'Montserrat',
fontSize: 18.sp,
fontWeight: FontWeight.w600,
),
),
leading: IconButton(
tooltip: '返回上一页',
icon: const Icon(
Icons.arrow_back,
color: AppColors.primaryElementText,
),
onPressed: () {
Get.back();
// Get.offAll(ApplicationPage());
// await Get.off(ApplicationPage());
// Get.toNamed(AppRoutes.Application);
// Navigator.of(context).pop();
//_nextPage(-1);
},
)),
body: Obx(() => Container(
width: double.infinity,
height: double.infinity,
padding: EdgeInsets.symmetric(horizontal: 0),
decoration: BoxDecoration(
image: DecorationImage(
image: Image.asset("assets/images/bg.png").image,
fit: BoxFit.cover),
),
child: Chat(
// onAttachmentPressed: _handleAttachmentPressed,
// bubbleBuilder: _bubbleBuilder,
theme: const DefaultChatTheme(
// #1e1c39//#1e1c39#1e1c39#1e1c39
// rgba(30, 28, 57, 1.00)
backgroundColor: Color.fromRGBO(30, 28, 57, 0),
// inputBackgroundColor: Colors.red,
),
messages: controller.state.messageList.value,
// messages: controller.state.messageList,
// onAttachmentPressed: _handleAttachmentPressed,
// onMessageTap: _handleMessageTap,
// onPreviewDataFetched: _handlePreviewDataFetched,
// onSendPressed: _handleSendPressed,
showUserAvatars: true,
showUserNames: true,
// UserStore.to.isLogin
// user: _user,
l10n: const ChatL10nEn(
inputPlaceholder: '请输入你的问题,并寻求解答...',
attachmentButtonAccessibilityLabel: '继续',
emptyChatPlaceholder: '暂无聊天信息',
sendButtonAccessibilityLabel: '发送'),
onSendPressed: controller.sendMessage, user: _user,
),
))
// Obx(() => )),
);
}
}
final _user = const types.User(
id: '82091008-a4aa-4a89-ae75-a22bf8d6f3aa',
);
......@@ -4,11 +4,11 @@ import 'package:get/get.dart';
import '../index.dart';
/// hellowrod
class HellowordWidget extends GetView<NotfoundController> {
class HellowordWidget extends GetView<ChatNewController> {
@override
Widget build(BuildContext context) {
return Center(
child: Obx(() => Text(controller.state.title)),
child: Obx(() => Text("controller.state.title")),
);
}
}
import 'package:get/get.dart';
import 'controller.dart';
class PayListBinding implements Bindings {
@override
void dependencies() {
Get.lazyPut<PayListController>(() => PayListController());
}
}
import 'dart:async';
import 'package:chart/common/apis/apis.dart';
import 'package:chart/common/store/store.dart';
import 'package:chart/entity/user_entity.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_inapp_purchase/flutter_inapp_purchase.dart';
import 'package:flutter_inapp_purchase/modules.dart';
import 'package:get/get.dart';
import 'index.dart';
class PayListController extends GetxController {
PayListController();
final state = PayListState();
final List<String> _productLists = [
"com.wudi.app.weekly_pass",
"com.wudi.app.monthly_pass",
"com.wudi.app.60stars"
// "com.wudi.app.prod_id_002",
// "com.wudi.app.prod_id_003",
// "com.wudi.app.prod_id_004"
];
var _conectionSubscription;
var _purchaseUpdatedSubscription;
var _purchaseErrorSubscription;
/// 成员变量
/// 事件
// tap
void handleTap(int index) {
Get.snackbar(
"标题",
"消息",
);
}
/// 生命周期
///在 widget 内存中分配后立即调用。
///你可以用它来为控制器初始化 initialize 一些东西。
@override
void onInit() async {
super.onInit();
await _getProduct();
// await initializedPlugins();
// new 对象
// 初始静态数据
}
Future _getProduct() async {
try {
List<IAPItem> items =
await FlutterInappPurchase.instance.getProducts(_productLists);
state.items.addAll(items);
// for (var item in items) {
// // print('${item.toString()}');
// // this._items.add(item);
// }
} catch (e) {
print("_getProductError$e");
}
}
void requestPurchase(IAPItem item) {
FlutterInappPurchase.instance.requestPurchase(item.productId!);
}
///在 onInit() 之后调用 1 帧。这是进入的理想场所
///导航事件,例如 snackbar、对话框或新route,或
///async 异步请求。
@override
void onReady() {
super.onReady();
// async 拉取数据
}
///在 [onDelete] 方法之前调用。 [onClose] 可能用于
///处理控制器使用的资源。就像 closing events 一样,
///或在控制器销毁之前的流。
///或者处置可能造成一些内存泄漏的对象,
///像 TextEditingControllers、AnimationControllers。
///将一些数据保存在磁盘上也可能很有用。
@override
void onClose() {
super.onClose();
// 1 stop & close 关闭对象
// 2 save 持久化数据
}
///dispose 释放内存
@override
void dispose() {
// _purchaseUpdatedSubscription.cancel();
// _purchaseErrorSubscription.cancel();
// _conectionSubscription.cancel();
super.dispose();
// dispose 释放对象
}
}
library notfound;
export './state.dart';
export './controller.dart';
export './bindings.dart';
export './view.dart';
import 'package:flutter_inapp_purchase/flutter_inapp_purchase.dart';
import 'package:get/get.dart';
class PayListState {
// title
final _title = "".obs;
set title(value) => this._title.value = value;
get title => this._title.value;
RxList<IAPItem> items = <IAPItem>[].obs;
}
import 'package:chart/common/routers/routes.dart';
import 'package:chart/common/values/colors.dart';
import 'package:chart/common/widgets/widgets.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'index.dart';
import 'widgets/widgets.dart';
class PayListPage extends GetView<PayListController> {
// 内容页
Widget _buildView() {
return PayItemWidget();
}
@override
Widget build(BuildContext context) {
final c = Get.put(PayListController());
return Scaffold(
appBar: transparentAppBar(
title: Text(
"套餐选择",
style: TextStyle(
color: AppColors.primaryElementText,
fontFamily: 'Montserrat',
fontSize: 18.sp,
fontWeight: FontWeight.w600,
),
),
leading: IconButton(
tooltip: '返回上一页',
icon: const Icon(
Icons.arrow_back,
color: AppColors.primaryElementText,
),
onPressed: () async {
// Get.back();
// Get.offAll(ApplicationPage());
// await Get.off(ApplicationPage());
// Get.toNamed(AppRoutes.Application);
Get.back();
// await Get.toNamed();
// Navigator.of(context).pop();
//_nextPage(-1);
},
),
),
// _buildView
body: Container(
width: double.infinity,
height: double.infinity,
padding: EdgeInsets.symmetric(horizontal: 20),
decoration: BoxDecoration(
image: DecorationImage(
image: Image.asset("assets/images/bg.png").image,
fit: BoxFit.cover),
),
child: SingleChildScrollView(
child: Obx(() => Column(
children: [
Text(
c.state.items.length.toString(),
style: TextStyle(color: Color.fromRGBO(0, 0, 0, 0)),
),
Container(child: PayItemWidget())
],
)),
)),
);
}
}
import 'dart:async';
import 'package:chart/common/store/store.dart';
import 'package:chart/entity/user_entity.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_inapp_purchase/flutter_inapp_purchase.dart';
import 'package:get/get.dart';
import 'package:glassmorphism/glassmorphism.dart';
import '../../../../common/apis/apis.dart';
import '../index.dart';
class PayItemWidget extends StatefulWidget {
const PayItemWidget({Key? key}) : super(key: key);
@override
GoodsPageState createState() => GoodsPageState();
}
class GoodsPageState extends State<PayItemWidget> {
late StreamSubscription _purchaseUpdatedSubscription;
late StreamSubscription _purchaseErrorSubscription;
late StreamSubscription _conectionSubscription;
@override
void initState() {
initializedPlugins();
// TODO: implement initState
super.initState();
}
initializedPlugins() async {
String platformVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
// prepare
var result = await FlutterInappPurchase.instance.initialize();
print('result: $result');
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
_conectionSubscription =
FlutterInappPurchase.connectionUpdated.listen((connected) {
print('connected: $connected');
});
_purchaseUpdatedSubscription =
FlutterInappPurchase.purchaseUpdated.listen((productItem) async {
// print(a);
ApplePayEntity? res = await UserAPI.notifyApplePay({
'receipt': productItem?.transactionReceipt,
'userId': UserStore.to.profile.id,
"chooseEnv": false
});
print(
"productItemproductItemproductItemproductItemproductItemproductItemproductItemproductItem");
if (res?.status == 200) {
await FlutterInappPurchase.instance.clearTransactionIOS();
EasyLoading.showSuccess('${res?.message}');
EasyLoading.dismiss();
} else {
EasyLoading.showError("${res?.message}}");
EasyLoading.dismiss();
}
});
_purchaseErrorSubscription =
FlutterInappPurchase.purchaseError.listen((purchaseError) {
// print('purchase-error: $purchaseError');
EasyLoading.showError('支付订单失败');
EasyLoading.dismiss();
});
}
@override
dispose() {
_purchaseUpdatedSubscription.cancel();
_purchaseErrorSubscription.cancel();
_conectionSubscription.cancel();
super.dispose();
}
@override
Widget build(BuildContext context) {
var count = 0.obs;
// ProductController c = Get.put(ProductController());
// ProductController c = Get.put(ProductController());
PayListController c = Get.find();
// initDataList
return Column(
children: c.state.items
.map((item) => GlassmorphicContainer(
borderRadius: 16,
margin: EdgeInsets.only(top: 16),
blur: 14,
alignment: Alignment.bottomCenter,
border: 2,
linearGradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
const Color(0xFF0FFFF).withOpacity(0.2),
const Color(0xFF0FFFF).withOpacity(0.2),
],
),
borderGradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
const Color(0xFF0FFFF).withOpacity(1),
const Color(0xFFFFFFF),
const Color(0xFF0FFFF).withOpacity(1),
],
),
height: 173,
width: double.infinity,
// margin: EdgeInsets.symmetric(vertical: 10.0),
child: Container(
child: Column(
children: <Widget>[
Container(
padding: EdgeInsets.all(16.0),
width: double.infinity,
// height: 200,
child: Column(children: [
Row(
children: [
const Text(
"项目名称:",
style: TextStyle(color: Colors.white),
),
SizedBox(
width: 10,
),
Text(
item.title!,
style: TextStyle(color: Colors.white),
)
],
),
Row(
children: [
const Text(
"项目价格:",
style: TextStyle(color: Colors.white),
),
SizedBox(
width: 10,
),
Text(
item.localizedPrice!,
style: TextStyle(color: Colors.white),
)
],
),
Row(
children: [
const Text(
"项目描述:",
style: TextStyle(color: Colors.white),
),
SizedBox(
width: 10,
),
Expanded(
child: Text(
maxLines: 3,
item.description!,
style: TextStyle(
color: Colors.white,
),
))
],
),
Row(children: [
ElevatedButton(
// color: Colors.orange,
onPressed: () {
EasyLoading.show(status: '提交订单中...');
c.requestPurchase(item);
// c()
},
child: Text('购买套餐'),
),
])
]),
// child: ,
),
],
),
),
))
.toList());
}
}
library widgets;
export './helloword.dart';
import 'package:get/get.dart';
import 'controller.dart';
class ProductBinding implements Bindings {
@override
void dependencies() {
Get.lazyPut<ProductController>(() => ProductController());
}
}
import 'package:chart/common/apis/apis.dart';
import 'package:chart/common/store/user.dart';
import 'package:get/get.dart';
import 'index.dart';
class ProductController extends GetxController {
ProductController();
/// 响应式成员变量
final state = ProductState();
late final List<String> initDataList;
/// 成员变量
/// 事件
// tap
void handleTap(int index) {
Get.snackbar(
"标题",
"消息",
);
}
/// 生命周期
///在 widget 内存中分配后立即调用。
///你可以用它来为控制器初始化 initialize 一些东西。
@override
void onInit() {
super.onInit();
initDataList = ["321321", '321321'];
// new 对象
// 初始静态数据
}
void handleGenText(String text) async {
try {
// var a =
String result = await NewsAPI.sendMessage(
{"question": text, "id": "${UserStore.to.profile.id}"});
state.genText = result;
} catch (e) {}
}
///在 onInit() 之后调用 1 帧。这是进入的理想场所
///导航事件,例如 snackbar、对话框或新route,或
///async 异步请求。
@override
void onReady() {
super.onReady();
// async 拉取数据
}
///在 [onDelete] 方法之前调用。 [onClose] 可能用于
///处理控制器使用的资源。就像 closing events 一样,
///或在控制器销毁之前的流。
///或者处置可能造成一些内存泄漏的对象,
///像 TextEditingControllers、AnimationControllers。
///将一些数据保存在磁盘上也可能很有用。
@override
void onClose() {
super.onClose();
// 1 stop & close 关闭对象
// 2 save 持久化数据
}
///dispose 释放内存
@override
void dispose() {
super.dispose();
// dispose 释放对象
}
}
library notfound;
export './state.dart';
export './controller.dart';
export './bindings.dart';
export './view.dart';
import 'package:get/get.dart';
class ProductState {
// title
final _title = "创作".obs;
set title(value) => this._title.value = value;
get title => this._title.value;
final _genText = "".obs;
set genText(value) => this._genText.value = value;
get genText => this._genText.value;
}
import 'dart:convert';
import 'package:chart/common/routers/routes.dart';
import 'package:chart/common/values/values.dart';
import 'package:chart/common/widgets/widgets.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'index.dart';
import 'widgets/widgets.dart';
class ProductPage extends GetView<ProductController> {
// class ChatNewPage extends GetView<ChatNewController> {
// 内容页
// Widget _buildView() {
// return HellowordWidget();
// }
// email的控制器
final TextEditingController emailController = TextEditingController();
// 密码的控制器
final TextEditingController passController = TextEditingController();
Widget _buildInputForm(Map<String, String> params) {
// var str = list['0'];
// list = json.decode(list);
ProductController c = Get.find();
return Container(
width: double.infinity,
// height: 164,
margin: EdgeInsets.only(top: 20.h),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"${params['firstLabel']} :",
style: TextStyle(
// rgba(94, 94, 94, 1.00)
fontSize: 16,
// fontWeight: FontWeight.bold,
height: 1.5,
textBaseline: TextBaseline.alphabetic,
color: Color.fromRGBO(94, 94, 94, 1)),
),
inputTextEdit(
controller: emailController,
keyboardType: TextInputType.text,
hintText: "${params['firstValue']}",
marginTop: 0,
// autofocus: true,
),
Text(
"${params['lastLabel']} :",
style: TextStyle(
// rgba(94, 94, 94, 1.00)
fontSize: 16,
// fontWeight: FontWeight.bold,
height: 1,
color: Color.fromRGBO(94, 94, 94, 1)),
),
// password input
inputTextEdit(
controller: passController,
keyboardType: TextInputType.text,
hintText: "${params['lastValue']}",
// isPassword: true,
),
// 注册、登录 横向布局
Container(
height: 44.h,
margin: EdgeInsets.only(top: 15.h),
child: btnFlatButtonWidget(
onPressed: () {
if (emailController.text.isNotEmpty &&
passController.text.isNotEmpty) {
String str =
"帮我写一篇${params['firstLabel']}${emailController.text} ${params['lastLabel']}包含${passController.text}${params['title']}";
c.handleGenText(str);
print("$str");
} else {
Get.snackbar("错误提示", "您的问题还没有填完", colorText: Colors.white);
}
},
gbColor: AppColors.primaryElement,
title: "生成",
),
),
// Spacer(),
// Fogot password
// Padding(
// padding: EdgeInsets.only(top: 8.0),
// child: TextButton(
// onPressed: controller.handleFogotPassword,
// child: Text(
// "Fogot password?",
// textAlign: TextAlign.center,
// style: TextStyle(
// color: AppColors.secondaryElementText,
// fontFamily: "Avenir",
// fontWeight: FontWeight.w400,
// fontSize: 16.sp,
// height: 1, // 设置下行高,否则字体下沉
// ),
// ),
// ),
// ),
],
),
);
}
@override
Widget build(BuildContext context) {
final c = Get.put(ProductController());
final title = Get.parameters['title'] as String;
final firstValue = Get.parameters['firstValue'] as String;
final firstLabel = Get.parameters['firstLabel'] as String;
final lastValue = Get.parameters['lastValue'] as String;
final lastLabel = Get.parameters['lastLabel'] as String;
// "title": title,
// firstValue: firstValue,
// lastLabel: lastLabel,
// lastValue: lastValue,
// lastLabel: lastLabel
return Obx(() => Scaffold(
appBar: transparentAppBar(
title: Text(
'${c.state.title}',
style: TextStyle(
color: AppColors.primaryElementText,
fontFamily: 'Montserrat',
fontSize: 18.sp,
fontWeight: FontWeight.w600,
),
),
leading: IconButton(
tooltip: '返回上一页',
icon: const Icon(
Icons.arrow_back,
color: AppColors.primaryElementText,
),
onPressed: () async {
// Get.back();
// Get.offAll(ApplicationPage());
// await Get.off(ApplicationPage());
Get.back();
// Get.toNamed(AppRoutes.Application);
// Navigator.of(context).pop();
//_nextPage(-1);
},
)),
body: SingleChildScrollView(
child: Container(
padding: EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"创作",
style: TextStyle(
fontSize: 16, fontWeight: FontWeight.bold, height: 1),
),
Text(
"您选择的模板是:",
style: TextStyle(
fontSize: 16, fontWeight: FontWeight.bold, height: 2),
),
Text(
'${title}',
style: TextStyle(
// rgba(94, 94, 94, 1.00)
fontSize: 16,
// fontWeight: FontWeight.bold,
height: 2,
color: Color.fromRGBO(94, 94, 94, 1)),
),
Text(
"您可以告诉闪文您想写的内容,例如:",
style: TextStyle(
fontSize: 16, fontWeight: FontWeight.bold, height: 2),
),
_buildInputForm({
"firstLabel": firstLabel,
"firstValue": firstValue,
"lastLabel": lastLabel,
"lastValue": lastValue,
"title": title,
}),
Text("${c.state.genText}")
],
)))
// body: _buildView(),
));
}
}
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../index.dart';
/// hellowrod
class HellowordWidget extends GetView<ProductController> {
@override
Widget build(BuildContext context) {
var count = 0.obs;
// ProductController c = Get.put(ProductController());
// ProductController c = Get.put(ProductController());
// initDataList
return Obx(() => Text("$count"));
// ProductController c = Get.put(ProductController());
// return
// ignore: unnecessary_null_comparison
// Obx(() => controller.state == null ? Container() : Container());
// Center(
// child: Obx(() => Text("controller.state.title")),
// );
}
}
library widgets;
export './helloword.dart';
......@@ -51,7 +51,7 @@ class SignInController extends GetxController {
UserLoginResponseEntity userProfile = await UserAPI.login(
params: params,
);
UserStore.to.saveProfile(userProfile);
// UserStore.to.saveProfile(userProfile);
Get.offAndToNamed(AppRoutes.Application);
}
......
......@@ -4,6 +4,10 @@ import 'package:chart/common/entities/entities.dart';
import 'package:chart/entity/plan_entity.dart';
import 'package:get/get.dart';
import '../../common/services/storage.dart';
import '../../common/store/user.dart';
import '../../common/values/storage.dart';
import '../../entity/user_entity.dart';
import 'index.dart';
class MainController extends GetxController {
......@@ -36,7 +40,13 @@ class MainController extends GetxController {
}
asyncLoadBannerData() async {
// state.bannerList = await NewsAPI.bannerList();
final token = StorageService.to.getString(STORAGE_USER_TOKEN_KEY);
if (token.isEmpty) {
IntegralEntity userInfo = await UserAPI.getUserIntegral();
await UserStore.to.getUserInfo(userInfo);
}
List<MessageEntity>? list = await NewsAPI.bannerList();
state.bannerList = constructList(3, list!);
......@@ -51,6 +61,8 @@ class MainController extends GetxController {
List<ClassifyDetialEntity>? _classFyList =
await NewsAPI.classFyDetialList({"id": _classFyId});
state.bannerPageDetail = _classFyList;
// /api/user/getUserIntegral
// bannerPageDetail
// state.categories = await NewsAPI.categories(
// cacheDisk: true,
......
......@@ -16,7 +16,7 @@ class MainState {
get newsPageList => _newsPageList.value;
void appendNewsPageList(NewsPageListResponseEntity value) {
if (_newsPageList.value != null) {
_newsPageList.value!.items?.addAll(value.items!.toList());
// _newsPageList.value!.items?.addAll(value.items!.toList());
}
}
......
......@@ -20,11 +20,11 @@ class DoctorAppBar extends StatelessWidget {
@override
Widget build(BuildContext context) {
UserModel userViewModel = Provider.of<UserModel>(context);
// UserModel userViewModel = Provider.of<UserModel>(context);
// final text = Provider.of<String>(context);
// _userModel = Provider.of<UserModel>(context);
// ${userViewModel.integralEntity?.username}
print(userViewModel.integralEntity);
// print(userViewModel.integralEntity);
return Container(
width: double.infinity,
child: Padding(
......@@ -38,7 +38,7 @@ class DoctorAppBar extends StatelessWidget {
children: [
// ignore: prefer_const_constructors
Text(
"Hi, ${userViewModel.integralEntity?.username}",
"Hi,32121",
// ignore: prefer_const_constructors
style: TextStyle(
color: Colors.white,
......
import 'package:chart/common/routers/routes.dart';
import 'package:flutter/material.dart';
import 'package:chart/common/values/values.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import '../../../common/store/user.dart';
import '../index.dart';
/// 分类导航
class NewsCategoriesWidget extends GetView<MainController> {
// NewsCategoriesWidget();
const NewsCategoriesWidget({super.key});
@override
Widget build(BuildContext context) {
......@@ -29,7 +31,7 @@ class NewsCategoriesWidget extends GetView<MainController> {
children: [
// ignore: prefer_const_constructors
Text(
"Hi, userViewModel.",
"Hi, ${UserStore.to.profile.username}",
// ignore: prefer_const_constructors
style: TextStyle(
color: Colors.white,
......@@ -46,8 +48,10 @@ class NewsCategoriesWidget extends GetView<MainController> {
],
),
GestureDetector(
onTap: () =>
{Navigator.of(context).pushNamed('/goods')},
onTap: () {
Get.toNamed(AppRoutes.PAY_LIST);
},
// {Navigator.of(context).pushNamed('/pay')},
child: Container(
height: 60.h,
width: 60.w,
......
......@@ -10,7 +10,7 @@ const kBackgroundColor = Color(0xffEFF2F7);
const List<Color> kCategoriesPrimaryColor = [
Color(0xffFFCA8C),
Color(0xff5DF9D3),
Color(0xff85E4FD),
Color(0xFF85E4FD),
Color(0xffB8ACFF)
];
......
This diff is collapsed.
......@@ -22,23 +22,23 @@ class NewsListWidget extends GetView<MainController> {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
// 图
InkWell(
onTap: () {
// ExtendedNavigator.rootNavigator.pushNamed(
// Routes.detailsPageRoute,
// arguments: DetailsPageArguments(item: item),
// );
},
child: SizedBox(
width: 121.w,
height: 121.w,
child: netImageCached(
item.thumbnail ?? "",
width: 121.w,
height: 121.w,
),
),
),
// InkWell(
// onTap: () {
// // ExtendedNavigator.rootNavigator.pushNamed(
// // Routes.detailsPageRoute,
// // arguments: DetailsPageArguments(item: item),
// // );
// },
// child: SizedBox(
// width: 121.w,
// height: 121.w,
// child: netImageCached(
// item.thumbnail ?? "",
// width: 121.w,
// height: 121.w,
// ),
// ),
// ),
// 右侧
SizedBox(
width: 194.w,
......@@ -49,7 +49,7 @@ class NewsListWidget extends GetView<MainController> {
Container(
margin: EdgeInsets.all(0),
child: Text(
item.author ?? "",
"item.author" ?? "",
style: TextStyle(
fontFamily: 'Avenir',
fontWeight: FontWeight.normal,
......@@ -69,7 +69,7 @@ class NewsListWidget extends GetView<MainController> {
child: Container(
margin: EdgeInsets.only(top: 10.w),
child: Text(
item.title ?? "",
"item.title" ?? "",
style: TextStyle(
fontFamily: 'Montserrat',
fontWeight: FontWeight.w500,
......@@ -95,7 +95,7 @@ class NewsListWidget extends GetView<MainController> {
maxWidth: 60.w,
),
child: Text(
item.category ?? "",
"item.category" ?? "",
style: TextStyle(
fontFamily: 'Avenir',
fontWeight: FontWeight.normal,
......@@ -115,7 +115,7 @@ class NewsListWidget extends GetView<MainController> {
maxWidth: 100.w,
),
child: Text(
'• ${duTimeLineFormat(item.addtime ?? DateTime(0))}',
'• ${duTimeLineFormat(DateTime(0))}',
style: TextStyle(
fontFamily: 'Avenir',
fontWeight: FontWeight.normal,
......
import 'package:chart/common/routers/routes.dart';
import 'package:chart/entity/plan_entity.dart';
import 'package:chart/pages/frame/notfound/index.dart';
import 'package:flutter/material.dart';
import 'package:chart/common/values/values.dart';
import 'package:flutter_chat_types/flutter_chat_types.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:card_swiper/card_swiper.dart';
......@@ -46,6 +49,7 @@ class SiperBannerWidget extends GetView<MainController> {
}
Widget _generateWidget(MessageEntity message, int idx, int index) {
final c = Get.put(ChatNewController());
return Container(
height: 70.0,
width: double.infinity,
......@@ -93,6 +97,14 @@ class SiperBannerWidget extends GetView<MainController> {
// Navigator.of(context).pop({'id': "1"})
// print("${message.question}")
},
child: InkWell(
onTap: () {
// message.question
Get.toNamed(
"${AppRoutes.CHAT_PAGE}?question=${message.question}");
c.sendMessage(PartialText(text: "${message.question}"));
},
child: Row(
children: [
Container(
......@@ -154,8 +166,10 @@ class SiperBannerWidget extends GetView<MainController> {
),
],
),
),
)),
));
),
);
}
}
......
import 'package:get/get.dart';
import 'controller.dart';
class UserDetailBinding implements Bindings {
@override
void dependencies() {
Get.lazyPut<UserDetailController>(() => UserDetailController());
}
}
import 'package:chart/common/apis/apis.dart';
import 'package:chart/common/entities/entities.dart';
import 'package:get/get.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'index.dart';
class UserDetailController extends GetxController {
UserDetailController();
/// UI 组件
final RefreshController refreshController = RefreshController(
initialRefresh: true,
);
/// 响应式成员变量
final state = CategoryState();
/// 成员变量
String categoryCode = '';
int curPage = 1;
int pageSize = 10;
int total = 0;
/// 事件
void onRefresh() {
fetchNewsList(isRefresh: true).then((_) {
refreshController.refreshCompleted(resetFooterState: true);
}).catchError((_) {
refreshController.refreshFailed();
});
}
void onLoading() {
if (state.newsList.length < total) {
fetchNewsList().then((_) {
refreshController.loadComplete();
}).catchError((_) {
refreshController.loadFailed();
});
} else {
refreshController.loadNoData();
}
}
// 方法
// 拉取数据
Future<void> fetchNewsList({bool isRefresh = false}) async {
var result =
await NewsAPI.newsPageList({'page': curPage, "size": pageSize});
if (isRefresh == true) {
curPage = 1;
total = result.total!;
state.newsList.clear();
} else {
curPage++;
}
state.newsList.addAll(result.records!);
print("${state.newsList.length}");
}
/// 生命周期
///dispose 释放内存
@override
void dispose() {
super.dispose();
// dispose 释放对象
refreshController.dispose();
}
}
library category;
export './state.dart';
export './controller.dart';
export './bindings.dart';
export './view.dart';
import 'package:chart/common/entities/entities.dart';
import 'package:get/get.dart';
class CategoryState {
// 新闻翻页
RxList<NewsItem> newsList = <NewsItem>[].obs;
}
This diff is collapsed.
import 'package:chart/utils/common_util.dart';
import 'package:flutter/material.dart';
import 'package:chart/common/entities/entities.dart';
import 'package:chart/common/utils/utils.dart';
import 'package:chart/common/values/values.dart';
import 'package:chart/common/widgets/widgets.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:glassmorphism/glassmorphism.dart';
// Widget newsListItem(NewsItem item) {
// print('itemitemitemitemitemitemitemitemitem${item}');
// return Container(
// height: 161.h,
// padding: EdgeInsets.all(20.w),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: <Widget>[
// // 图
// InkWell(
// onTap: () {
// // ExtendedNavigator.rootNavigator.pushNamed(
// // Routes.detailsPageRoute,
// // arguments: DetailsPageArguments(item: item),
// // );
// },
// child: netImageCached(
// item.thumbnail ?? "",
// width: 121.w,
// height: 121.w,
// ),
// ),
// // 右侧
// SizedBox(
// width: 194.w,
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: <Widget>[
// // 作者
// Container(
// margin: EdgeInsets.all(0),
// child: Text(
// "item.author" ?? "",
// style: TextStyle(
// fontFamily: 'Avenir',
// fontWeight: FontWeight.normal,
// color: AppColors.thirdElementText,
// fontSize: 14.sp,
// height: 1,
// ),
// ),
// ),
// // 标题
// InkWell(
// onTap: () {
// // ExtendedNavigator.rootNavigator.pushNamed(
// // Routes.detailsPageRoute,
// // arguments: DetailsPageArguments(item: item),
// // );
// },
// child: Container(
// margin: EdgeInsets.only(top: 10.h),
// child: Text(
// "item.title " ?? "",
// style: TextStyle(
// fontFamily: 'Montserrat',
// fontWeight: FontWeight.w500,
// color: AppColors.primaryText,
// fontSize: 16.sp,
// height: 1,
// ),
// overflow: TextOverflow.clip,
// maxLines: 3,
// ),
// ),
// ),
// // Spacer
// Spacer(),
// // 一行 3 列
// Container(
// child: Row(
// crossAxisAlignment: CrossAxisAlignment.center,
// children: <Widget>[
// // 分类
// ConstrainedBox(
// constraints: BoxConstraints(
// maxWidth: 60.w,
// ),
// child: Text(
// "item.category" ?? "",
// style: TextStyle(
// fontFamily: 'Avenir',
// fontWeight: FontWeight.normal,
// color: AppColors.secondaryElementText,
// fontSize: 14.sp,
// height: 1,
// ),
// overflow: TextOverflow.clip,
// maxLines: 1,
// ),
// ),
// // 添加时间
// Container(
// width: 15.w,
// ),
// ConstrainedBox(
// constraints: BoxConstraints(
// maxWidth: 100.w,
// ),
// child: Text(
// '• ${duTimeLineFormat(DateTime(0) ?? DateTime(0))}',
// // "item.addtime"
// style: TextStyle(
// fontFamily: 'Avenir',
// fontWeight: FontWeight.normal,
// color: AppColors.thirdElementText,
// fontSize: 14.sp,
// height: 1,
// ),
// overflow: TextOverflow.clip,
// maxLines: 1,
// ),
// ),
// // 更多
// Spacer(),
// InkWell(
// child: Icon(
// Icons.more_horiz,
// color: AppColors.primaryText,
// size: 24.sp,
// ),
// onTap: () {},
// ),
// ],
// ),
// ),
// ],
// ),
// ),
// ],
// ),
// );
// }
Widget newsListItem(NewsItem item) {
// double textScaleFactor = MediaQuery.textScaleFactorOf(context);
return GlassmorphicContainer(
height: 300.h,
width: double.infinity,
// flex: 1,
borderRadius: 16,
padding: EdgeInsets.only(bottom: 16),
blur: 14,
alignment: Alignment.bottomCenter,
border: 2,
linearGradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFF0FFFF).withOpacity(0.2),
Color(0xFF0FFFF).withOpacity(0.2),
],
),
margin: EdgeInsets.only(bottom: 16.h),
borderGradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFF0FFFF).withOpacity(1),
Color(0xFFFFFFF),
Color(0xFF0FFFF).withOpacity(1),
],
),
child: Column(key: UniqueKey(),
// mainAxisAlignment: MainAxisAlignment.spaceAround,
// ignore: prefer_const_literals_to_create_immutables
children: [
// ignore: prefer_const_constructors
Container(
// color: Colors.red,
height: 50,
width: double.infinity,
padding: EdgeInsets.symmetric(horizontal: 16),
child: Text(
"${item.question}",
style: const TextStyle(
color: Colors.white,
height: 2,
fontSize: 20,
fontWeight: FontWeight.w600),
)),
// ignore: prefer_const_constructors
Container(
// color: Colors.red,
padding: EdgeInsets.symmetric(horizontal: 16),
width: double.infinity,
height: 150,
child: SingleChildScrollView(
child: Text(
"${item.answer}",
style: TextStyle(color: Colors.white, fontSize: 12
// height: 0.8
),
// height: 2,
// fontSize: 20,
maxLines: 7,
),
),
),
]));
}
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../index.dart';
import 'widgets.dart';
class NewsPageList extends StatefulWidget {
NewsPageList({Key? key}) : super(key: key);
@override
_NewsPageListState createState() => _NewsPageListState();
}
class _NewsPageListState extends State<NewsPageList>
with AutomaticKeepAliveClientMixin {
@override
bool get wantKeepAlive => true;
final controller = Get.find<UserDetailController>();
@override
Widget build(BuildContext context) {
super.build(context);
return GetX<UserDetailController>(
init: controller,
builder: (controller) => SmartRefresher(
enablePullUp: true,
controller: controller.refreshController,
onRefresh: controller.onRefresh,
onLoading: controller.onLoading,
child: CustomScrollView(
slivers: [
SliverPadding(
padding: EdgeInsets.symmetric(
vertical: 16.w,
horizontal: 16.w,
),
sliver: SliverList(
delegate: SliverChildBuilderDelegate(
(content, index) {
var item = controller.state.newsList[index];
return newsListItem(item);
},
childCount: controller.state.newsList.length,
),
),
),
],
),
),
);
}
}
library widgets;
export 'news_page_list.dart';
export 'news_item.dart';
......@@ -27,22 +27,22 @@ import 'package:fluttertoast/fluttertoast.dart';
// import 'package:path_provider/path_provider.dart';
// import 'package:glassmorphism/glassmorphism.dart';
final _user = const types.User(
id: '82091008-a484-4a89-ae75-a22bf8d6f3ac',
);
final _user1 = const types.User(
id: '82091008-a4aa-4a89-ae75-a22bf8d6f3aa',
);
final receiveUser = const types.User(
id: '82091008-a484-4a89-ae75-a22bf8d6f3aa',
firstName: "GPT",
lastName: '大师',
imageUrl:
"https://imgb15.photophoto.cn/20201124/jiqirentupian-39852917_3.jpg"
// imageUrl: "assets/images/300.jpg",
);
// final _user = const types.User(
// id: '82091008-a484-4a89-ae75-a22bf8d6f3ac',
// );
// final _user1 = const types.User(
// id: '82091008-a4aa-4a89-ae75-a22bf8d6f3aa',
// );
// final receiveUser = const types.User(
// id: '82091008-a484-4a89-ae75-a22bf8d6f3aa',
// firstName: "GPT",
// lastName: '大师',
// imageUrl:
// "https://imgb15.photophoto.cn/20201124/jiqirentupian-39852917_3.jpg"
// // imageUrl: "assets/images/300.jpg",
// );
class ChatPage extends StatefulWidget {
const ChatPage({Key? key}) : super(key: key);
......
......@@ -228,19 +228,6 @@ class HomePageState extends State<HomePage> {
Navigator.of(context).pushNamed('/chat');
},
),
// BottomNavigationBar(
// // unselectedLabelStyle: TextStyle(color: Colors.black12),
// // selectedIconTheme: AppColors.darkSurfaceColor,
// selectedItemColor: AppColors.greenColor,
// onTap: _onItemTapped,
// currentIndex: _selectedIndex,
// items: const [
// BottomNavigationBarItem(icon: Icon(Icons.home), label: "首页"),
// BottomNavigationBarItem(icon: Icon(Icons.business), label: "广场"),
// BottomNavigationBarItem(icon: Icon(Icons.school), label: "应用市场"),
// BottomNavigationBarItem(icon: Icon(Icons.school), label: "我的"),
// ],
// ),
floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
));
}
......
import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:chart/pages/home/home_page.dart';
// import 'package:sail/pages/404/not_find_page.dart';
import 'package:chart/pages/login/login_page.dart';
import 'package:chart/pages/chat/chat_page.dart';
import 'package:chart/pages/goods/goods_page.dart';
import 'package:chart/pages/login/msm_page.dart';
// import 'package:/chart/pages/goods/goods_page.dart';
// import 'package:sail/pages/plan/plan_page.dart';
// import 'package:sail/pages/server_list.dart';
// import 'package:sail/pages/webview_widget.dart';
// import 'package:chart/pages/home/main_page.dart';
// import 'dart:convert';
// import 'package:fluro/fluro.dart';
// import 'package:flutter/material.dart';
// import 'package:chart/pages/home/home_page.dart';
// // import 'package:sail/pages/404/not_find_page.dart';
// import 'package:chart/pages/login/login_page.dart';
// import 'package:chart/pages/chat/chat_page.dart';
// import 'package:chart/pages/goods/goods_page.dart';
// import 'package:chart/pages/login/msm_page.dart';
// // import 'package:/chart/pages/goods/goods_page.dart';
// // import 'package:sail/pages/plan/plan_page.dart';
// // import 'package:sail/pages/server_list.dart';
// // import 'package:sail/pages/webview_widget.dart';
// // import 'package:chart/pages/home/main_page.dart';
// // import 'dart:convert';
/// 入口
// Handler rootHandler = Handler(
// /// 入口
// // Handler rootHandler = Handler(
// // handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
// // return const MainPage();
// // });
// Handler msgCodeHandler = Handler(
// handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
// return const MainPage();
// return const MsmPage();
// });
Handler msgCodeHandler = Handler(
handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
return const MsmPage();
});
/// 登录页
Handler loginHandler = Handler(
handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
return const LoginPage();
});
/// 首页
Handler homeHandler = Handler(
handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
return const HomePage();
});
/// goods
Handler goodsHandler = Handler(
handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
return const GoodsPage();
});
/// 404页面
// Handler notFindHandler = Handler(
// /// 登录页
// Handler loginHandler = Handler(
// handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
// return const NotFindPage();
// return const LoginPage();
// });
// 聊天
Handler chatHandle = Handler(
handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
return const ChatPage();
});
// /// 首页
// Handler homeHandler = Handler(
// handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
// return const HomePage();
// });
/// 服务器节点页
// Handler serverListHandler = Handler(
// /// goods
// Handler goodsHandler = Handler(
// handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
// return const ServerListPage();
// return const GoodsPage();
// });
/// WebView页
// Handler webViewHandler = Handler(
// /// 404页面
// // Handler notFindHandler = Handler(
// // handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
// // return const NotFindPage();
// // });
// // 聊天
// Handler chatHandle = Handler(
// handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
// var title = jsonDecode(parameters["titleName"]!.first);
// var url = jsonDecode(parameters["url"]!.first);
// return WebViewWidget(name: title, url: url);
// return const ChatPage();
// });
// /// 服务器节点页
// // Handler serverListHandler = Handler(
// // handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
// // return const ServerListPage();
// // });
// /// WebView页
// // Handler webViewHandler = Handler(
// // handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
// // var title = jsonDecode(parameters["titleName"]!.first);
// // var url = jsonDecode(parameters["url"]!.first);
// // return WebViewWidget(name: title, url: url);
// // });
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment