Modfiy: 调整栏目

This commit is contained in:
ryan
2019-08-09 23:48:49 +08:00
parent 009a58f292
commit b1cc850fbb
6 changed files with 112 additions and 31 deletions

View File

@ -22,7 +22,25 @@ Language: [English](https://github.com/alibaba/flutter-go/blob/master/README-en.
<img src="https://img.alicdn.com/tfs/TB19UahQQzoK1RjSZFlXXai4VXa-1500-1106.png" width="600px">
## 运行方式
- 查看一下版本号是否正确
```dart
flutter --version
```
- 运行以下命令查看是否需要安装其它依赖项来完成安装
```dart
flutter doctor
```
- 运行启动您的应用
```dart
flutter packages get
flutter run
```
- 如果有其他问题,请参考
- https://flutterchina.club/setup-macos/
- https://flutter.dev/docs/get-started/install/macos
## Release安装包下载地址

View File

@ -174,6 +174,7 @@ class _ListRefreshState extends State<ListRefresh> {
return widget.renderItem(index, items[index]);
}
}
return null;
},
controller: _scrollController,
),

View File

@ -50,7 +50,9 @@ class FirstPageState extends State<FirstPage> with AutomaticKeepAliveClientMixin
Future<Map> getIndexListData([Map<String, dynamic> params]) async {
const juejin_flutter = 'https://timeline-merger-ms.juejin.im/v1/get_tag_entry?src=web&tagId=5a96291f6fb9a0535b535438';
/// const juejin_flutter = 'https://timeline-merger-ms.juejin.im/v1/get_tag_entry?src=web&tagId=5a96291f6fb9a0535b535438';
const juejin_flutter = 'https://fluttergo.pub:9527/juejin.im/v1/get_tag_entry?src=web&tagId=5a96291f6fb9a0535b535438';
var pageIndex = (params is Map) ? params['pageIndex'] : 0;
final _param = {'page':pageIndex,'pageSize':20,'sort':'rankIndex'};
var responseList = [];

View File

@ -6,18 +6,24 @@ import './sub_page.dart';
import './main_app_bar.dart';
import './search_page.dart';
import 'package:flutter_go/model/user_info.dart';
import 'package:flutter_go/routers/application.dart' show Application;
import 'package:flutter_go/routers/routers.dart' show Routes;
DefaultTabController _tabController;
TabBar _tabBar;
class _Page {
final String labelId;
final int labelIndex;
_Page(this.labelId);
_Page(this.labelId,this.labelIndex);
}
final List<_Page> _allPages = <_Page>[
_Page('项目1'),
_Page('项目2'),
_Page('项目3'),
_Page('项目4'),
_Page('热门资讯', 1),
_Page('FG-官网', 2),
_Page('FG-web版', 3),
///_Page('项目4'),
];
class MainPage extends StatelessWidget {
@ -27,12 +33,12 @@ class MainPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
print("MainPagess build......");
return DefaultTabController(
_tabController = DefaultTabController(
length: _allPages.length,
child: Scaffold(
appBar: new MyAppBar(
appBar: MyAppBar(
leading: Container(
child: new ClipOval(
child: ClipOval(
child: Image.network(
userInfo.id == 0?'https://hbimg.huabanimg.com/9bfa0fad3b1284d652d370fa0a8155e1222c62c0bf9d-YjG0Vt_fw658':userInfo.avatarPic,
scale: 15.0,
@ -54,10 +60,8 @@ class MainPage extends StatelessWidget {
),
),
body: TabBarViewLayout(),
// drawer: Drawer(
// child: MainLeftPage(),
// ),
));
return _tabController;
}
}
@ -66,37 +70,93 @@ void pushPage(BuildContext context, Widget page, {String pageName}) {
Navigator.push(context, CupertinoPageRoute<void>(builder: (ctx) => page));
}
void showAlertDialog(BuildContext context) {
showDialog<void>(
context: context,
barrierDismissible: false, // user must tap button!
builder: (BuildContext context) {
return AlertDialog(
//title: Text('免责声明'),
content: SingleChildScrollView(
child: ListBody(
children: <Widget>[
Container(
padding: EdgeInsets.fromLTRB(5.0, 5.0, 10.0, 10.0),
//width: 100,
height: 35,
child: Text('免责声明',
style: TextStyle(
fontSize: 18, fontWeight: FontWeight.w700)),
decoration: BoxDecoration(
//color: Colors.blue,
image: DecorationImage(
fit: BoxFit.fitWidth,
image: AssetImage('assets/images/paimaiLogo.png')),
borderRadius: BorderRadius.all(
Radius.circular(10.0),
),
//alignment: Alignment.bottomRight,
)),
SizedBox(height: 20),
Text('111111111'),
Text('222222222'),
],
),
),
shape: RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(20.0)), // 圆角
actions: <Widget>[
new Container(
width: 250,
/// child: _create(),
)
],
);
},
);
}
class TabLayout extends StatelessWidget {
@override
Widget build(BuildContext context) {
return TabBar(
_tabBar = TabBar(
isScrollable: true,
//labelPadding: EdgeInsets.all(12.0),
labelPadding: EdgeInsets.only(top: 12.0, left: 12.0, right: 12.0),
indicatorSize: TabBarIndicatorSize.label,
tabs: _allPages
.map((_Page page) =>
Tab(text: page.labelId))
.toList(),
tabs: _allPages.map((_Page page) => Tab(text: page.labelId)).toList(),
onTap: (index) {
if (index == 1) {
DefaultTabController.of(context).animateTo(0);
Application.router.navigateTo(context, '${Routes.webViewPage}?title=${Uri.encodeComponent('Flutter Go 官方网站')}&url=${Uri.encodeComponent('https://flutter-go.pub')}');
} else if (index == 2) {
// new Future.delayed(const Duration(seconds: 1),(){
// showAlertDialog(Application.globalContext);
// });
DefaultTabController.of(context).animateTo(0);
Application.router.navigateTo(context, '${Routes.webViewPage}?title=${Uri.encodeComponent('Flutter Go web版(H5)')}&url=${Uri.encodeComponent('https://flutter-go.pub/flutter_go_web')}');
}
}
);
return _tabBar;
}
}
class TabBarViewLayout extends StatelessWidget {
Widget buildTabView(BuildContext context, _Page page) {
String labelId = page.labelId;
switch (labelId) {
case '项目1':
int labelIndex = page.labelIndex;
switch (labelIndex) {
case 1:
return FirstPage();
break;
case '项目2':
return SubPage();
case 2:
return Container(child:Text('1'));
break;
case '项目3':
return SubPage();
break;
case '项目4':
return SubPage();
case 3:
return Container(child:Text('2'));
break;
default:
return Container();

View File

@ -23,7 +23,7 @@ final _industryPage = Industry.IndustryPage(itemTitle: (state){
),
subtitle: Text(state.res[index].source),
onTap: () {
// 在这里对选中的结果进行解析因为我目前是用golang实现的所以就没贴代码了。
// 在这里对选中的结果进行解析
print(state.res[index].source);
final itemTitle = state.res[index].title;
final itemUrl = state.res[index].source;
@ -44,7 +44,7 @@ class SearchPage extends StatelessWidget {
/// print('suggestion::${Industry.suggestion}');
return Scaffold(
appBar: PreferredSize(
preferredSize: Size(double.infinity, 52), // 44 is the height
preferredSize: Size(double.infinity, 52), // is the height
child: AppBar(title: searchBarPage)
),
//body: ProgressView(),
@ -160,7 +160,7 @@ class _SearchBarPageState extends State<SearchBarPage> {
controller: controller,
decoration: InputDecoration(
contentPadding: EdgeInsets.only(top: 0.0),
hintText: '搜索全局flutter知识库',
hintText: '全网搜索 Flutter 相关知识库',
hintStyle:TextStyle(fontSize: 12.0),
border: InputBorder.none
),

View File

@ -30,7 +30,7 @@ dependencies:
flutter_spinkit: "^3.1.0"
fluttertoast: ^3.1.0
dio: ^2.0.15
flutter_webview_plugin: ^0.3.4
flutter_webview_plugin: ^0.3.5
cookie_jar: ^1.0.0
# 日期格式化
intl: 0.15.7