Skip to content

Commit

Permalink
搭建页面框架,完成首页-发现。
Browse files Browse the repository at this point in the history
  • Loading branch information
guofudong committed Mar 26, 2019
0 parents commit 8351142
Show file tree
Hide file tree
Showing 38 changed files with 1,321 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .gitignore
@@ -0,0 +1,41 @@
.DS_Store
.dart_tool/

.packages
.pub/

.idea/
.vagrant/
.sconsign.dblite
.svn/

*.swp
profile

DerivedData/

.generated/

*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3

!default.pbxuser
!default.mode1v3
!default.mode2v3
!default.perspectivev3

xcuserdata

*.moved-aside

*.pyc
*sync/
Icon?
.tags*

build/
.android/
.ios/
.flutter-plugins
10 changes: 10 additions & 0 deletions .metadata
@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: cccf44faa64af2b9e0e9436f36960852b50532c4
channel: master

project_type: module
8 changes: 8 additions & 0 deletions README.md
@@ -0,0 +1,8 @@
# flutter_eyepetizer

A new Flutter module.

## Getting Started

For help getting started with Flutter, view our online
[documentation](https://flutter.io/).
18 changes: 18 additions & 0 deletions flutter_eyepetizer.iml
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/lib" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/.idea" />
<excludeFolder url="file://$MODULE_DIR$/.pub" />
<excludeFolder url="file://$MODULE_DIR$/build" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart SDK" level="project" />
<orderEntry type="library" name="Flutter Plugins" level="project" />
<orderEntry type="library" name="Dart Packages" level="project" />
</component>
</module>
27 changes: 27 additions & 0 deletions flutter_eyepetizer_android.iml
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android" name="Android">
<configuration>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="GEN_FOLDER_RELATIVE_PATH_APT" value="/.android/gen" />
<option name="GEN_FOLDER_RELATIVE_PATH_AIDL" value="/.android/gen" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/.android/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/.android/res" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/.android/assets" />
<option name="LIBS_FOLDER_RELATIVE_PATH" value="/.android/libs" />
<option name="PROGUARD_LOGS_FOLDER_RELATIVE_PATH" value="/.android/proguard_logs" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$/.android">
<sourceFolder url="file://$MODULE_DIR$/.android/Flutter/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/.android/gen" isTestSource="false" generated="true" />
</content>
<orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Flutter for Android" level="project" />
</component>
</module>
Binary file added images/2.0x/ic_action_search.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/2.0x/ic_home_public.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/2.0x/ic_tab_strip_icon_category.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/2.0x/ic_tab_strip_icon_category_selected.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/2.0x/ic_tab_strip_icon_feed.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/2.0x/ic_tab_strip_icon_feed_selected.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/2.0x/ic_tab_strip_icon_follow.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/2.0x/ic_tab_strip_icon_follow_selected.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/2.0x/ic_tab_strip_icon_profile.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/2.0x/ic_tab_strip_icon_profile_selected.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
100 changes: 100 additions & 0 deletions lib/app.dart
@@ -0,0 +1,100 @@
import 'package:flutter/material.dart';
import 'package:flutter_eyepetizer/feed/feed_page.dart';
import 'package:flutter_eyepetizer/home/home_page.dart';
import 'package:flutter_eyepetizer/notice/notice_page.dart';
import 'package:flutter_eyepetizer/personal/personal_page.dart';
import 'package:flutter_eyepetizer/publish/publish_page.dart';

/// 应用程序主页面
class App extends StatefulWidget {
@override
State<StatefulWidget> createState() => _MyAppState();
}

class _MyAppState extends State<App> {
/// tab选中的文本颜色
Color _colorTabSelect = Colors.black;

/// tab未选中的文本颜色
Color _colorTabNormal = Colors.black38;

int _currentIndex = 0;

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
//底部导航tab
bottomNavigationBar: BottomNavigationBar(
backgroundColor: Colors.white,
type: BottomNavigationBarType.fixed,
//设置tab选中和未选中的属性
selectedItemColor: _colorTabSelect,
unselectedItemColor: _colorTabNormal,
selectedFontSize: 14,
unselectedFontSize: 14,
//tab点击事件
onTap: (index) => {
setState(() {
_currentIndex = index;
})
},
items: [
BottomNavigationBarItem(
title: Text("首页"),
icon: _currentIndex == 0
? Image.asset("images/ic_tab_strip_icon_feed_selected.png")
: Image.asset("images/ic_tab_strip_icon_feed.png")),
BottomNavigationBarItem(
title: Text("社区"),
icon: _currentIndex == 1
? Image.asset(
"images/ic_tab_strip_icon_follow_selected.png")
: Image.asset("images/ic_tab_strip_icon_follow.png")),
BottomNavigationBarItem(
title: Text(
"",
style: TextStyle(fontSize: 0),
),
icon: Image.asset("images/ic_home_public.png")),
BottomNavigationBarItem(
title: Text("通知"),
icon: _currentIndex == 3
? Image.asset(
"images/ic_tab_strip_icon_category_selected.png")
: Image.asset("images/ic_tab_strip_icon_category.png")),
BottomNavigationBarItem(
title: Text("我的"),
icon: _currentIndex == 4
? Image.asset(
"images/ic_tab_strip_icon_profile_selected.png")
: Image.asset("images/ic_tab_strip_icon_profile.png"))
]),
//页面展示的内容
body: _currentPage(),
);
}

/// 根据选中的tab显示对应的内容
Widget _currentPage() {
Widget page;
switch (_currentIndex) {
case 0:
page = HomePage();
break;
case 1:
page = FeedPage();
break;
case 2:
page = PublishPage();
break;
case 3:
page = NoticePage();
break;
case 4:
page = PersonalPage();
break;
}
return page;
}
}
12 changes: 12 additions & 0 deletions lib/feed/feed_attention.dart
@@ -0,0 +1,12 @@
import 'package:flutter/material.dart';

///社区-关注
class FeedAttentionPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
alignment: Alignment.center,
child: Text("关注"),
);
}
}
59 changes: 59 additions & 0 deletions lib/feed/feed_page.dart
@@ -0,0 +1,59 @@
import 'package:flutter/material.dart';
import 'package:flutter_eyepetizer/feed/feed_attention.dart';
import 'package:flutter_eyepetizer/feed/feed_recommend.dart';
import 'package:flutter_eyepetizer/search/search_page.dart';

/// 社区页面
class FeedPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return DefaultTabController(
//tab数量
length: 2,
child: Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
backgroundColor: Colors.white,
elevation: 0,
title: Stack(
children: <Widget>[
Align(
child: Container(
width: MediaQuery.of(context).size.width / 2.5,
child: TabBar(
//设置tab选中和未选中的属性
indicatorSize: TabBarIndicatorSize.label,
indicatorWeight: 2,
labelColor: Colors.black,
labelStyle: TextStyle(
fontSize: 14.2, fontWeight: FontWeight.bold),
unselectedLabelColor: Colors.black54,
unselectedLabelStyle: TextStyle(
fontSize: 14.0, fontWeight: FontWeight.bold),
indicatorColor: Colors.black,
indicatorPadding: new EdgeInsets.only(bottom: -8.0),
//tab点击事件
onTap: (index) => {},
tabs: [Text("发现"), Text("关注")]),
),
alignment: FractionalOffset.center,
),
Align(
child: IconButton(
icon: Icon(Icons.search, color: Colors.black),
onPressed: () => {
Navigator.of(context).push(MaterialPageRoute(
builder: (BuildContext context) {
return SearchPage();
}))
}),
alignment: FractionalOffset.centerRight,
)
],
),
),
body: TabBarView(children: [FeedRecommendPage(), FeedAttentionPage()]),
),
);
}
}
12 changes: 12 additions & 0 deletions lib/feed/feed_recommend.dart
@@ -0,0 +1,12 @@
import 'package:flutter/material.dart';

/// 社区-推荐
class FeedRecommendPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
alignment: Alignment.center,
child: Text("推荐"),
);
}
}
14 changes: 14 additions & 0 deletions lib/home/home_attention.dart
@@ -0,0 +1,14 @@
import 'package:flutter/material.dart';

/// 首页-关注
class HomeAttentionPage extends StatelessWidget{

@override
Widget build(BuildContext context) {
return Container(
alignment: Alignment.center,
child: Text("关注"),
);
}

}

0 comments on commit 8351142

Please sign in to comment.