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.
147 lines
4.1 KiB
147 lines
4.1 KiB
4 years ago
|
import 'package:flutter/material.dart';
|
||
|
import 'package:flutter/cupertino.dart';
|
||
|
import 'package:pull_to_refresh/pull_to_refresh.dart';
|
||
|
import 'package:flutter_icons/flutter_icons.dart';
|
||
|
import 'package:akuCommunity/utils/screenutil.dart';
|
||
|
import 'package:akuCommunity/routers/page_routers.dart';
|
||
|
import 'widget/trend_card.dart';
|
||
|
|
||
|
class TopiceDetailPage extends StatefulWidget {
|
||
|
final Bundle bundle;
|
||
|
TopiceDetailPage({Key key, this.bundle}) : super(key: key);
|
||
|
|
||
|
@override
|
||
|
_TopiceDetailPageState createState() => _TopiceDetailPageState();
|
||
|
}
|
||
|
|
||
|
class _TopiceDetailPageState extends State<TopiceDetailPage> {
|
||
|
RefreshController _refreshController =
|
||
|
RefreshController(initialRefresh: false);
|
||
|
ScrollController _controller;
|
||
|
|
||
|
@override
|
||
|
void initState() {
|
||
|
super.initState();
|
||
|
}
|
||
|
|
||
|
void noteCreateRouter() {
|
||
|
Navigator.pushNamed(
|
||
|
context,
|
||
|
PageName.note_create_page.toString(),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
void _onRefresh() async {
|
||
|
await Future.delayed(Duration(milliseconds: 1500));
|
||
|
|
||
|
_refreshController.refreshCompleted();
|
||
|
}
|
||
|
|
||
|
void _onLoading() async {
|
||
|
await Future.delayed(Duration(milliseconds: 1500));
|
||
|
|
||
|
if (mounted) setState(() {});
|
||
|
_refreshController.loadComplete();
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
void dispose() {
|
||
|
super.dispose();
|
||
|
_refreshController.dispose();
|
||
|
}
|
||
|
|
||
|
SliverAppBar _sliverAppBar(String imagePath) {
|
||
|
return SliverAppBar(
|
||
|
expandedHeight: Screenutil.length(500),
|
||
|
pinned: true,
|
||
|
floating: true,
|
||
|
elevation: 0,
|
||
|
backgroundColor: Colors.white,
|
||
|
leading: IconButton(
|
||
|
icon: Icon(AntDesign.left, size: Screenutil.size(40)),
|
||
|
onPressed: () {
|
||
|
Navigator.pop(context);
|
||
|
},
|
||
|
),
|
||
|
flexibleSpace: FlexibleSpaceBar(
|
||
|
title: Text('教师节'),
|
||
|
background: Image.asset(
|
||
|
imagePath,
|
||
|
fit: BoxFit.fitHeight,
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
Positioned _positionedFloatActionButton(){
|
||
|
return Positioned(
|
||
|
bottom: Screenutil.length(124),
|
||
|
right: Screenutil.length(32),
|
||
|
child: FloatingActionButton(
|
||
|
backgroundColor: Color(0xffffd000),
|
||
|
child: Icon(
|
||
|
Icons.add,
|
||
|
color: Colors.white,
|
||
|
size: Screenutil.size(40),
|
||
|
),
|
||
|
onPressed: noteCreateRouter,
|
||
|
));
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
double _statusHeight = MediaQuery.of(context).padding.top;
|
||
|
return Scaffold(
|
||
|
body: Stack(
|
||
|
children: [
|
||
|
RefreshConfiguration(
|
||
|
hideFooterWhenNotFull: true,
|
||
|
maxOverScrollExtent: 100 + _statusHeight,
|
||
|
child: SmartRefresher(
|
||
|
controller: _refreshController,
|
||
|
header: ClassicHeader(
|
||
|
height: _statusHeight + 60,
|
||
|
outerBuilder: (child) {
|
||
|
return Container(
|
||
|
padding: EdgeInsets.only(top: _statusHeight),
|
||
|
child: Container(
|
||
|
alignment: Alignment.center,
|
||
|
height: 60,
|
||
|
child: child,
|
||
|
),
|
||
|
);
|
||
|
},
|
||
|
),
|
||
|
footer: ClassicFooter(),
|
||
|
onRefresh: _onRefresh,
|
||
|
onLoading: _onLoading,
|
||
|
enablePullUp: true,
|
||
|
child: CustomScrollView(
|
||
|
controller: _controller,
|
||
|
slivers: [
|
||
|
_sliverAppBar(widget.bundle.getMap('topicMap')['imagePath']),
|
||
|
SliverToBoxAdapter(
|
||
|
child: Container(
|
||
|
color: Colors.white,
|
||
|
child: ListView.builder(
|
||
|
shrinkWrap: true,
|
||
|
physics: NeverScrollableScrollPhysics(),
|
||
|
itemBuilder: (context, index) => TrendCard(
|
||
|
name: '秋森',
|
||
|
content: '真的 很喜欢这个小区,保安也非常好',
|
||
|
),
|
||
|
itemCount: 6,
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
_positionedFloatActionButton(),
|
||
|
],
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|