mirror of
https://github.com/alibaba/flutter-go.git
synced 2025-05-17 21:05:56 +08:00
Change:服务端控制显示业界动态
This commit is contained in:
@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:fluro/fluro.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'routers/routers.dart';
|
||||
import 'routers/application.dart';
|
||||
import 'routers/application.dart' show Application;
|
||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||
import 'package:flutter_go/utils/provider.dart';
|
||||
import 'package:flutter_go/utils/shared_preferences.dart';
|
||||
@ -19,6 +19,7 @@ import 'package:event_bus/event_bus.dart';
|
||||
import 'package:flutter_go/model/widget.dart';
|
||||
import 'package:flutter_go/standard_pages/index.dart';
|
||||
//import 'views/welcome_page/index.dart';
|
||||
import 'package:flutter_go/utils/net_utils.dart';
|
||||
|
||||
SpUtil sp;
|
||||
var db;
|
||||
@ -49,6 +50,19 @@ class _MyAppState extends State<MyApp> {
|
||||
ApplicationEvent.event = eventBus;
|
||||
}
|
||||
|
||||
/// 服务端控制是否显示业界动态
|
||||
Future _reqsMainPageIsOpen() async {
|
||||
const reqs = 'https://flutter-go.pub/api/isInfoOpen';
|
||||
var response;
|
||||
try{
|
||||
response = await NetUtils.get(reqs, {});
|
||||
print('response-${response}');
|
||||
}catch(e){
|
||||
print('response-${e}');
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@ -128,6 +142,16 @@ class _MyAppState extends State<MyApp> {
|
||||
});
|
||||
print('身份信息验证失败:$onError');
|
||||
});
|
||||
|
||||
/// 服务端控制是否显示业界动态
|
||||
_reqsMainPageIsOpen().then((res){
|
||||
//{status: 200, data: {isOpen: true}, success: true}
|
||||
if(res['status'] == 200 && res['success'] ==true && res['data'] is Map && res['data']['isOpen'] == true) {
|
||||
Application.pageIsOpen = false;
|
||||
print('是否需要展开【业界动态】${Application.pageIsOpen}');
|
||||
}
|
||||
});
|
||||
|
||||
ApplicationEvent.event.on<UserSettingThemeColorEvent>().listen((event) {
|
||||
print('接收到的 event $event');
|
||||
});
|
||||
|
@ -15,6 +15,7 @@ class Application {
|
||||
static TabController controller;
|
||||
static SpUtil sharePeference;
|
||||
static CategoryComponent widgetTree;
|
||||
static bool pageIsOpen = false;
|
||||
|
||||
static Map<String, String> github = {
|
||||
'widgetsURL':'https://github.com/alibaba/flutter-go/blob/develop/lib/widgets/',
|
||||
|
@ -42,24 +42,32 @@ class _MyHomePageState extends State<AppPage>
|
||||
WidgetControlModel widgetControl = new WidgetControlModel();
|
||||
SearchHistoryList searchHistoryList;
|
||||
bool isSearch = false;
|
||||
String appBarTitle = tabData[0]['text'];
|
||||
|
||||
List<Widget> _list = List();
|
||||
int _currentIndex = 0;
|
||||
static List tabData = [
|
||||
{'text': '业界动态', 'icon': Icon(Icons.language)},
|
||||
List tabData = [
|
||||
{'text': 'WIDGET', 'icon': Icon(Icons.extension)},
|
||||
{'text': '关于手册', 'icon': Icon(Icons.import_contacts)},
|
||||
{'text': '个人中心', 'icon': Icon(Icons.account_circle)},
|
||||
|
||||
//https://flutter-go.pub/api/isInfoOpen
|
||||
];
|
||||
|
||||
List<BottomNavigationBarItem> _myTabs = [];
|
||||
String appBarTitle;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
print('widget.userInfo ${widget.userInfo}');
|
||||
initSearchHistory();
|
||||
|
||||
if(Application.pageIsOpen == true){// 是否展开业界动态
|
||||
tabData.insert(0, {'text': '业界动态', 'icon': Icon(Icons.language)});
|
||||
_list
|
||||
//..add(FirstPage())
|
||||
..add(MainPage(userInfo: widget.userInfo));
|
||||
}
|
||||
appBarTitle = tabData[0]['text'];
|
||||
|
||||
for (int i = 0; i < tabData.length; i++) {
|
||||
_myTabs.add(BottomNavigationBarItem(
|
||||
icon: tabData[i]['icon'],
|
||||
@ -68,12 +76,10 @@ class _MyHomePageState extends State<AppPage>
|
||||
),
|
||||
));
|
||||
}
|
||||
_list
|
||||
// ..add(FirstPage())
|
||||
..add(MainPage(userInfo: widget.userInfo))
|
||||
..add(WidgetPage())
|
||||
..add(FourthPage())
|
||||
..add(UserPage(userInfo: widget.userInfo));
|
||||
_list
|
||||
..add(WidgetPage())
|
||||
..add(FourthPage())
|
||||
..add(UserPage(userInfo: widget.userInfo));
|
||||
}
|
||||
|
||||
@override
|
||||
@ -121,7 +127,9 @@ class _MyHomePageState extends State<AppPage>
|
||||
}
|
||||
|
||||
renderAppBar(BuildContext context, Widget widget, int index) {
|
||||
if (index == 1) {
|
||||
if (index == 1 && Application.pageIsOpen == true) {
|
||||
return AppBar(title: buildSearchInput(context));
|
||||
}else if(index == 0 && Application.pageIsOpen == false){
|
||||
return AppBar(title: buildSearchInput(context));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user