|
|
@@ -1,17 +1,10 @@
|
|
|
+import 'dart:io';
|
|
|
import 'package:flutter/material.dart';
|
|
|
-import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
import 'package:get/get.dart';
|
|
|
import 'package:keyboard/base/base_page.dart';
|
|
|
-import 'package:keyboard/resource/colors.gen.dart';
|
|
|
-import 'package:keyboard/resource/string.gen.dart';
|
|
|
import 'package:keyboard/router/app_pages.dart';
|
|
|
-import 'package:lottie/lottie.dart';
|
|
|
-
|
|
|
-import '../../resource/assets.gen.dart';
|
|
|
-import '../../utils/status_bar_util.dart';
|
|
|
-import '../../widget/app_lifecycle_widget.dart';
|
|
|
-import '../../widget/gradient_btn.dart';
|
|
|
-import '../../widget/top_bar.dart';
|
|
|
+import 'android/keyboard_tutorial_android_view.dart';
|
|
|
+import 'ios/keyboard_tutorial_ios_view.dart';
|
|
|
import 'keyboard_tutorial_controller.dart';
|
|
|
|
|
|
/// 键盘使用教程-引导页
|
|
|
@@ -40,201 +33,17 @@ class KeyboardTutorialPage extends BasePage<KeyboardTutorialController> {
|
|
|
|
|
|
@override
|
|
|
Widget buildBody(BuildContext context) {
|
|
|
- return Scaffold(
|
|
|
- backgroundColor: backgroundColor(),
|
|
|
- body: AppLifecycleWidget(
|
|
|
- onAppLifecycleCallback: (isForeground) async {
|
|
|
- // 步骤都做完了,则跳转去键盘引导页
|
|
|
- if (await controller.checkHasComplete()) {
|
|
|
- return;
|
|
|
- }
|
|
|
- // 未完成,则每次切换到前台时,重新检查设置,更新按钮状态
|
|
|
- if (isForeground) {
|
|
|
- controller.checkSetting();
|
|
|
- }
|
|
|
- },
|
|
|
- child: Stack(
|
|
|
- children: [
|
|
|
- // 头部
|
|
|
- Positioned(left: 0, top: 0, right: 0, child: _buildHeader(context)),
|
|
|
- // 状态栏和标题栏
|
|
|
- Positioned(
|
|
|
- left: 0,
|
|
|
- top: 0,
|
|
|
- right: 0,
|
|
|
- child: Column(
|
|
|
- mainAxisSize: MainAxisSize.min,
|
|
|
- children: [_buildStatusBar(), _buildTopBar()],
|
|
|
- ),
|
|
|
- ),
|
|
|
- // 内容,填充剩余部分
|
|
|
- Positioned.fill(
|
|
|
- top: 170.h + StatusBarUtil.getStatusBarHeight(Get.context!),
|
|
|
- left: 0,
|
|
|
- right: 0,
|
|
|
- child: Column(children: [_buildContent()]),
|
|
|
- ),
|
|
|
- // 底部按钮
|
|
|
- Positioned(
|
|
|
- left: 0,
|
|
|
- right: 0,
|
|
|
- bottom: 0,
|
|
|
- child: _buildBottomActionBtn(),
|
|
|
- ),
|
|
|
- ],
|
|
|
- ),
|
|
|
- ),
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- /// 导航栏占位
|
|
|
- Widget _buildStatusBar() {
|
|
|
- // 导航栏高度
|
|
|
- double statusBarHeight = StatusBarUtil.getStatusBarHeight(Get.context!);
|
|
|
- return Container(height: statusBarHeight);
|
|
|
- }
|
|
|
-
|
|
|
- /// 顶部栏
|
|
|
- Widget _buildTopBar() {
|
|
|
- return TopBar(
|
|
|
- leftWidget: GestureDetector(
|
|
|
- onTap: controller.clickBack,
|
|
|
- child: Assets.images.iconBlackBackArrow.image(
|
|
|
- width: 24.w,
|
|
|
- height: 24.h,
|
|
|
- ),
|
|
|
- ),
|
|
|
- rightWidget: // 视频教程按钮
|
|
|
- Positioned(
|
|
|
- right: 16.w,
|
|
|
- child: Visibility(
|
|
|
- visible: true,
|
|
|
- child: GestureDetector(
|
|
|
- onTap: () {
|
|
|
- controller.clickTutorialVideo();
|
|
|
- },
|
|
|
- child: Text(
|
|
|
- StringName.keyboardTutorialVideo,
|
|
|
- style: TextStyle(
|
|
|
- color: ColorName.black85,
|
|
|
- fontSize: 14.sp,
|
|
|
- fontWeight: FontWeight.w500,
|
|
|
- ),
|
|
|
- ),
|
|
|
- ),
|
|
|
- ),
|
|
|
- ),
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- /// 头部布局
|
|
|
- Widget _buildHeader(BuildContext context) {
|
|
|
- return SizedBox(
|
|
|
- width: double.infinity,
|
|
|
- height: 298.h,
|
|
|
- child: Stack(
|
|
|
- alignment: Alignment.center,
|
|
|
- children: [
|
|
|
- // 头像
|
|
|
- Positioned(
|
|
|
- top: 37.5.h,
|
|
|
- bottom: 86.5.h,
|
|
|
- child: Assets.images.iconKeyboardTutorialHeader.image(
|
|
|
- height: 174.h,
|
|
|
- fit: BoxFit.cover,
|
|
|
- ),
|
|
|
- ),
|
|
|
- // 蒙版
|
|
|
- Assets.images.bgKeyboardTutorialHeaderMask.image(
|
|
|
- width: double.infinity,
|
|
|
- height: double.infinity,
|
|
|
- ),
|
|
|
- // 提示语
|
|
|
- Positioned(
|
|
|
- top: 70.h + StatusBarUtil.getStatusBarHeight(context),
|
|
|
- child: Assets.images.iconKeyboardTutorialHeaderSlogan.image(
|
|
|
- width: 200.w,
|
|
|
- height: 73.h,
|
|
|
- ),
|
|
|
- ),
|
|
|
- ],
|
|
|
- ),
|
|
|
- );
|
|
|
+ return Scaffold(backgroundColor: backgroundColor(), body: _buildContent());
|
|
|
}
|
|
|
|
|
|
/// 内容
|
|
|
Widget _buildContent() {
|
|
|
- return Expanded(child: Column(children: [_buildTutorialAnimation()]));
|
|
|
- }
|
|
|
-
|
|
|
- /// 键盘设置引导动画
|
|
|
- Widget _buildTutorialAnimation() {
|
|
|
- return Lottie.asset(
|
|
|
- Assets.anim.animKeyboardTutorialSetting,
|
|
|
- repeat: true,
|
|
|
- width: 340.w,
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- /// 启用键盘按钮
|
|
|
- Widget _buildEnableKeyboard() {
|
|
|
- return Obx(() {
|
|
|
- return Container(
|
|
|
- margin: EdgeInsets.symmetric(horizontal: 50.w),
|
|
|
- child: GradientTextBtn(
|
|
|
- // 是否启用,这里UI设计上,未启用时要高亮按钮,所以要取反
|
|
|
- enable: !controller.isKeyboardEnable.value,
|
|
|
- StringName.tutorialEnableKeyboardStep,
|
|
|
- onPressed: () {
|
|
|
- // 已启用,不响应点击
|
|
|
- if (controller.isKeyboardEnable.value) {
|
|
|
- return;
|
|
|
- }
|
|
|
- // 去启用键盘
|
|
|
- controller.goEnableKeyboard();
|
|
|
- },
|
|
|
- ),
|
|
|
- );
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- /// 悬浮球设置按钮
|
|
|
- Widget _buildFloatingBallActionBtn() {
|
|
|
- return Obx(() {
|
|
|
- bool isKeyboardEnable = controller.isKeyboardEnable.value;
|
|
|
- bool isFloatingWindowEnable = controller.isFloatingWindowEnable.value;
|
|
|
- // 启用了键盘,但悬浮窗权限未获取到,则高亮按钮
|
|
|
- bool isHighlightBtn = isKeyboardEnable && !isFloatingWindowEnable;
|
|
|
- return Container(
|
|
|
- margin: EdgeInsets.symmetric(horizontal: 50.w),
|
|
|
- child: GradientTextBtn(
|
|
|
- enable: isHighlightBtn,
|
|
|
- StringName.tutorialEnableFloatingBallStep,
|
|
|
- onPressed: () {
|
|
|
- // 已获取,不响应点击
|
|
|
- if (controller.isFloatingWindowEnable.value) {
|
|
|
- return;
|
|
|
- }
|
|
|
- // 去启用悬浮球
|
|
|
- controller.jumpFloatingWindowSetting();
|
|
|
- },
|
|
|
- ),
|
|
|
- );
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- /// 底部操作按钮
|
|
|
- Widget _buildBottomActionBtn() {
|
|
|
- return Column(
|
|
|
- children: [
|
|
|
- // 启用键盘
|
|
|
- _buildEnableKeyboard(),
|
|
|
- SizedBox(height: 20.h),
|
|
|
- // 启用悬浮球
|
|
|
- _buildFloatingBallActionBtn(),
|
|
|
- // 距离底部一定距离
|
|
|
- SizedBox(height: 25.h),
|
|
|
- ],
|
|
|
- );
|
|
|
+ Widget content;
|
|
|
+ if (Platform.isIOS) {
|
|
|
+ content = const KeyboardTutorialIosView();
|
|
|
+ } else {
|
|
|
+ content = const KeyboardTutorialAndroidView();
|
|
|
+ }
|
|
|
+ return content;
|
|
|
}
|
|
|
}
|