import 'dart:async'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:aslan/chatvibe_ui/components/at_compontent.dart'; import 'package:aslan/chatvibe_ui/components/text/at_text.dart'; import 'package:aslan/chatvibe_ui/theme/chatvibe_theme.dart'; import 'package:aslan/chatvibe_core/constants/at_global_config.dart'; import 'package:aslan/chatvibe_features/store/store_route.dart'; import 'package:aslan/chatvibe_features/store/theme/store_theme_page.dart'; import 'package:provider/provider.dart'; import 'package:tancent_vap/utils/constant.dart'; import 'package:tancent_vap/widgets/vap_view.dart'; import 'package:aslan/app_localizations.dart'; import 'package:aslan/chatvibe_ui/components/appbar/chatvibe_appbar.dart'; import 'package:aslan/chatvibe_core/routes/at_fluro_navigator.dart'; import 'package:aslan/chatvibe_core/utilities/at_path_utils.dart'; import 'package:aslan/chatvibe_data/sources/local/file_cache_manager.dart'; import 'package:aslan/chatvibe_managers/user_profile_manager.dart'; import 'package:aslan/chatvibe_ui/widgets/headdress/headdress_widget.dart'; import 'package:aslan/chatvibe_features/wallet/wallet_route.dart'; import 'package:aslan/chatvibe_features/store/chatbox/store_chatbox_page.dart'; import 'package:aslan/chatvibe_features/store/headdress/store_headdress_page.dart'; import 'package:aslan/chatvibe_features/store/mountains/store_mountains_page.dart'; import '../../chatvibe_domain/usecases/at_fixed_width_tabIndicator.dart'; class StorePage extends StatefulWidget { @override _StorePageState createState() => _StorePageState(); } class _StorePageState extends State with SingleTickerProviderStateMixin { late TabController _tabController; final List _pages = []; final List _tabs = []; String effPlayPath = ""; String themePath = ""; VapController? vapController; Timer? _timer; @override void initState() { super.initState(); _pages.add(StoreHeaddressPage()); _pages.add( StoreMountainsPage((playUrl) { effPlayPath = ""; vapController?.stop(); setState(() {}); try { Future.delayed(Duration(milliseconds: 350), () { if (ATPathUtils.fetchFileExtensionFunction(playUrl).toLowerCase() == ".mp4") { FileCacheManager.getInstance().getFile(url: playUrl).then((file) { vapController?.playFile(file.path); }); } else { effPlayPath = playUrl; setState(() {}); } }); } catch (e) {} }), ); _pages.add( StoreThemePage((playUrl) { themePath = playUrl; setState(() {}); _timer ??= Timer.periodic(Duration(seconds: 5), (timer) { themePath = ""; setState(() {}); }); }), ); _pages.add(StoreChatboxPage()); _tabController = TabController(length: _pages.length, vsync: this); _tabController.addListener(() { vapController?.stop(); _timer?.cancel(); setState(() { effPlayPath = ""; themePath = ""; }); }); Provider.of(context, listen: false).balance(); } @override void dispose() { super.dispose(); vapController?.dispose(); _timer?.cancel(); } @override Widget build(BuildContext context) { _tabs.clear(); _tabs.add(Tab(text: ATAppLocalizations.of(context)!.headdress)); _tabs.add(Tab(text: ATAppLocalizations.of(context)!.mountains)); _tabs.add(Tab(text: ATAppLocalizations.of(context)!.theme)); _tabs.add(Tab(text: ATAppLocalizations.of(context)!.chatBox)); return Stack( children: [ themePath.isNotEmpty ? netImage( url: themePath, width: ScreenUtil().screenWidth, height: ScreenUtil().screenHeight, ) : Image.asset( ATGlobalConfig.businessLogicStrategy.getStorePageBackgroundImage(), width: ScreenUtil().screenWidth, height: ScreenUtil().screenHeight, fit: BoxFit.fill, ), Scaffold( backgroundColor: Colors.transparent, resizeToAvoidBottomInset: false, appBar: ChatVibeStandardAppBar( title: ATAppLocalizations.of(context)!.store, actions: [ GestureDetector( behavior: HitTestBehavior.opaque, child: Container( padding: EdgeInsets.all(5.w), margin: EdgeInsetsDirectional.only( end: ATGlobalConfig.businessLogicStrategy .getStorePageShoppingBagMargin() .end .w, ), child: Image.asset( ATGlobalConfig.businessLogicStrategy.getStorePageShoppingBagIcon(), width: 20.w, height: 20.w, ), ), onTap: () { ATNavigatorUtils.push(context, StoreRoute.bags, replace: true); }, ), ], ), body: SafeArea(top: false,child:Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox(width: 5.w), TabBar( tabAlignment: TabAlignment.center, // 改为 center labelPadding: EdgeInsets.symmetric(horizontal: 12.w), labelColor: Colors.black87, isScrollable: true, unselectedLabelColor: Colors.black38, labelStyle: TextStyle(fontSize: 15.sp, fontWeight: FontWeight.w600), unselectedLabelStyle: TextStyle(fontSize: 13.sp, fontWeight: FontWeight.w500), indicator: ATFixedWidthTabIndicator( width: 15.w, color: ATGlobalConfig.businessLogicStrategy.getStorePageTabIndicatorColor(), ), dividerColor: ChatVibeTheme.transparent, controller: _tabController, tabs: _tabs, ), ], ), SizedBox(height: 4.w,), Container(color: ChatVibeTheme.primaryLight,width: ScreenUtil().screenWidth,height: 0.5.w,), SizedBox(height: 6.w,), Expanded( child: TabBarView(controller: _tabController, children: _pages), ), Divider( color: ATGlobalConfig.businessLogicStrategy.getStorePageBottomDividerColor(), thickness: ATGlobalConfig.businessLogicStrategy.getStorePageBottomDividerThickness(), height: ATGlobalConfig.businessLogicStrategy.getStorePageBottomDividerHeight().w, ), Consumer( builder: (context, ref, child) { return GestureDetector( child: Container( padding: EdgeInsets.only(bottom: 12.w), child: Row( children: [ SizedBox(width: 10.w), Image.asset( ATGlobalConfig.businessLogicStrategy.getStorePageGoldIcon(), width: 25.w, height: 25.w, ), SizedBox(width: 5.w), text( "${ref.myBalance}", fontSize: 14.sp, textColor: ATGlobalConfig.businessLogicStrategy.getStorePageGoldTextColor(), ), SizedBox(width: 4.w), Icon( Icons.chevron_right, size: 20.w, color: ATGlobalConfig.businessLogicStrategy.getStorePageGoldIconColor(), ), ], ), ), onTap: () { ATNavigatorUtils.push( context, WalletRoute.recharge, replace: false, ); }, ); }, ), ], ) ,), ), SizedBox( width: ScreenUtil().screenWidth, height: ScreenUtil().screenHeight, child: IgnorePointer( child: VapView( scaleType: ScaleType.centerCrop, onViewCreated: (controller) { vapController = controller; }, ), ), ), ATPathUtils.fetchFileExtensionFunction(effPlayPath).toLowerCase() == ".svga" ? IgnorePointer( child: SVGAHeadwearWidget( width: ScreenUtil().screenWidth, height: ScreenUtil().screenHeight, resource: effPlayPath, loops: 1, ), ) : Container(), ], ); } }