From 101d1a42fa3d8545f7e00edba783f77a4b0a4d69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=A4=A9?= Date: Mon, 24 Jul 2023 17:19:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=B8=AA=E4=BA=BA=E4=B8=AD?= =?UTF-8?q?=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main.dart | 2 +- lib/modules/account/account_page.dart | 193 +++++++++++++++++- lib/modules/application/application_page.dart | 6 +- lib/routes/app_pages.dart | 9 +- 4 files changed, 204 insertions(+), 6 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 9be90ac..036e1c3 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -57,7 +57,7 @@ class MyApp extends StatelessWidget { footerTriggerDistance: 150, child: Obx(() { return ConfigService.to.isGrayFilter.isTrue ? ColorFiltered( - colorFilter: ColorFilter.mode(Colors.white, BlendMode.color), + colorFilter: ColorFilter.mode(Colors.grey, BlendMode.color), child: app, ) : app; }), diff --git a/lib/modules/account/account_page.dart b/lib/modules/account/account_page.dart index bb91422..226f9e1 100644 --- a/lib/modules/account/account_page.dart +++ b/lib/modules/account/account_page.dart @@ -1,14 +1,203 @@ import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:news_getx/data/services/config.dart'; +import 'package:news_getx/data/services/user.dart'; +import 'package:news_getx/modules/widgets/button.dart'; +import 'package:news_getx/theme/app_colors.dart'; +import 'package:news_getx/theme/app_radii.dart'; import 'account_controller.dart'; class AccountPage extends GetView { const AccountPage({Key? key}) : super(key: key); + // 个人页面 头部 + Widget _buildUserHeader() { + return Container( + padding: EdgeInsets.all(20.w), + decoration: BoxDecoration( + color: AppColors.primaryBackground, + border: Border( + bottom: BorderSide( + color: AppColors.tabCellSeparator, + width: 2, + ), + )), + child: Column( + children: [ + // 头像 + Container( + height: 200.h, + alignment: Alignment.center, + child: ClipOval( + child: Image.asset( + "assets/images/account_header.png", + height: 108, + width: 108, + fit: BoxFit.fill, + ), + ), + ), + + // 文字 + Text( + UserService.to.profile.displayName ?? "unknown", + textAlign: TextAlign.center, + style: TextStyle( + color: AppColors.primaryText, + fontFamily: "Montserrat", + fontWeight: FontWeight.w400, + fontSize: 24.sp, + ), + ), + Container( + margin: EdgeInsets.only(top: 9.h, bottom: 16.h), + child: Text( + "@boltrogers", + textAlign: TextAlign.center, + style: TextStyle( + color: AppColors.primaryText, + fontFamily: "Avenir", + fontWeight: FontWeight.w400, + fontSize: 16.sp, + ), + ), + ), + + // 按钮 crossAxisAlignment会导致设置的宽度时效 + FlatButton( + height: 40.h, + width: double.infinity, + onPressed: () {}, + title: "Get Premium - \$9.99", + ), + ], + ), + ); + } + + // 列表项 + Widget _buildCell({ + required String title, + String? subTitle, + int? number, + bool hasArrow = false, + GestureTapCallback? onTap, + }) { + var rightWidget = [ + Text( + subTitle ?? number?.toString() ?? "", + textAlign: TextAlign.left, + style: TextStyle( + color: AppColors.primaryText, + fontFamily: "Montserrat", + fontWeight: FontWeight.w400, + fontSize: 18.sp, + ), + ), + ]; + + if (hasArrow) { + rightWidget.addAll([ + SizedBox(width: 10.w), + Icon(Icons.arrow_forward_ios), + ]); + } + + return GestureDetector( + onTap: onTap, + child: Container( + color: Colors.white, + height: 60.h, + padding: EdgeInsets.symmetric(horizontal: 20.w), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + title, + textAlign: TextAlign.left, + style: TextStyle( + color: AppColors.primaryText, + fontFamily: "Montserrat", + fontWeight: FontWeight.w400, + fontSize: 18.sp, + ), + ), + Row( + children: rightWidget, + ), + ], + ), + ), + ); + } + + Widget _divider10() { + return Divider( + color: AppColors.secondaryElement, + thickness: 10.h, + ); + } + @override Widget build(BuildContext context) { - - return Container(); + return SingleChildScrollView( + child: Column( + children: [ + _buildUserHeader(), + _divider10(), + _buildCell( + title: "Email", + subTitle: "boltrogers@gmail.com", + ), + _divider10(), + _buildCell( + title: "Favorite channels", + number: 12, + hasArrow: true, + ), + _buildCell( + title: "Bookmarks", + number: 294, + hasArrow: true, + ), + _buildCell( + title: "Popular categories", + number: 7, + hasArrow: true, + ), + _divider10(), + _buildCell( + title: "Newsletter", + hasArrow: true, + ), + _buildCell( + title: "Settings", + hasArrow: true, + onTap: () { + print("点击测试"); + }, + ), + _divider10(), + _buildCell( + title: "Switch Gray Filter", + hasArrow: true, + onTap: () { + ConfigService.to.changeGrayTheme(); + }, + ), + _buildCell( + title: "Log out", + hasArrow: true, + onTap: () { + print('Log out'); + UserService.to.onLogout(); + }, + ), + _divider10(), + ], + ), + ); } } diff --git a/lib/modules/application/application_page.dart b/lib/modules/application/application_page.dart index 9716a0e..2cf45c3 100644 --- a/lib/modules/application/application_page.dart +++ b/lib/modules/application/application_page.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:news_getx/modules/account/account_page.dart'; +import 'package:news_getx/modules/bookmarks/bookmarks_page.dart'; import 'package:news_getx/modules/category/category_page.dart'; import 'package:news_getx/modules/main/main_page.dart'; import 'package:news_getx/modules/widgets/app_bar.dart'; @@ -45,8 +47,8 @@ class ApplicationPage extends GetView { children: [ MainPage(), CategoryPage(), - Text('BookmarksPage'), - Text('AccountPage'), + BookmarksPage(), + AccountPage(), ], ); } diff --git a/lib/routes/app_pages.dart b/lib/routes/app_pages.dart index 5c6dce9..5cf3205 100644 --- a/lib/routes/app_pages.dart +++ b/lib/routes/app_pages.dart @@ -2,8 +2,10 @@ import 'package:flutter/cupertino.dart'; import 'package:get/get.dart'; import 'package:news_getx/middlewares/router_auth.dart'; import 'package:news_getx/middlewares/router_welcome.dart'; +import 'package:news_getx/modules/account/account_binding.dart'; import 'package:news_getx/modules/application/application_binding.dart'; import 'package:news_getx/modules/application/application_page.dart'; +import 'package:news_getx/modules/bookmarks/bookmarks_binding.dart'; import 'package:news_getx/modules/category/category_binding.dart'; import 'package:news_getx/modules/category/category_page.dart'; import 'package:news_getx/modules/main/main_binding.dart'; @@ -53,7 +55,12 @@ abstract class AppPages { name: AppRoutes.Application, page: () => ApplicationPage(), binding: ApplicationBinding(), - bindings: [MainBinding(), CategoryBinding()], + bindings: [ + MainBinding(), + CategoryBinding(), + BookmarksBinding(), + AccountBinding(), + ], middlewares: [ RouteAuthMiddleware(), ],