You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
140 lines
3.9 KiB
140 lines
3.9 KiB
4 years ago
|
import 'package:flutter/material.dart';
|
||
|
import 'package:huixiang/generated/l10n.dart';
|
||
|
import 'package:huixiang/message/mine_message.dart';
|
||
|
import 'package:huixiang/message/real_time_info_page.dart';
|
||
|
import 'package:huixiang/view_widget/my_tab.dart';
|
||
|
import 'package:huixiang/view_widget/round_button.dart';
|
||
|
|
||
|
class MainMessagePage extends StatefulWidget {
|
||
|
@override
|
||
|
State<StatefulWidget> createState() {
|
||
|
return _MainMessagePage();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class _MainMessagePage extends State<MainMessagePage>
|
||
|
with SingleTickerProviderStateMixin {
|
||
|
var tabcontroller;
|
||
|
|
||
|
@override
|
||
|
void initState() {
|
||
|
super.initState();
|
||
|
if (tabcontroller == null)
|
||
|
tabcontroller = TabController(length: 2, vsync: this);
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return Scaffold(
|
||
|
backgroundColor: Color(0xFFFFFFFF),
|
||
|
appBar: AppBar(
|
||
|
backgroundColor: Color(0xFFFFFFFF),
|
||
|
elevation: 0,
|
||
|
centerTitle: false,
|
||
|
leading: GestureDetector(
|
||
|
onTap: () {
|
||
|
Navigator.of(context).pop();
|
||
|
},
|
||
|
child: Container(
|
||
|
alignment: Alignment.centerRight,
|
||
|
margin: EdgeInsets.only(left: 10),
|
||
|
padding: EdgeInsets.all(6),
|
||
|
child: Icon(
|
||
|
Icons.arrow_back_ios,
|
||
|
color: Colors.black,
|
||
|
size: 24,
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
titleSpacing: 2,
|
||
|
leadingWidth: 56,
|
||
|
automaticallyImplyLeading: true,
|
||
|
actions: [rightAction()],
|
||
|
title: Text(
|
||
|
S.of(context).xiaoxi,
|
||
|
style: TextStyle(color: Colors.black),
|
||
|
),
|
||
|
bottom: PreferredSize(
|
||
|
preferredSize: Size(double.infinity, 38),
|
||
|
child: TabBar(
|
||
|
controller: tabcontroller,
|
||
|
isScrollable: true,
|
||
|
indicatorWeight: 2,
|
||
|
indicatorColor: Color(0xFF39B54A),
|
||
|
labelPadding: EdgeInsets.only(left: 25, right: 25),
|
||
|
indicatorPadding: EdgeInsets.only(left: 25, right: 25, top: 3),
|
||
|
unselectedLabelStyle:
|
||
|
TextStyle(fontSize: 16, fontWeight: FontWeight.normal),
|
||
|
labelStyle: TextStyle(
|
||
|
color: Colors.black,
|
||
|
fontSize: 16,
|
||
|
fontWeight: FontWeight.bold),
|
||
|
labelColor: Colors.black,
|
||
|
tabs: [
|
||
|
MyTab(text: S.of(context).huodongzixun),
|
||
|
MyTab(
|
||
|
text: S.of(context).wodexiaoxi,
|
||
|
),
|
||
|
]),
|
||
|
),
|
||
|
),
|
||
|
body: TabBarView(
|
||
|
children: [
|
||
|
RealTimeInfoPage(),
|
||
|
MineMessagePage(_status, (status) {
|
||
|
setState(() {
|
||
|
_bgStatus = status;
|
||
|
});
|
||
|
})
|
||
|
],
|
||
|
controller: tabcontroller,
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
var _status = 0;
|
||
|
var _bgStatus = false;
|
||
|
|
||
|
Widget rightAction() {
|
||
|
if (_status == 0) {
|
||
|
return Container(
|
||
|
margin: EdgeInsets.only(right: 17),
|
||
|
child: GestureDetector(
|
||
|
onTap: () {
|
||
|
setState(() {
|
||
|
_status = (_status + 1) % 2;
|
||
|
});
|
||
|
},
|
||
|
child: Image.asset(
|
||
|
"assets/image/icon_delete.png",
|
||
|
width: 24,
|
||
|
height: 24,
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
} else {
|
||
|
return GestureDetector(
|
||
|
onTap: () {
|
||
|
setState(() {
|
||
|
_status = (_status + 1) % 2;
|
||
|
});
|
||
|
},
|
||
|
child: Container(
|
||
|
margin: EdgeInsets.only(right: 17),
|
||
|
padding: EdgeInsets.only(top: 15, bottom: 15),
|
||
|
alignment: Alignment.center,
|
||
|
child: RoundButton(
|
||
|
text: S.of(context).wancheng,
|
||
|
textColor: _bgStatus ? Colors.white : Color(0xFFA0A0A0),
|
||
|
backgroup: _bgStatus ? Color(0xFF32A060) : Color(0xFFD8D8D8),
|
||
|
fontSize: 14,
|
||
|
fontWeight: FontWeight.bold,
|
||
|
padding: EdgeInsets.only(left: 12, right: 12, top: 2, bottom: 2),
|
||
|
radius: 12,
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
}
|