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.
aku_new_community/lib/pages/community/topice_detail_page.dart

143 lines
4.1 KiB

4 years ago
import 'package:akuCommunity/pages/community/note_create_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
4 years ago
import 'package:get/get.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:flutter_icons/flutter_icons.dart';
4 years ago
import 'package:akuCommunity/utils/headers.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 _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(
4 years ago
expandedHeight: 500.w,
pinned: true,
floating: true,
elevation: 0,
backgroundColor: Colors.white,
leading: IconButton(
4 years ago
icon: Icon(AntDesign.left, size: 40.sp),
onPressed: () {
4 years ago
Get.back();
},
),
flexibleSpace: FlexibleSpaceBar(
title: Text('教师节'),
background: Image.asset(
imagePath,
fit: BoxFit.fitHeight,
),
),
);
}
4 years ago
Positioned _positionedFloatActionButton() {
return Positioned(
4 years ago
bottom: 124.w,
right: 32.w,
child: FloatingActionButton(
backgroundColor: Color(0xffffd000),
child: Icon(
Icons.add,
color: Colors.white,
size: 40.sp,
),
onPressed: () {
Get.to(NoteCreatePage());
}));
}
@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(),
],
),
);
}
}