导航栏代码,配置文件
This commit is contained in:
39
ln_jq_app/lib/pages/home/controller.dart
Normal file
39
ln_jq_app/lib/pages/home/controller.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
import 'package:flutter_native_splash/flutter_native_splash.dart';
|
||||
import 'package:getx_scaffold/getx_scaffold.dart';
|
||||
import 'package:ln_jq_app/pages/b_page/base_widgets/view.dart';
|
||||
import 'package:ln_jq_app/pages/c_page/base_widgets/view.dart';
|
||||
import 'package:ln_jq_app/pages/login/view.dart';
|
||||
|
||||
class HomeController extends GetxController with BaseControllerMixin {
|
||||
@override
|
||||
String get builderId => 'home';
|
||||
|
||||
HomeController();
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
FlutterNativeSplash.remove();
|
||||
}
|
||||
|
||||
//登录状态 未登录跳转登录页
|
||||
bool isLoggedIn = false;
|
||||
|
||||
// 登录渠道 加氢站b_login 司机端c_login
|
||||
String loginChannel = "c_login";
|
||||
String loginChannel_b = "b_login";
|
||||
|
||||
// 根据登录状态和登录渠道返回不同的首页
|
||||
Widget getHomePage(bool isLoggedIn, String loginChannel) {
|
||||
if (!isLoggedIn) {
|
||||
return LoginPage(); // 未登录,跳转到登录页面
|
||||
} else {
|
||||
// 已登录,根据渠道判断跳转到不同的页面
|
||||
if (loginChannel == "b_login") {
|
||||
return BaseWidgetsPage(); // 渠道A进入 BaseWidgetsPage
|
||||
} else {
|
||||
return B_BaseWidgetsPage(); // 渠道B进入 B_BaseWidgetsPage
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
23
ln_jq_app/lib/pages/home/view.dart
Normal file
23
ln_jq_app/lib/pages/home/view.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:getx_scaffold/getx_scaffold.dart';
|
||||
import 'package:ln_jq_app/pages/home/controller.dart';
|
||||
|
||||
class HomePage extends GetView<HomeController> {
|
||||
const HomePage({super.key});
|
||||
|
||||
// 主视图
|
||||
Widget _buildView() {
|
||||
return <Widget>[Text('主页面')].toColumn(mainAxisSize: MainAxisSize.min).center();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GetBuilder<HomeController>(
|
||||
init: HomeController(),
|
||||
id: 'home',
|
||||
builder: (_) {
|
||||
return controller.getHomePage(false, controller.loginChannel);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user