|
|
@@ -1,23 +1,16 @@
|
|
|
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/assets.gen.dart';
|
|
|
-import 'package:keyboard/resource/colors.gen.dart';
|
|
|
-import 'package:video_player/video_player.dart';
|
|
|
-
|
|
|
import '../../../router/app_pages.dart';
|
|
|
-import '../../../utils/status_bar_util.dart';
|
|
|
+import '../../../widget/platform_util.dart';
|
|
|
+import 'android/keyboard_tutorial_video_android_view.dart';
|
|
|
+import 'ios/keyboard_tutorial_video_ios_view.dart';
|
|
|
import 'keyboard_tutorial_video_controller.dart';
|
|
|
|
|
|
/// 键盘使用教程-视频引导页
|
|
|
class KeyboardTutorialVideoPage
|
|
|
extends BasePage<KeyboardTutorialVideoController> {
|
|
|
- KeyboardTutorialVideoPage({super.key});
|
|
|
-
|
|
|
- final KeyboardTutorialVideoController _controller = Get.put(
|
|
|
- KeyboardTutorialVideoController(),
|
|
|
- );
|
|
|
+ const KeyboardTutorialVideoPage({super.key});
|
|
|
|
|
|
static void start() {
|
|
|
Get.toNamed(RoutePath.keyboardTutorialVideo);
|
|
|
@@ -31,192 +24,15 @@ class KeyboardTutorialVideoPage
|
|
|
|
|
|
@override
|
|
|
backgroundColor() {
|
|
|
- return Color(0xFFF2EFFF);
|
|
|
+ return Colors.transparent;
|
|
|
}
|
|
|
|
|
|
@override
|
|
|
Widget buildBody(BuildContext context) {
|
|
|
- return Scaffold(
|
|
|
- backgroundColor: backgroundColor(),
|
|
|
- body: Stack(
|
|
|
- children: [
|
|
|
- // 内容,填充剩余部分
|
|
|
- Positioned.fill(
|
|
|
- top: 0,
|
|
|
- left: 0,
|
|
|
- right: 0,
|
|
|
- bottom: 0,
|
|
|
- child: SingleChildScrollView(child: _buildContent(context)),
|
|
|
- ),
|
|
|
- // 状态栏和标题栏
|
|
|
- Positioned(
|
|
|
- left: 0,
|
|
|
- top: 0,
|
|
|
- right: 0,
|
|
|
- child: Column(
|
|
|
- mainAxisSize: MainAxisSize.min,
|
|
|
- children: [_buildStatusBar(), _buildTopBar()],
|
|
|
- ),
|
|
|
- ),
|
|
|
- ],
|
|
|
- ),
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- /// 导航栏占位
|
|
|
- Widget _buildStatusBar() {
|
|
|
- // 导航栏高度
|
|
|
- double statusBarHeight = StatusBarUtil.getStatusBarHeight(Get.context!);
|
|
|
- return Container(height: statusBarHeight);
|
|
|
- }
|
|
|
-
|
|
|
- /// 顶部栏
|
|
|
- Widget _buildTopBar() {
|
|
|
- return Container(
|
|
|
- // 宽度撑满父组件
|
|
|
- width: double.infinity,
|
|
|
- height: kToolbarHeight,
|
|
|
- // 背景颜色
|
|
|
- color: Colors.transparent,
|
|
|
- // padding: EdgeInsets.symmetric(horizontal: 16.0),
|
|
|
- child: ConstrainedBox(
|
|
|
- // 设置宽度为无限大,撑满父组件,否则Stack获取不到高度,会报错
|
|
|
- constraints: BoxConstraints(minWidth: double.infinity),
|
|
|
- child: Stack(
|
|
|
- alignment: Alignment.center,
|
|
|
- children: [
|
|
|
- // 返回按钮
|
|
|
- Positioned(
|
|
|
- left: 16.w,
|
|
|
- child: GestureDetector(
|
|
|
- onTap: _controller.clickBack,
|
|
|
- child: Assets.images.iconBlackBackArrow.image(
|
|
|
- width: 24.w,
|
|
|
- height: 24.h,
|
|
|
- ),
|
|
|
- ),
|
|
|
- ),
|
|
|
- ],
|
|
|
- ),
|
|
|
- ),
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- /// 头部布局
|
|
|
- Widget _buildHeader(BuildContext context) {
|
|
|
- return SizedBox(
|
|
|
- width: double.infinity,
|
|
|
- height: 230.h,
|
|
|
- child: Stack(
|
|
|
- alignment: Alignment.center,
|
|
|
- children: [
|
|
|
- // 蒙版
|
|
|
- Assets.images.bgKeyboardVideoTutorialHeaderMask.image(
|
|
|
- width: double.infinity,
|
|
|
- height: double.infinity,
|
|
|
- ),
|
|
|
- // 提示语
|
|
|
- Positioned(
|
|
|
- top: 20.h + StatusBarUtil.getStatusBarHeight(context),
|
|
|
- child: Assets.images.iconKeyboardTutorialVideoHeaderSlogan.image(
|
|
|
- width: 352.w,
|
|
|
- height: 178.h,
|
|
|
- ),
|
|
|
- ),
|
|
|
- ],
|
|
|
- ),
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- /// 内容
|
|
|
- Widget _buildContent(BuildContext context) {
|
|
|
- return Container(
|
|
|
- // 渐变背景
|
|
|
- decoration: BoxDecoration(
|
|
|
- gradient: LinearGradient(
|
|
|
- colors: [Color(0x00FFFFFF), Color(0xFFF2EFFF)],
|
|
|
- begin: Alignment.topCenter,
|
|
|
- end: Alignment.bottomRight,
|
|
|
- ),
|
|
|
- shape: BoxShape.rectangle,
|
|
|
- ),
|
|
|
- child: Column(
|
|
|
- children: [
|
|
|
- // 头部
|
|
|
- _buildHeader(context),
|
|
|
- _buildTutorialVideo(),
|
|
|
- ],
|
|
|
- ),
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- /// 教程视频
|
|
|
- Widget _buildTutorialVideo() {
|
|
|
- return Container(
|
|
|
- margin: EdgeInsets.only(left: 16, right: 16, bottom: 23),
|
|
|
- padding: EdgeInsets.all(12.w),
|
|
|
- decoration: BoxDecoration(
|
|
|
- color: ColorName.white,
|
|
|
- borderRadius: BorderRadius.all(Radius.circular(24.w)),
|
|
|
- ),
|
|
|
- child: Stack(
|
|
|
- alignment: Alignment.center,
|
|
|
- children: [
|
|
|
- Obx(() {
|
|
|
- if (!_controller.isVideoInitialized.value) {
|
|
|
- return SizedBox(width: double.infinity, height: 542.h);
|
|
|
- } else {
|
|
|
- return AspectRatio(
|
|
|
- aspectRatio: _controller.videoController.value.aspectRatio,
|
|
|
- child: ClipRRect(
|
|
|
- borderRadius: BorderRadius.circular(12.w),
|
|
|
- child: VideoPlayer(_controller.videoController),
|
|
|
- ),
|
|
|
- );
|
|
|
- }
|
|
|
- }),
|
|
|
- // 操作按钮
|
|
|
- _buildActionBtn(),
|
|
|
- ],
|
|
|
- ),
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- /// 操作按钮
|
|
|
- Widget _buildActionBtn() {
|
|
|
- return Obx(() {
|
|
|
- return Stack(
|
|
|
- children: [
|
|
|
- Visibility(
|
|
|
- visible: !_controller.isVideoPlaying.value,
|
|
|
- child: _buildPlayBtn(),
|
|
|
- ),
|
|
|
- Visibility(
|
|
|
- visible: _controller.isVideoPlaying.value,
|
|
|
- child: _buildPauseBtn(),
|
|
|
- ),
|
|
|
- ],
|
|
|
- );
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- /// 播放按钮
|
|
|
- Widget _buildPlayBtn() {
|
|
|
- return GestureDetector(
|
|
|
- onTap: () {
|
|
|
- _controller.clickPlay();
|
|
|
- },
|
|
|
- child: Assets.images.iconPlay.image(width: 52.w, height: 52.w),
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- /// 暂停按钮
|
|
|
- Widget _buildPauseBtn() {
|
|
|
- return GestureDetector(
|
|
|
- onTap: () {
|
|
|
- _controller.clickPause();
|
|
|
- },
|
|
|
- child: Assets.images.iconPause.image(width: 52.w, height: 52.w),
|
|
|
- );
|
|
|
+ if (PlatformUtil.isIOS) {
|
|
|
+ return KeyboardTutorialVideoIosView();
|
|
|
+ } else {
|
|
|
+ return KeyboardTutorialVideoAndroidView();
|
|
|
+ }
|
|
|
}
|
|
|
}
|