Commit e7cbb1fd by tanghuan

测试iOS返回的手势操作

1 parent 647c7088
import 'dart:io';
import 'package:appframe/bloc/web_cubit.dart'; import 'package:appframe/bloc/web_cubit.dart';
import 'package:appframe/config/constant.dart'; import 'package:appframe/config/constant.dart';
import 'package:appframe/config/evn_config.dart'; import 'package:appframe/config/evn_config.dart';
...@@ -45,87 +43,74 @@ class WebPage extends StatelessWidget { ...@@ -45,87 +43,74 @@ class WebPage extends StatelessWidget {
), ),
child: BlocConsumer<WebCubit, WebState>( child: BlocConsumer<WebCubit, WebState>(
builder: (ctx, state) { builder: (ctx, state) {
return PopScope( return Scaffold(
canPop: Platform.isIOS, appBar: _buildAppBar(ctx, state),
onPopInvokedWithResult: (didPop, result) { endDrawer: _buildDrawer(ctx, state),
print("onPopInvokedWithResult--------------------------- $didPop $result"); body: Stack(
if (Platform.isIOS) { children: [
if (didPop) { state.loaded
ctx.read<WebCubit>().handleBack(); ? SizedBox(
} height: MediaQuery.of(ctx).size.height - 60, // 减去100像素留空
} else { child: WebViewWidget(controller: ctx.read<WebCubit>().controller),
ctx.read<WebCubit>().handleBack(); )
} : const Center(
}, child: Column(
child: Scaffold( mainAxisAlignment: MainAxisAlignment.center,
appBar: _buildAppBar(ctx, state), children: [
endDrawer: _buildDrawer(ctx, state), CircularProgressIndicator(color: Color(0xFF7691fa)),
body: Stack( SizedBox(height: 16),
children: [ Text('加载中...'),
state.loaded ],
? SizedBox( ),
height: MediaQuery.of(ctx).size.height - 60, // 减去100像素留空 ),
child: WebViewWidget(controller: ctx.read<WebCubit>().controller), // 添加升级遮罩层
) if (state.isUpgrading)
: const Center( Container(
child: Column( color: Colors.black54,
mainAxisAlignment: MainAxisAlignment.center, child: const Center(
children: [ child: Column(
CircularProgressIndicator(color: Color(0xFF7691fa)), mainAxisAlignment: MainAxisAlignment.center,
SizedBox(height: 16), children: [
Text('加载中...'), CircularProgressIndicator(color: Color(0xFF7691fa)),
], SizedBox(height: 16),
), Text('资源更新中...', style: TextStyle(color: Colors.white)),
), ],
// 添加升级遮罩层
if (state.isUpgrading)
Container(
color: Colors.black54,
child: const Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CircularProgressIndicator(color: Color(0xFF7691fa)),
SizedBox(height: 16),
Text('资源更新中...', style: TextStyle(color: Colors.white)),
],
),
), ),
), ),
], ),
), ],
bottomNavigationBar: state.showBottomNavBar
? BottomNavigationBar(
type: BottomNavigationBarType.fixed,
currentIndex: state.selectedIndex,
selectedItemColor: Color(0xFF7691fa),
unselectedItemColor: Color(0xFF969799),
onTap: (index) {
// 更新选中索引
ctx.read<WebCubit>().updateSelectedIndex(index);
// 根据 index 执行相应的操作
},
items: const [
BottomNavigationBarItem(
icon: Icon(Icons.home, size: 32),
label: '我的班级',
),
BottomNavigationBarItem(
icon: Icon(Icons.contact_page, size: 32),
label: '通讯录',
),
BottomNavigationBarItem(
icon: Icon(Icons.find_in_page, size: 32),
label: '发现',
),
BottomNavigationBarItem(
icon: Icon(Icons.person, size: 32),
label: '我的',
),
],
)
: null,
), ),
bottomNavigationBar: state.showBottomNavBar
? BottomNavigationBar(
type: BottomNavigationBarType.fixed,
currentIndex: state.selectedIndex,
selectedItemColor: Color(0xFF7691fa),
unselectedItemColor: Color(0xFF969799),
onTap: (index) {
// 更新选中索引
ctx.read<WebCubit>().updateSelectedIndex(index);
// 根据 index 执行相应的操作
},
items: const [
BottomNavigationBarItem(
icon: Icon(Icons.home, size: 32),
label: '我的班级',
),
BottomNavigationBarItem(
icon: Icon(Icons.contact_page, size: 32),
label: '通讯录',
),
BottomNavigationBarItem(
icon: Icon(Icons.find_in_page, size: 32),
label: '发现',
),
BottomNavigationBarItem(
icon: Icon(Icons.person, size: 32),
label: '我的',
),
],
)
: null,
); );
}, },
listener: (context, state) { listener: (context, state) {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!