206 lines
7.1 KiB
Dart
206 lines
7.1 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:aslan/chatvibe_features/user/my_items/theme/bags_tab_theme_page.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_ui/components/at_compontent.dart';
|
|
import 'package:aslan/chatvibe_ui/theme/chatvibe_theme.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_ui/widgets/headdress/headdress_widget.dart';
|
|
import 'package:aslan/chatvibe_features/store/store_route.dart';
|
|
import 'package:aslan/chatvibe_features/user/my_items/chatbox/bags_chatbox_page.dart';
|
|
import 'package:aslan/chatvibe_features/user/my_items/headdress/bags_headdress_page.dart';
|
|
import 'package:aslan/chatvibe_features/user/my_items/mountains/bags_mountains_page.dart';
|
|
|
|
import '../../../chatvibe_core/constants/at_global_config.dart';
|
|
import '../../../chatvibe_domain/usecases/at_fixed_width_tabIndicator.dart';
|
|
|
|
class MyItemsPage extends StatefulWidget {
|
|
@override
|
|
_MyItemsPageState createState() => _MyItemsPageState();
|
|
}
|
|
|
|
class _MyItemsPageState extends State<MyItemsPage>
|
|
with SingleTickerProviderStateMixin {
|
|
late TabController _tabController;
|
|
final List<Widget> _pages = [];
|
|
final List<Widget> _tabs = [];
|
|
String effPlayPath = "";
|
|
String themePath = "";
|
|
VapController? vapController;
|
|
Timer? _timer;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_pages.add(BagsHeaddressPage());
|
|
_pages.add(
|
|
BagsMountainsPage((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(BagsChatboxPage());
|
|
_pages.add(
|
|
BagsTabThemePage((playUrl) {
|
|
themePath = playUrl;
|
|
setState(() {});
|
|
_timer ??= Timer.periodic(Duration(seconds: 5), (timer) {
|
|
themePath = "";
|
|
setState(() {});
|
|
});
|
|
}),
|
|
);
|
|
_tabController = TabController(length: _pages.length, vsync: this);
|
|
_tabController.addListener(() {
|
|
vapController?.stop();
|
|
_timer?.cancel();
|
|
setState(() {
|
|
effPlayPath = "";
|
|
themePath = "";
|
|
});
|
|
});
|
|
}
|
|
|
|
@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)!.chatBox));
|
|
_tabs.add(Tab(text: ATAppLocalizations.of(context)!.theme));
|
|
return Stack(
|
|
children: [
|
|
themePath.isNotEmpty
|
|
? netImage(
|
|
url: themePath,
|
|
width: ScreenUtil().screenWidth,
|
|
height: ScreenUtil().screenHeight,
|
|
)
|
|
: Image.asset(
|
|
"atu_images/room/at_icon_room_settig_bg.png",
|
|
width: ScreenUtil().screenWidth,
|
|
height: ScreenUtil().screenHeight,
|
|
fit: BoxFit.fill,
|
|
),
|
|
Scaffold(
|
|
backgroundColor: Colors.transparent,
|
|
resizeToAvoidBottomInset: false,
|
|
appBar: ChatVibeStandardAppBar(
|
|
title: ATAppLocalizations.of(context)!.myItems,
|
|
actions: [
|
|
GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
child: Container(
|
|
padding: EdgeInsets.all(5.w),
|
|
margin: EdgeInsetsDirectional.only(end: 10.w),
|
|
child: Image.asset(
|
|
"atu_images/store/at_icon_bag_shop.png",
|
|
width: 20.w,
|
|
height: 20.w,
|
|
),
|
|
),
|
|
onTap: () {
|
|
ATNavigatorUtils.push(
|
|
context,
|
|
StoreRoute.list,
|
|
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,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
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(),
|
|
],
|
|
);
|
|
}
|
|
}
|