diff --git a/README.md b/README.md index 2512a8a8..bd2f01d0 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,25 @@ Language: [English](https://github.com/alibaba/flutter-go/blob/master/README-en. +## 运行方式 +- 查看一下版本号是否正确 +```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安装包下载地址 diff --git a/lib/components/list_refresh.dart b/lib/components/list_refresh.dart index b4a13244..c5d3b0d8 100644 --- a/lib/components/list_refresh.dart +++ b/lib/components/list_refresh.dart @@ -174,6 +174,7 @@ class _ListRefreshState extends State { return widget.renderItem(index, items[index]); } } + return null; }, controller: _scrollController, ), diff --git a/lib/views/first_page/first_page.dart b/lib/views/first_page/first_page.dart index 8c7f66ea..38840ba1 100644 --- a/lib/views/first_page/first_page.dart +++ b/lib/views/first_page/first_page.dart @@ -50,7 +50,9 @@ class FirstPageState extends State with AutomaticKeepAliveClientMixin Future getIndexListData([Map 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 = []; diff --git a/lib/views/first_page/main_page.dart b/lib/views/first_page/main_page.dart index 1630c994..d2f9f63a 100644 --- a/lib/views/first_page/main_page.dart +++ b/lib/views/first_page/main_page.dart @@ -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(builder: (ctx) => page)); } +void showAlertDialog(BuildContext context) { + showDialog( + context: context, + barrierDismissible: false, // user must tap button! + builder: (BuildContext context) { + return AlertDialog( + //title: Text('免责声明'), + content: SingleChildScrollView( + child: ListBody( + children: [ + 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: [ + 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(); diff --git a/lib/views/first_page/search_page.dart b/lib/views/first_page/search_page.dart index 6d519738..e3d751c8 100644 --- a/lib/views/first_page/search_page.dart +++ b/lib/views/first_page/search_page.dart @@ -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 { controller: controller, decoration: InputDecoration( contentPadding: EdgeInsets.only(top: 0.0), - hintText: '搜索全局flutter知识库', + hintText: '全网搜索 Flutter 相关知识库', hintStyle:TextStyle(fontSize: 12.0), border: InputBorder.none ), diff --git a/pubspec.yaml b/pubspec.yaml index 7dba5e7f..6401c44a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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