Commit 9d058cb499fdcc34402ba8274d71886f381d9f16

Authored by 吴启风
1 parent af6af3c5

feat: 调整首页导航栏入口布局

assets/images/wow_selected_header.png 0 → 100644

376 KB

lib/pages/home/view.dart
... ... @@ -15,7 +15,6 @@ import 'package:wow_english/common/utils/popup_manager.dart';
15 15 import 'package:wow_english/models/app_version_entity.dart';
16 16 import 'package:wow_english/pages/home/state.dart';
17 17 import 'package:wow_english/pages/home/widgets/BaseHomeHeaderWidget.dart';
18   -import 'package:wow_english/pages/home/widgets/ShakeImage.dart';
19 18 import 'package:wow_english/pages/user/bloc/user_bloc.dart';
20 19 import 'package:wow_english/utils/audio_player_util.dart';
21 20  
... ... @@ -69,6 +68,8 @@ class _HomePageView extends StatelessWidget {
69 68 child: Column(
70 69 children: [
71 70 BaseHomeHeaderWidget(
  71 + onWowSelected: () =>
  72 + _checkPermission(() => _openWowSelected(context), bloc),
72 73 callBack: (value) async => {
73 74 await AudioPlayerUtil.getInstance()
74 75 .playAudio(AudioPlayerUtilType.touch),
... ... @@ -123,57 +124,7 @@ class _HomePageView extends StatelessWidget {
123 124 ),
124 125 ),
125 126 ),
126   - BlocBuilder<UserBloc, UserState>(
127   - builder: (context, userState) {
128   - return GestureDetector(
129   - onTap: () {
130   - _checkPermission(() async {
131   - await AudioPlayerUtil.getInstance().pause();
132   - if (Platform.isIOS) {
133   - await LimitingDirectionCsx
134   - .setScreenDirection(
135   - DeviceDirectionMask.Portrait);
136   - } else {
137   - await SystemChrome
138   - .setPreferredOrientations([
139   - DeviceOrientation.portraitUp,
140   - DeviceOrientation.portraitDown
141   - ]);
142   - }
143   - Navigator.of(context).pushNamed(
144   - AppRouteName.webView,
145   - arguments: {
146   - 'urlStr': AppConsts.xiaoeShopUrl,
147   - 'webViewTitle': 'Wow精选'
148   - }).then((value) async => {
149   - if (Platform.isIOS)
150   - {
151   - await LimitingDirectionCsx
152   - .setScreenDirection(
153   - DeviceDirectionMask
154   - .Landscape),
155   - }
156   - else
157   - {
158   - await SystemChrome
159   - .setPreferredOrientations([
160   - DeviceOrientation.landscapeLeft,
161   - DeviceOrientation.landscapeRight
162   - ]),
163   - },
164   - await AudioPlayerUtil.getInstance()
165   - .playAudio(
166   - AudioPlayerUtilType.touch),
167   - });
168   - }, bloc);
169   - },
170   - child: Offstage(
171   - offstage: AppConfigHelper.shouldHidePay() ||
172   - !UserUtil.isLogined() ||
173   - UserUtil.isAppReviewAccount(),
174   - child: const ShakeImage(),
175   - ));
176   - }),
  127 + const Expanded(child: SizedBox.shrink()),
177 128 Expanded(
178 129 child: BlocBuilder<UserBloc, UserState>(
179 130 builder: (context, userState) {
... ... @@ -226,6 +177,38 @@ class _HomePageView extends StatelessWidget {
226 177 );
227 178 });
228 179  
  180 + Future<void> _openWowSelected(BuildContext context) async {
  181 + await AudioPlayerUtil.getInstance().pause();
  182 + try {
  183 + if (Platform.isIOS) {
  184 + await LimitingDirectionCsx.setScreenDirection(
  185 + DeviceDirectionMask.Portrait);
  186 + } else {
  187 + await SystemChrome.setPreferredOrientations([
  188 + DeviceOrientation.portraitUp,
  189 + DeviceOrientation.portraitDown,
  190 + ]);
  191 + }
  192 +
  193 + if (!context.mounted) return;
  194 + await Navigator.of(context).pushNamed(AppRouteName.webView, arguments: {
  195 + 'urlStr': AppConsts.xiaoeShopUrl,
  196 + 'webViewTitle': 'Wow精选',
  197 + });
  198 + } finally {
  199 + if (Platform.isIOS) {
  200 + await LimitingDirectionCsx.setScreenDirection(
  201 + DeviceDirectionMask.Landscape);
  202 + } else {
  203 + await SystemChrome.setPreferredOrientations([
  204 + DeviceOrientation.landscapeLeft,
  205 + DeviceOrientation.landscapeRight,
  206 + ]);
  207 + }
  208 + await AudioPlayerUtil.getInstance().playAudio(AudioPlayerUtilType.touch);
  209 + }
  210 + }
  211 +
229 212 _checkPermission(VoidCallback onAllowed, HomeBloc bloc) {
230 213 if (UserUtil.isLogined()) {
231 214 if (AppConfigHelper.shouldHidePay()) {
... ...
lib/pages/home/widgets/BaseHomeHeaderWidget.dart
... ... @@ -15,10 +15,16 @@ import &#39;customer_service_qr_dialog.dart&#39;;
15 15 typedef HeaderCallback = void Function(dynamic);
16 16  
17 17 class BaseHomeHeaderWidget extends StatelessWidget {
18   - const BaseHomeHeaderWidget({super.key, this.entity, this.callBack});
  18 + const BaseHomeHeaderWidget({
  19 + super.key,
  20 + this.entity,
  21 + this.callBack,
  22 + this.onWowSelected,
  23 + });
19 24  
20 25 final CourseEntity? entity;
21 26 final HeaderCallback? callBack;
  27 + final VoidCallback? onWowSelected;
22 28  
23 29 @override
24 30 Widget build(BuildContext context) {
... ... @@ -81,6 +87,23 @@ class BaseHomeHeaderWidget extends StatelessWidget {
81 87 textAlign: TextAlign.left,
82 88 style: TextStyle(color: Colors.white, fontSize: 30.0),
83 89 )),
  90 + Offstage(
  91 + offstage: AppConfigHelper.shouldHidePay() ||
  92 + !UserUtil.isLogined() ||
  93 + UserUtil.isAppReviewAccount(),
  94 + child: GestureDetector(
  95 + onTap: onWowSelected,
  96 + child: Padding(
  97 + padding: EdgeInsets.only(right: 10.w),
  98 + child: Image.asset(
  99 + 'wow_selected_header'.assetPng,
  100 + width: 105.w,
  101 + height: 34.h,
  102 + fit: BoxFit.contain,
  103 + ),
  104 + ),
  105 + ),
  106 + ),
84 107 FutureBuilder(
85 108 future: AppConfigHelper.getAppConfig(),
86 109 builder: (context, snapshot) {
... ... @@ -92,7 +115,7 @@ class BaseHomeHeaderWidget extends StatelessWidget {
92 115 onTap: () =>
93 116 showCustomerServiceQrDialog(context, customerQr),
94 117 child: Padding(
95   - padding: EdgeInsets.only(right: 12.w),
  118 + padding: EdgeInsets.only(right: 10.w),
96 119 child: Image.asset(
97 120 'ic_customer_service'.assetPng,
98 121 width: 90.w,
... ...