Commit 5f368f69 authored by skeyboy's avatar skeyboy

修复切换tabbar导致用户状态丢失的问题

parent 04afb450
......@@ -9,7 +9,7 @@ class AssistantPage extends GetView<AssistantController> {
// 主视图
Widget _buildView() {
return GridWidget();
return _AssistantPage();
}
@override
......@@ -29,3 +29,20 @@ class AssistantPage extends GetView<AssistantController> {
);
}
}
class _AssistantPage extends StatefulWidget {
const _AssistantPage({Key? key}) : super(key: key);
@override
State<_AssistantPage> createState() => _AssistantPageState();
}
class _AssistantPageState extends State<_AssistantPage> with AutomaticKeepAliveClientMixin{
@override
// TODO: implement wantKeepAlive
bool get wantKeepAlive => true;
@override
Widget build(BuildContext context) {
return GridWidget();
}
}
......@@ -9,7 +9,7 @@ class CreationPage extends GetView<CreationController> {
// 主视图
Widget _buildView() {
return GridWidget();
return const _InnerCreationPage();
// return Obx(() => Center(
// child: InkWell(
// onTap: () => controller.increment(),
......@@ -40,3 +40,23 @@ class CreationPage extends GetView<CreationController> {
);
}
}
class _InnerCreationPage extends StatefulWidget {
const _InnerCreationPage({Key? key}) : super(key: key);
@override
State<_InnerCreationPage> createState() => _InnerCreationPageState();
}
class _InnerCreationPageState extends State<_InnerCreationPage>
with AutomaticKeepAliveClientMixin {
/// 防止每次切换之后自动滑动到顶部
@override
bool get wantKeepAlive => true;
@override
Widget build(BuildContext context) {
return GridWidget();
}
}
......@@ -23,12 +23,34 @@ class HomePage extends GetView<HomeController> {
@override
Widget build(BuildContext context) {
final cc = Get.put(HomeController());
return WillPopScope(
onWillPop: () async {
return false;
},
child: Obx(() => Scaffold(
child: const _HomePage());
}
}
class _HomePage extends StatefulWidget {
const _HomePage({Key? key}) : super(key: key);
@override
State<_HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<_HomePage>
with AutomaticKeepAliveClientMixin {
@override
// TODO: implement wantKeepAlive
bool get wantKeepAlive => true;
HomeController get controller => Get.find();
@override
Widget build(BuildContext context) {
final cc = Get.put(HomeController());
return Obx(() =>
Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: Color.fromARGB(0, 0, 0, 0),
appBar: transparentAppBar(
......@@ -126,7 +148,7 @@ class HomePage extends GetView<HomeController> {
// GradientButton(
// child: Icon(Icons.text_fields_sharp), callback: () {}),
/*Android语音转换文字有问题暂时屏蔽掉*/
(Platform.isAndroid ? Container(): Container(
(Platform.isAndroid ? Container() : Container(
margin: const EdgeInsets.only(right: 10),
child: InkWell(
borderRadius: BorderRadius.circular(100),
......@@ -217,7 +239,8 @@ class HomePage extends GetView<HomeController> {
),
),
),
)));
)
);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment