| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- import 'package:electronic_assistant/base/base_page.dart';
- import 'package:electronic_assistant/module/record/constants.dart';
- import 'package:electronic_assistant/module/record/controller.dart';
- import 'package:electronic_assistant/resource/colors.gen.dart';
- import 'package:electronic_assistant/utils/expand.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:get/get.dart';
- import '../../resource/assets.gen.dart';
- import '../../widget/frame_animation_view.dart';
- class RecordPage extends BasePage<RecordController> {
- const RecordPage({super.key});
- @override
- bool immersive() {
- return true;
- }
- @override
- bool statusBarDarkFont() {
- return false;
- }
- @override
- Color backgroundColor() {
- return ColorName.recordBackgroundColor;
- }
- @override
- Color navigationBarColor() {
- return "#4A4F67".color;
- }
- @override
- Widget buildBody(BuildContext context) {
- return Stack(alignment: Alignment.bottomCenter, children: [
- _buildBottomGradient(),
- Scaffold(
- appBar: AppBar(
- leading: IconButton(
- icon: const Icon(Icons.arrow_back_ios_new_rounded),
- color: ColorName.white,
- onPressed: () {
- controller.onBackClick();
- },
- ),
- scrolledUnderElevation: 0,
- backgroundColor: ColorName.transparent,
- systemOverlayStyle: SystemUiOverlayStyle.light,
- actions: [
- _buildAddShortcut(false),
- ],
- ),
- backgroundColor: ColorName.transparent,
- body: Flex(
- direction: Axis.vertical,
- children: [
- _buildRecordStatus(),
- const Spacer(flex: 271),
- _buildRecordAnim(),
- const Spacer(flex: 407),
- _buildRecordControl(),
- ],
- ),
- ),
- ]);
- }
- Widget _buildAddShortcut(bool visible) {
- return GestureDetector(
- onTap: () {
- controller.addShortcut();
- },
- child: Visibility(
- visible: visible,
- child: Row(
- children: [
- Image(
- image: Assets.images.iconRecordAddShortcut.provider(),
- width: 24.w,
- height: 24.w),
- Padding(
- padding: EdgeInsets.only(left: 8.w, right: 16.w),
- child: Text(
- '添加到桌面',
- style: TextStyle(color: ColorName.white, fontSize: 14.w),
- ),
- )
- ],
- ),
- ),
- );
- }
- Widget _buildRecordStatus() {
- return Container(
- padding: EdgeInsets.symmetric(horizontal: 16.w),
- margin: EdgeInsets.only(top: 20.w),
- child: Row(
- children: [
- Container(
- margin: EdgeInsets.only(right: 8.w),
- child: Image(
- image: Assets.images.iconRecordLogo.provider(),
- width: 45.w,
- height: 48.w),
- ),
- Obx(() {
- return Text(
- controller.currentStatus.value.desc,
- style: TextStyle(color: ColorName.white, fontSize: 17.w),
- );
- }),
- ],
- ),
- );
- }
- Widget _buildRecordAnim() {
- return Obx(() {
- return AnimatedOpacity(
- opacity:
- controller.currentStatus.value == RecordStatus.recording ? 1 : 0,
- duration: const Duration(milliseconds: 520),
- child: FrameAnimationView(
- controller: controller.frameAnimationController,
- framePath: 'assets/anim/anim_recording.zip',
- speed: 1,
- width: 360.w,
- height: 180.w,
- ),
- );
- });
- }
- Widget _buildRecordControl() {
- return Stack(
- alignment: Alignment.bottomCenter,
- children: [
- Container(
- padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 30.w),
- decoration: BoxDecoration(
- color: "#4A4F67".color,
- borderRadius: BorderRadius.only(
- topLeft: Radius.circular(40.w),
- topRight: Radius.circular(40.w)),
- ),
- child: Row(
- children: [
- GestureDetector(
- onTap: controller.onCancelClick,
- child: Obx(() {
- return Image(
- image: controller.currentStatus.value.cancelButtonImage,
- width: 56.w,
- height: 56.w);
- }),
- ),
- const Spacer(),
- GestureDetector(
- onTap: controller.onSaveClick,
- child: Obx(() {
- return Image(
- image: controller.currentStatus.value.saveButtonImage,
- width: 56.w,
- height: 56.w);
- }),
- ),
- ],
- ),
- ),
- Column(
- children: [
- GestureDetector(
- onTap: () {
- controller.onActionClick();
- },
- child: Obx(
- () => Image(
- image: controller.currentStatus.value.actionButtonImage,
- width: 92.w,
- height: 92.w),
- )),
- Padding(
- padding: EdgeInsets.only(top: 10.w, bottom: 35.w),
- child: Obx(() => Text(
- formatDuration(controller.currentDuration.value),
- style: TextStyle(
- color: ColorName.white,
- fontSize: 16.w,
- ),
- )),
- )
- ],
- )
- ],
- );
- }
- Widget _buildBottomGradient() {
- return Container(
- height: 0.38.sh,
- decoration: BoxDecoration(
- gradient: LinearGradient(
- begin: Alignment.topCenter,
- end: Alignment.bottomCenter,
- colors: [
- "#006177F2".color,
- "#806177F2".color,
- ],
- ),
- ),
- );
- }
- String formatDuration(double value) {
- int hour = (value / 3600).floor();
- int minute = ((value - hour * 3600) / 60).floor();
- int second = (value - hour * 3600 - minute * 60).floor();
- return '${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}:${second.toString().padLeft(2, '0')}';
- }
- }
|