|
@@ -31,6 +31,8 @@ import 'package:sport/widgets/misc.dart';
|
|
|
import 'package:sport/widgets/persistent_header.dart';
|
|
|
import 'package:sport/widgets/space.dart';
|
|
|
|
|
|
+final List<String> _tabs = ['热门', '关注', '最新', '精华', '官方'];
|
|
|
+
|
|
|
class NewSocialIndexPage extends StatefulWidget {
|
|
|
NewSocialIndexPage();
|
|
|
|
|
@@ -38,20 +40,19 @@ class NewSocialIndexPage extends StatefulWidget {
|
|
|
State<StatefulWidget> createState() => _PageState();
|
|
|
}
|
|
|
|
|
|
-class _PageState
|
|
|
- extends ViewStateLifecycle<NewSocialIndexPage, SocialDetailModel>
|
|
|
- with TickerProviderStateMixin, UserId, InjectApi {
|
|
|
+class _PageState extends ViewStateLifecycle<NewSocialIndexPage, SocialDetailModel> with TickerProviderStateMixin, UserId, InjectApi {
|
|
|
ScrollController _controller;
|
|
|
double _expandedHeight = 0;
|
|
|
int _brightness = 0;
|
|
|
|
|
|
TabController _tabController;
|
|
|
- final List<String> _tabs = ['热门', '关注', '最新', '精华', '官方'];
|
|
|
Future<RespPage<Post>> _getPostListByOfficial;
|
|
|
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
|
|
+
|
|
|
@override
|
|
|
SocialDetailModel createModel() => SocialDetailModel(0);
|
|
|
SocialIndexModel indexModel = new SocialIndexModel();
|
|
|
+
|
|
|
// 右边draw中的 当前选择的索引...
|
|
|
|
|
|
ValueNotifier<int> drawOneIndex = ValueNotifier(0);
|
|
@@ -73,16 +74,18 @@ class _PageState
|
|
|
];
|
|
|
ValueNotifier<bool> isShowSelect = ValueNotifier(false);
|
|
|
|
|
|
+ void _refresh(){
|
|
|
+ model?.setForumIdAndOrigin(_tabController.index, forumId, isOfficial);
|
|
|
+ _controller.animateTo(0, duration: Duration(milliseconds: 100), curve: Curves.ease);
|
|
|
+ }
|
|
|
+
|
|
|
@override
|
|
|
void initState() {
|
|
|
super.initState();
|
|
|
- _tabController = TabController(
|
|
|
- length: _tabs.length, initialIndex: 0, vsync: this)
|
|
|
+ _tabController = TabController(length: _tabs.length, initialIndex: 0, vsync: this)
|
|
|
..addListener(() {
|
|
|
if (_tabController.index.toDouble() == _tabController.animation.value) {
|
|
|
- model?.setForumIdAndOrigin(_tabController.index, forumId, isOfficial);
|
|
|
- _controller.animateTo(0,
|
|
|
- duration: Duration(milliseconds: 100), curve: Curves.ease);
|
|
|
+ _refresh();
|
|
|
}
|
|
|
});
|
|
|
_controller = ScrollController()
|
|
@@ -102,6 +105,7 @@ class _PageState
|
|
|
}
|
|
|
});
|
|
|
initButtonList();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@override
|
|
@@ -132,8 +136,7 @@ class _PageState
|
|
|
Widget _buildSearchWidget() {
|
|
|
return GestureDetector(
|
|
|
onTap: () {
|
|
|
- Navigator.push(
|
|
|
- context, new MaterialPageRoute(builder: (context) => SearchPage()));
|
|
|
+ Navigator.push(context, new MaterialPageRoute(builder: (context) => SearchPage()));
|
|
|
},
|
|
|
child: Container(
|
|
|
// margin: EdgeInsets.fromLTRB(12.0, 0, 12.0, 12.0),
|
|
@@ -166,27 +169,17 @@ class _PageState
|
|
|
// @index 当前显示的下标
|
|
|
// @targetIndex 目标下标
|
|
|
// @type origin / project
|
|
|
- Widget _buildDrawerButtonItem(
|
|
|
- Forum data, int index, ValueNotifier<int> targetIndex, String type) {
|
|
|
+ Widget _buildDrawerButtonItem(Forum data, int index, ValueNotifier<int> targetIndex, String type) {
|
|
|
return InkWell(
|
|
|
child: Container(
|
|
|
decoration: BoxDecoration(
|
|
|
- color: index == targetIndex.value
|
|
|
- ? Theme.of(context).accentColor
|
|
|
- : Colors.white,
|
|
|
+ color: index == targetIndex.value ? Theme.of(context).accentColor : Colors.white,
|
|
|
borderRadius: BorderRadius.all(Radius.circular(20.0)),
|
|
|
- border: Border.all(
|
|
|
- color: index == targetIndex.value
|
|
|
- ? Colors.white
|
|
|
- : Color(0xff999999))),
|
|
|
+ border: Border.all(color: index == targetIndex.value ? Colors.white : Color(0xff999999))),
|
|
|
padding: EdgeInsets.symmetric(vertical: 8.0, horizontal: 25.0),
|
|
|
child: Text(
|
|
|
data.gameName,
|
|
|
- style: TextStyle(
|
|
|
- fontSize: 14.0,
|
|
|
- color: index == targetIndex.value
|
|
|
- ? Colors.white
|
|
|
- : Color(0xff999999)),
|
|
|
+ style: TextStyle(fontSize: 14.0, color: index == targetIndex.value ? Colors.white : Color(0xff999999)),
|
|
|
),
|
|
|
),
|
|
|
onTap: () {
|
|
@@ -223,11 +216,7 @@ class _PageState
|
|
|
height: 43.0,
|
|
|
)
|
|
|
: Container(),
|
|
|
- Text("运动项目",
|
|
|
- style: TextStyle(
|
|
|
- color: Color(0xff333333),
|
|
|
- fontSize: 16.0,
|
|
|
- fontWeight: FontWeight.bold)),
|
|
|
+ Text("运动项目", style: TextStyle(color: Color(0xff333333), fontSize: 16.0, fontWeight: FontWeight.bold)),
|
|
|
Space(
|
|
|
height: 16.0,
|
|
|
),
|
|
@@ -250,18 +239,8 @@ class _PageState
|
|
|
spacing: 8.0,
|
|
|
runSpacing: 16.0,
|
|
|
children: list != null
|
|
|
- ? list
|
|
|
- .asMap()
|
|
|
- .entries
|
|
|
- .map((e) => _buildDrawerButtonItem(
|
|
|
- e.value, e.key, targetIndex, "project"))
|
|
|
- .toList()
|
|
|
- : buttonData
|
|
|
- .asMap()
|
|
|
- .entries
|
|
|
- .map((e) => _buildDrawerButtonItem(
|
|
|
- e.value, e.key, targetIndex, "origin"))
|
|
|
- .toList(),
|
|
|
+ ? list.asMap().entries.map((e) => _buildDrawerButtonItem(e.value, e.key, targetIndex, "project")).toList()
|
|
|
+ : buttonData.asMap().entries.map((e) => _buildDrawerButtonItem(e.value, e.key, targetIndex, "origin")).toList(),
|
|
|
),
|
|
|
);
|
|
|
}
|
|
@@ -293,21 +272,17 @@ class _PageState
|
|
|
));
|
|
|
}
|
|
|
|
|
|
- Widget _buildFilterButton(
|
|
|
- String name, ValueNotifier<int> index, String type) {
|
|
|
+ Widget _buildFilterButton(String name, ValueNotifier<int> index, String type) {
|
|
|
return InkWell(
|
|
|
child: Container(
|
|
|
padding: EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0),
|
|
|
- decoration: BoxDecoration(
|
|
|
- border: Border.all(color: Theme.of(context).accentColor),
|
|
|
- borderRadius: BorderRadius.all(Radius.circular(44.0))),
|
|
|
+ decoration: BoxDecoration(border: Border.all(color: Theme.of(context).accentColor), borderRadius: BorderRadius.all(Radius.circular(44.0))),
|
|
|
child: Row(
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
children: <Widget>[
|
|
|
Text(
|
|
|
"$name",
|
|
|
- style: TextStyle(
|
|
|
- color: Theme.of(context).accentColor, fontSize: 12.0),
|
|
|
+ style: TextStyle(color: Theme.of(context).accentColor, fontSize: 12.0),
|
|
|
),
|
|
|
Space(
|
|
|
width: 5.0,
|
|
@@ -321,9 +296,7 @@ class _PageState
|
|
|
),
|
|
|
),
|
|
|
onTap: () {
|
|
|
- type == "one"
|
|
|
- ? model.setForumIdAndOrigin(_tabController.index, "", isOfficial)
|
|
|
- : model.setForumIdAndOrigin(_tabController.index, forumId, "");
|
|
|
+ type == "one" ? model.setForumIdAndOrigin(_tabController.index, "", isOfficial) : model.setForumIdAndOrigin(_tabController.index, forumId, "");
|
|
|
index.value = 0;
|
|
|
},
|
|
|
);
|
|
@@ -373,60 +346,32 @@ class _PageState
|
|
|
pinned: false,
|
|
|
actions: <Widget>[
|
|
|
Selector<SocialIndexModel, ViewState>(
|
|
|
- selector: (_, SocialIndexModel model) =>
|
|
|
- model.viewState,
|
|
|
- shouldRebuild: (_, v) =>
|
|
|
- v == ViewState.idle,
|
|
|
- builder: (BuildContext context,
|
|
|
- ViewState value, Widget child) {
|
|
|
+ selector: (_, SocialIndexModel model) => model.viewState,
|
|
|
+ shouldRebuild: (_, v) => v == ViewState.idle,
|
|
|
+ builder: (BuildContext context, ViewState value, Widget child) {
|
|
|
return IconButton(
|
|
|
icon: Stack(
|
|
|
alignment: Alignment.center,
|
|
|
children: <Widget>[
|
|
|
- Image.asset(
|
|
|
- "lib/assets/img/bbs_icon_news.png"),
|
|
|
+ Image.asset("lib/assets/img/bbs_icon_news.png"),
|
|
|
FutureBuilder(
|
|
|
- future: SharedPreferences
|
|
|
- .getInstance(),
|
|
|
- builder: (BuildContext context,
|
|
|
- AsyncSnapshot<
|
|
|
- SharedPreferences>
|
|
|
- snapshot) {
|
|
|
- if (snapshot
|
|
|
- .connectionState ==
|
|
|
- ConnectionState.done) {
|
|
|
- if (snapshot.data.getBool(
|
|
|
- "message_setting") ??
|
|
|
- true == true) {
|
|
|
+ future: SharedPreferences.getInstance(),
|
|
|
+ builder: (BuildContext context, AsyncSnapshot<SharedPreferences> snapshot) {
|
|
|
+ if (snapshot.connectionState == ConnectionState.done) {
|
|
|
+ if (snapshot.data.getBool("message_setting") ?? true == true) {
|
|
|
return FutureBuilder(
|
|
|
future: _getCount(),
|
|
|
- builder: (BuildContext
|
|
|
- context,
|
|
|
- AsyncSnapshot<int>
|
|
|
- snapshot) {
|
|
|
- if (snapshot.data !=
|
|
|
- null &&
|
|
|
- snapshot.data >
|
|
|
- 0) {
|
|
|
+ builder: (BuildContext context, AsyncSnapshot<int> snapshot) {
|
|
|
+ if (snapshot.data != null && snapshot.data > 0) {
|
|
|
return Align(
|
|
|
- alignment:
|
|
|
- Alignment
|
|
|
- .topRight,
|
|
|
- child:
|
|
|
- Container(
|
|
|
- margin: const EdgeInsets
|
|
|
- .only(
|
|
|
- top: 6.0),
|
|
|
+ alignment: Alignment.topRight,
|
|
|
+ child: Container(
|
|
|
+ margin: const EdgeInsets.only(top: 6.0),
|
|
|
width: 10,
|
|
|
height: 10,
|
|
|
- decoration: BoxDecoration(
|
|
|
- shape: BoxShape
|
|
|
- .circle,
|
|
|
- color: Colors
|
|
|
- .red),
|
|
|
+ decoration: BoxDecoration(shape: BoxShape.circle, color: Colors.red),
|
|
|
child: Center(
|
|
|
- child: Text(
|
|
|
- ""),
|
|
|
+ child: Text(""),
|
|
|
),
|
|
|
),
|
|
|
);
|
|
@@ -440,8 +385,7 @@ class _PageState
|
|
|
],
|
|
|
),
|
|
|
onPressed: () async {
|
|
|
- await NavigatorUtil.go(
|
|
|
- context, Routes.socialMessage);
|
|
|
+ await NavigatorUtil.go(context, Routes.socialMessage);
|
|
|
setState(() {});
|
|
|
},
|
|
|
);
|
|
@@ -458,20 +402,17 @@ class _PageState
|
|
|
padding: EdgeInsets.only(bottom: 5),
|
|
|
child: TabBar(
|
|
|
isScrollable: true,
|
|
|
- indicatorPadding:
|
|
|
- EdgeInsets.symmetric(horizontal: 8),
|
|
|
+ indicatorPadding: EdgeInsets.symmetric(horizontal: 8),
|
|
|
indicatorWeight: 3,
|
|
|
controller: _tabController,
|
|
|
- tabs:
|
|
|
- _tabs.map((e) => Tab(text: e)).toList(),
|
|
|
+ tabs: _tabs.map((e) => Tab(text: e)).toList(),
|
|
|
),
|
|
|
)),
|
|
|
pinned: true,
|
|
|
),
|
|
|
SliverToBoxAdapter(
|
|
|
child: Padding(
|
|
|
- padding: EdgeInsets.symmetric(
|
|
|
- vertical: 12.0, horizontal: 12.0),
|
|
|
+ padding: EdgeInsets.symmetric(vertical: 12.0, horizontal: 12.0),
|
|
|
child: Row(
|
|
|
children: <Widget>[
|
|
|
_buildSearchWidget(),
|
|
@@ -492,8 +433,7 @@ class _PageState
|
|
|
width: 22,
|
|
|
height: 22,
|
|
|
),
|
|
|
- onTap: () => _scaffoldKey.currentState
|
|
|
- .openEndDrawer(),
|
|
|
+ onTap: () => _scaffoldKey.currentState.openEndDrawer(),
|
|
|
),
|
|
|
),
|
|
|
],
|
|
@@ -505,19 +445,11 @@ class _PageState
|
|
|
padding: EdgeInsets.only(left: 12.0),
|
|
|
child: Row(
|
|
|
children: <Widget>[
|
|
|
- if (drawOneIndex.value != 0)
|
|
|
- _buildFilterButton(
|
|
|
- '${buttonList[drawOneIndex.value].gameName}',
|
|
|
- drawOneIndex,
|
|
|
- "one"),
|
|
|
+ if (drawOneIndex.value != 0) _buildFilterButton('${buttonList[drawOneIndex.value].gameName}', drawOneIndex, "one"),
|
|
|
Space(
|
|
|
width: 10.0,
|
|
|
),
|
|
|
- if (drawTwoIndex.value != 0)
|
|
|
- _buildFilterButton(
|
|
|
- '${buttonData[drawTwoIndex.value].gameName}',
|
|
|
- drawTwoIndex,
|
|
|
- "two"),
|
|
|
+ if (drawTwoIndex.value != 0) _buildFilterButton('${buttonData[drawTwoIndex.value].gameName}', drawTwoIndex, "two"),
|
|
|
],
|
|
|
),
|
|
|
),
|
|
@@ -532,8 +464,7 @@ class _PageState
|
|
|
child: RequestErrorWidget(
|
|
|
null,
|
|
|
msg: "暂无帖子~",
|
|
|
- assets:
|
|
|
- RequestErrorWidget.ASSETS_NO_INVITATION,
|
|
|
+ assets: RequestErrorWidget.ASSETS_NO_INVITATION,
|
|
|
),
|
|
|
),
|
|
|
),
|
|
@@ -542,8 +473,7 @@ class _PageState
|
|
|
delegate: SliverChildBuilderDelegate(
|
|
|
(context, index) {
|
|
|
Post post = model.list[index];
|
|
|
- return PostWidget(
|
|
|
- post, model, selfId == post.userId);
|
|
|
+ return PostWidget(post, model, selfId == post.userId);
|
|
|
},
|
|
|
childCount: model.list.length,
|
|
|
),
|
|
@@ -563,19 +493,28 @@ class _PageState
|
|
|
alignment: Alignment.centerRight,
|
|
|
decoration: BoxDecoration(
|
|
|
image: DecorationImage(
|
|
|
- image: AssetImage("lib/assets/img/bbs_icon_edit.png",)
|
|
|
- ),
|
|
|
+ image: AssetImage(
|
|
|
+ "lib/assets/img/bbs_icon_edit.png",
|
|
|
+ )),
|
|
|
// color: Colors.white,
|
|
|
),
|
|
|
),
|
|
|
- onTap: () {
|
|
|
+ onTap: () async {
|
|
|
// print('FloatingActionButton');
|
|
|
- NavigatorUtil.goPage(
|
|
|
+ var result = await NavigatorUtil.goPage(
|
|
|
context,
|
|
|
(context) => PostPage(
|
|
|
"",
|
|
|
forums: buttonList,
|
|
|
));
|
|
|
+ if(result == true){
|
|
|
+ if (_tabController.index.toDouble() == _tabController.animation.value) {
|
|
|
+ _refresh();
|
|
|
+ }else{
|
|
|
+ _tabController?.index = 2;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
},
|
|
|
),
|
|
|
);
|