Parcourir la source

[new]增加首页界面样板显示

zk il y a 1 an
Parent
commit
03d0501991

BIN
assets/images/bg_audio_todo_popup.webp


BIN
assets/images/bg_home_quick_audio.webp


BIN
assets/images/icon_add_talk.webp


BIN
assets/images/icon_agent_checked.webp


BIN
assets/images/icon_agent_un_check.webp


+ 8 - 0
assets/string/base/string.xml

@@ -6,4 +6,12 @@
     <string name="home_go_login">立即登录</string>
     <string name="home_talk_record">谈话记录</string>
     <string name="home_talk_see_all">查看全部</string>
+    <string name="home_talk_audio">谈话录音</string>
+    <string name="home_talk_quick_audio">快速录音谈话内容</string>
+    <string name="home_talk_example">示例</string>
+    <string name="home_talk_todo_title">待办事项</string>
+    <string name="home_talk_thinking">小思路听</string>
+    <string name="home_talk_todo1">想找更多待办?查看</string>
+    <string name="home_talk_todo2">全部待办</string>
+    <string name="home_popup_tips_txt">当前有未完成录音,\n快来处理</string>
 </resources>

+ 3 - 1
lib/main.dart

@@ -2,6 +2,7 @@ import 'package:electronic_assistant/resource/string_source.dart';
 import 'package:electronic_assistant/router/app_pages.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter_screenutil/flutter_screenutil.dart';
+import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
 import 'package:get/get.dart';
 import 'package:get/get_navigation/src/root/get_material_app.dart';
 
@@ -30,9 +31,10 @@ class MyApp extends StatelessWidget {
       initialRoute: RoutePath.splash,
       initialBinding: AppBinding(),
       theme: ThemeData(
-        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
         useMaterial3: true,
       ),
+      navigatorObservers: [FlutterSmartDialog.observer],
+      builder: FlutterSmartDialog.init(),
       translations: StringResource(),
       // 你的翻译
       locale: const Locale('zh', 'CN'),

+ 369 - 102
lib/module/home/view.dart

@@ -3,14 +3,19 @@ import 'package:electronic_assistant/resource/assets.gen.dart';
 import 'package:electronic_assistant/resource/colors.gen.dart';
 import 'package:electronic_assistant/resource/string.gen.dart';
 import 'package:electronic_assistant/utils/expand.dart';
+import 'package:electronic_assistant/utils/toast_util.dart';
+import 'package:flutter/gestures.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter_screenutil/flutter_screenutil.dart';
+import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
 import 'package:get/get.dart';
 
 import 'controller.dart';
 
 class HomePage extends BasePage<HomePageController> {
-  const HomePage({super.key});
+  HomePage({super.key});
+
+  BuildContext? todoTargetContext;
 
   @override
   Widget? buildBody(BuildContext context) {
@@ -29,64 +34,18 @@ class HomePage extends BasePage<HomePageController> {
               Expanded(
                   child: CustomScrollView(
                 slivers: [
-                  SliverToBoxAdapter(
-                    child: Column(
-                      children: [
-                        SizedBox(height: 7.h),
-                        Padding(
-                          padding: const EdgeInsets.symmetric(horizontal: 12).w,
-                          child: Row(
-                            crossAxisAlignment: CrossAxisAlignment.center,
-                            children: [
-                              Text(StringName.homeTalkRecord.tr,
-                                  style: TextStyle(
-                                      fontWeight: FontWeight.bold,
-                                      fontSize: 17.sp,
-                                      color: ColorName.primaryTextColor)),
-                              const Spacer(),
-                              GestureDetector(
-                                onTap: () {},
-                                child: Row(
-                                  crossAxisAlignment: CrossAxisAlignment.center,
-                                  children: [
-                                    Text(
-                                      StringName.homeTalkSeeAll.tr,
-                                      style: TextStyle(
-                                          fontSize: 13.sp,
-                                          color: ColorName.secondaryTextColor),
-                                    ),
-                                    SizedBox(
-                                        width: 16.w,
-                                        height: 16.w,
-                                        child: Assets.images.iconHomeTalkArrow
-                                            .image()),
-                                  ],
-                                ),
-                              )
-                            ],
-                          ),
-                        ),
-                        SizedBox(height: 12.h),
-                      ],
-                    ),
-                  ),
-                  SliverList(
-                    delegate: SliverChildBuilderDelegate(
-                      (context, index) {
-                        return ListTile(
-                          title: Text('Item $index'),
-                        );
-                      },
-                      childCount: 20, // 列表项的数量
-                    ),
-                  ),
+                  buildTalkRecordTitle(),
                   SliverToBoxAdapter(
                     child: Container(
-                      padding: EdgeInsets.all(16),
-                      color: Colors.green,
-                      child: Text('尾部', style: TextStyle(color: Colors.white)),
+                      height: 0.3111.sw,
+                      margin: EdgeInsets.only(bottom: 15.h),
+                      child: buildTalkRecord(),
                     ),
                   ),
+                  buildTalkTodoTitle(),
+                  SliverAnimatedList(
+                      itemBuilder: _buildTodoItem, initialItemCount: 20),
+                  buildSeeMoreView(),
                 ],
               ))
             ],
@@ -96,61 +55,120 @@ class HomePage extends BasePage<HomePageController> {
     );
   }
 
-  Row buildOperationBar() {
-    return Row(children: [
-      GestureDetector(
-        onTap: () {},
-        child: Row(
-          children: [
-            SizedBox(
-                width: 0.1.sw,
-                height: 0.1.sw,
-                child: Assets.images.iconHomeLogged.image()),
-            SizedBox(width: 8.w),
-            Text(StringName.homeGoLogin.tr,
-                style: TextStyle(
-                    fontWeight: FontWeight.bold,
-                    fontSize: 15.sp,
-                    color: ColorName.primaryTextColor))
-          ],
+  SliverToBoxAdapter buildSeeMoreView() {
+    return SliverToBoxAdapter(
+      child: Container(
+        alignment: Alignment.center,
+        padding: const EdgeInsets.only(top: 12, bottom: 36).w,
+        child: RichText(
+          text: TextSpan(
+            text: StringName.homeTalkTodo1.tr,
+            style:
+                TextStyle(color: ColorName.secondaryTextColor, fontSize: 12.sp),
+            children: <TextSpan>[
+              TextSpan(
+                  text: StringName.homeTalkTodo2.tr,
+                  style:
+                      TextStyle(color: ColorName.colorPrimary, fontSize: 12.sp),
+                  recognizer: TapGestureRecognizer()
+                    ..onTap = () {
+                      ToastUtil.showToast('点击了全部');
+                    }),
+            ],
+          ),
         ),
       ),
-      const Spacer(),
-      GestureDetector(
-          child: DecoratedBox(
-              decoration: BoxDecoration(
-                color: Colors.white,
-                borderRadius: BorderRadius.circular(16),
+    );
+  }
+
+  SliverToBoxAdapter buildTalkTodoTitle() {
+    return SliverToBoxAdapter(
+        child: Column(
+      children: [
+        SizedBox(height: 9.w),
+        buildTitle(StringName.homeTalkTodoTitle.tr, () {
+          ToastUtil.showToast('待办事项 查看全部');
+        }),
+        SizedBox(height: 12.w)
+      ],
+    ));
+  }
+
+  SliverToBoxAdapter buildTalkRecordTitle() {
+    return SliverToBoxAdapter(
+      child: Column(
+        children: [
+          SizedBox(height: 7.w),
+          buildTitle(StringName.homeTalkRecord.tr, () {
+            ToastUtil.showToast('谈话记录 查看全部');
+          }),
+          SizedBox(height: 12.w)
+        ],
+      ),
+    );
+  }
+
+  Row buildOperationBar() {
+    return Row(children: [buildGoLogin(), const Spacer(), buildGoStore()]);
+  }
+
+  GestureDetector buildGoStore() {
+    return GestureDetector(
+        child: DecoratedBox(
+            decoration: BoxDecoration(
+              color: Colors.white,
+              borderRadius: BorderRadius.circular(16),
+            ),
+            child: Padding(
+              padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2).w,
+              child: Row(
+                crossAxisAlignment: CrossAxisAlignment.center,
+                children: [
+                  SizedBox(
+                      width: 28.w,
+                      height: 28.w,
+                      child: Assets.images.iconCharge.image()),
+                  SizedBox(width: 4.w),
+                  SizedBox(
+                      width: 28.w, child: Assets.images.iconChargeTxt.image()),
+                  SizedBox(
+                      width: 12.w,
+                      height: 12.w,
+                      child: Assets.images.iconChargeArrow.image()),
+                ],
               ),
-              child: Padding(
-                padding:
-                    const EdgeInsets.symmetric(horizontal: 8, vertical: 2).w,
-                child: Row(
-                  crossAxisAlignment: CrossAxisAlignment.center,
-                  children: [
-                    SizedBox(
-                        width: 28.w,
-                        height: 28.w,
-                        child: Assets.images.iconCharge.image()),
-                    SizedBox(width: 4.w),
-                    SizedBox(
-                        width: 28.w,
-                        child: Assets.images.iconChargeTxt.image()),
-                    SizedBox(
-                        width: 12.w,
-                        height: 12.w,
-                        child: Assets.images.iconChargeArrow.image()),
-                  ],
-                ),
-              )),
-          onTap: () {})
-    ]);
+            )),
+        onTap: () {
+          ToastUtil.showToast('GoStore');
+        });
+  }
+
+  GestureDetector buildGoLogin() {
+    return GestureDetector(
+      onTap: () {
+        ToastUtil.showToast('GoLogin');
+      },
+      child: Row(
+        children: [
+          SizedBox(
+              width: 0.1.sw,
+              height: 0.1.sw,
+              child: Assets.images.iconHomeLogged.image()),
+          SizedBox(width: 8.w),
+          Text(StringName.homeGoLogin.tr,
+              style: TextStyle(
+                  fontWeight: FontWeight.bold,
+                  fontSize: 15.sp,
+                  color: ColorName.primaryTextColor))
+        ],
+      ),
+    );
   }
 
   Container buildTopGradient() {
     return Container(
         width: 1.sw,
-        height: 0.4444444444444444.sw,
+        height: 112.h,
         decoration: BoxDecoration(
           gradient: LinearGradient(
             colors: ['#E8EBFF'.toColor(), '#00E8EBFF'.toColor()],
@@ -169,4 +187,253 @@ class HomePage extends BasePage<HomePageController> {
           height: double.infinity,
         ));
   }
+
+  Widget buildTalkRecord() {
+    return SizedBox(
+      width: 1.sw,
+      child: CustomScrollView(
+        scrollDirection: Axis.horizontal,
+        slivers: [
+          SliverToBoxAdapter(child: SizedBox(width: 12.w)),
+          buildGoRecordView(),
+          SliverAnimatedList(itemBuilder: _buildTalkItem, initialItemCount: 10)
+        ],
+      ),
+    );
+  }
+
+  SliverToBoxAdapter buildGoRecordView() {
+    return SliverToBoxAdapter(
+        child: GestureDetector(
+      onTap: () {
+        showUnfinishedRecordPopup();
+      },
+      child: Container(
+        margin: EdgeInsets.only(right: 8.w),
+        decoration: BoxDecoration(
+          color: Colors.white,
+          border: Border.all(color: '#EBEBFF'.toColor(), width: 1),
+          borderRadius: BorderRadius.circular(8.0),
+        ),
+        child: SizedBox(
+          width: 100.w,
+          height: double.infinity,
+          child: Stack(
+            children: [
+              Positioned(
+                right: 0,
+                bottom: 0,
+                child: SizedBox(
+                  width: 48.w,
+                  child: Assets.images.bgHomeQuickAudio.image(),
+                ),
+              ),
+              Positioned.fill(
+                  child: Align(
+                alignment: Alignment.center,
+                child: Column(
+                  children: [
+                    SizedBox(height: 20.h),
+                    SizedBox(
+                        width: 32.w,
+                        height: 32.w,
+                        child: Assets.images.iconAddTalk.image()),
+                    SizedBox(height: 6.h),
+                    Text(StringName.homeTalkAudio.tr,
+                        style: TextStyle(
+                            fontSize: 14.sp,
+                            color: ColorName.colorPrimary,
+                            fontWeight: FontWeight.bold)),
+                    Builder(builder: (context) {
+                      todoTargetContext = context;
+                      return Text(StringName.homeTalkQuickAudio.tr,
+                          style: TextStyle(
+                              fontSize: 10.sp,
+                              color: ColorName.secondaryTextColor));
+                    })
+                  ],
+                ),
+              )),
+            ],
+          ),
+        ),
+      ),
+    ));
+  }
+
+  Widget _buildTodoItem(
+      BuildContext context, int index, Animation<double> animation) {
+    return Container(
+      padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 17).w,
+      margin: const EdgeInsets.only(left: 12, right: 12, bottom: 8).w,
+      decoration: BoxDecoration(
+        color: Colors.white,
+        borderRadius: BorderRadius.circular(8),
+      ),
+      child: Row(
+        crossAxisAlignment: CrossAxisAlignment.center,
+        children: [
+          SizedBox(
+              width: 20.w,
+              height: 20.w,
+              child: Assets.images.iconAgentChecked.image()),
+          SizedBox(width: 8.w),
+          Text('今天要完成某项任务',
+              style: TextStyle(
+                  fontSize: 15.sp,
+                  fontWeight: FontWeight.bold,
+                  color: ColorName.primaryTextColor)),
+          const Spacer(),
+          Container(
+            decoration: BoxDecoration(
+              gradient: LinearGradient(
+                colors: ['#9075FF'.toColor(), '#4366FF'.toColor()],
+                stops: const [0.3, 1.0],
+              ),
+              borderRadius: BorderRadius.circular(6),
+            ),
+            padding: const EdgeInsets.symmetric(horizontal: 9, vertical: 4).w,
+            child: Text(
+              StringName.homeTalkThinking.tr,
+              style: TextStyle(fontSize: 13.sp, color: ColorName.white),
+            ),
+          )
+        ],
+      ),
+    );
+  }
+
+  Widget _buildTalkItem(
+      BuildContext context, int index, Animation<double> animation) {
+    return Container(
+        width: 258.w,
+        margin: EdgeInsets.only(right: 8.w),
+        decoration: BoxDecoration(
+          color: Colors.white,
+          border: Border.all(color: '#F0F0F0'.toColor(), width: 1),
+          borderRadius: BorderRadius.circular(8),
+        ),
+        height: double.infinity,
+        padding: EdgeInsets.symmetric(horizontal: 12.w),
+        child: Column(
+          mainAxisAlignment: MainAxisAlignment.center,
+          crossAxisAlignment: CrossAxisAlignment.start,
+          children: [
+            Row(
+              children: [
+                Container(
+                    padding: const EdgeInsets.symmetric(horizontal: 6).w,
+                    decoration: BoxDecoration(
+                      color: '#DFE4FC'.toColor(),
+                      borderRadius: BorderRadius.circular(4),
+                    ),
+                    child: Text(
+                      StringName.homeTalkExample.tr,
+                      style: TextStyle(
+                          fontSize: 12.sp, color: ColorName.colorPrimary),
+                    )),
+                SizedBox(width: 6.w),
+                Text('与吴总张总沟通活动策划',
+                    style: TextStyle(
+                        fontSize: 15.sp,
+                        color: ColorName.colorPrimary,
+                        fontWeight: FontWeight.bold))
+              ],
+            ),
+            SizedBox(height: 5.h),
+            Text(
+                style: TextStyle(
+                    fontSize: 12.sp, color: ColorName.secondaryTextColor),
+                overflow: TextOverflow.ellipsis,
+                maxLines: 2,
+                '这个群,现在由我管理。目的是把你们训练成一个个社会高薪人士,从本周起,已经个个社会高薪人士,从本周起,已经个个社会高薪人士,从本周起,已经'),
+            SizedBox(height: 8.h),
+            Row(
+              crossAxisAlignment: CrossAxisAlignment.center,
+              children: [
+                Text('1m12s',
+                    style: TextStyle(
+                        fontSize: 12.sp, color: ColorName.tertiaryTextColor)),
+                SizedBox(width: 6.w),
+                Container(
+                    width: 1, height: 9, color: ColorName.tertiaryTextColor),
+                SizedBox(width: 6.w),
+                Text('2024-04-15 10:04',
+                    style: TextStyle(
+                        fontSize: 12.sp, color: ColorName.tertiaryTextColor))
+              ],
+            )
+          ],
+        ));
+  }
+
+  Widget buildTitle(String titleName, VoidCallback onTap) {
+    return Padding(
+      padding: const EdgeInsets.symmetric(horizontal: 12).w,
+      child: Row(
+        crossAxisAlignment: CrossAxisAlignment.center,
+        children: [
+          Text(titleName,
+              style: TextStyle(
+                  fontWeight: FontWeight.bold,
+                  fontSize: 17.sp,
+                  color: ColorName.primaryTextColor)),
+          const Spacer(),
+          GestureDetector(
+            onTap: onTap,
+            child: Padding(
+              padding: const EdgeInsets.symmetric(vertical: 6).w,
+              child: Row(
+                crossAxisAlignment: CrossAxisAlignment.center,
+                children: [
+                  Text(
+                    StringName.homeTalkSeeAll.tr,
+                    style: TextStyle(
+                        fontSize: 13.sp, color: ColorName.secondaryTextColor),
+                  ),
+                  SizedBox(
+                      width: 16.w,
+                      height: 16.w,
+                      child: Assets.images.iconHomeTalkArrow.image()),
+                ],
+              ),
+            ),
+          )
+        ],
+      ),
+    );
+  }
+
+  attachDialog(BuildContext? context, Alignment alignment) {
+    SmartDialog.showAttach(
+      targetContext: context,
+      alignment: alignment,
+      animationType: SmartAnimationType.fade,
+      clickMaskDismiss: true,
+      maskColor: Colors.transparent,
+      bindPage: true,
+      builder: (_) => Padding(
+        padding: const EdgeInsets.only(top: 7).h,
+        child: Stack(
+          alignment: Alignment.topCenter,
+          children: [
+            SizedBox(
+                width: 146.w,
+                height: 66.w,
+                child: Assets.images.bgAudioTodoPopup.image()),
+            Container(
+                alignment: Alignment.center,
+                padding: const EdgeInsets.only(top: 17).w,
+                width: 146.w,
+                child: Text(StringName.homePopupTipsTxt.tr,
+                    style: TextStyle(fontSize: 14.sp, color: Colors.white)))
+          ],
+        ),
+      ),
+    );
+  }
+
+  void showUnfinishedRecordPopup() {
+    attachDialog(todoTargetContext, Alignment.bottomRight);
+  }
 }

+ 1 - 1
lib/module/main/view.dart

@@ -14,7 +14,7 @@ class MainTabPage extends BasePage<MainController> {
   MainTabPage({super.key});
 
   final pages = [
-    const HomePage(),
+    HomePage(),
     const FilesPage(),
   ];
 

+ 7 - 6
lib/module/splash/view.dart

@@ -9,17 +9,18 @@ import '../../router/app_pages.dart';
 class SplashPage extends BasePage {
   const SplashPage({super.key});
 
-  final splashDelayedTime = 2;
+  final splashDelayedTime = 1;
 
   @override
   Widget? buildBody(BuildContext context) {
     Timer(Duration(seconds: splashDelayedTime), () {
-      Get.toNamed(RoutePath.mainTab);
+      Get.offNamed(RoutePath.mainTab);
     });
     return GestureDetector(
-        child: Text('启屏页'),
-        onTap: () {
-          Get.toNamed(RoutePath.mainTab);
-        });
+        child: Center(
+            child: Text(
+      '启屏页',
+      style: TextStyle(fontSize: 36),
+    )));
   }
 }

+ 2 - 0
lib/router/app_pages.dart

@@ -2,6 +2,7 @@ import 'package:electronic_assistant/module/main/controller.dart';
 import 'package:get/get.dart';
 
 import '../module/files/view.dart';
+import '../module/home/controller.dart';
 import '../module/login/view.dart';
 import '../module/main/view.dart';
 import '../module/splash/view.dart';
@@ -26,6 +27,7 @@ class AppBinding extends Bindings {
   @override
   void dependencies() {
     lazyPut(() => MainController());
+    lazyPut(() => HomePageController());
   }
 
   void lazyPut<S>(InstanceBuilderCallback<S> builder) {

+ 0 - 0
lib/utils/popup_util.dart


+ 14 - 0
lib/utils/toast_util.dart

@@ -0,0 +1,14 @@
+import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
+
+class ToastUtil {
+  ToastUtil._();
+
+  static void showToast(String? msg,
+      {Duration? displayTime,
+      SmartToastType? displayType = SmartToastType.onlyRefresh}) {
+    if (msg != null) {
+      SmartDialog.showToast(msg,
+          displayType: displayType, displayTime: displayTime);
+    }
+  }
+}

+ 3 - 0
pubspec.yaml

@@ -48,6 +48,9 @@ dependencies:
   # 屏幕适配
   flutter_screenutil: ^5.9.3
 
+  # dialog
+  flutter_smart_dialog: ^4.9.8
+
 dev_dependencies:
   flutter_test:
     sdk: flutter

+ 2 - 3
string_resource_builder.dart

@@ -52,7 +52,8 @@ void generateStringResources() {
           final value = string.text;
           if (isBase) {
             final camelCaseName = toCamelCase(name);
-            buffer.writeln('  static const String $camelCaseName = \'$name\';');
+            buffer.writeln(
+                '  static const String $camelCaseName = \'$name\';// $value');
           }
           multiBuffer.writeln('      \'$name\': \'$value\',');
         }
@@ -80,8 +81,6 @@ void createDirectory(String path) {
   if (!directory.existsSync()) {
     directory.createSync(recursive: true);
     print('Directory created: $path');
-  } else {
-    print('Directory already exists: $path');
   }
 }