parent
49f9d8a8fe
commit
238fd09bc7
After Width: | Height: | Size: 10 KiB |
@ -1,47 +0,0 @@
|
||||
import 'package:akuCommunity/utils/headers.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class TopicScrollableText extends StatefulWidget {
|
||||
final String title;
|
||||
TopicScrollableText({Key key, @required this.title}) : super(key: key);
|
||||
|
||||
@override
|
||||
_TopicScrollableTextState createState() => _TopicScrollableTextState();
|
||||
}
|
||||
|
||||
class _TopicScrollableTextState extends State<TopicScrollableText> {
|
||||
ScrollPosition _scrollPosition;
|
||||
|
||||
_positionListener() {
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_scrollPosition?.removeListener(_positionListener);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
_scrollPosition = Scrollable.of(context)?.position;
|
||||
_scrollPosition?.addListener(_positionListener);
|
||||
}
|
||||
|
||||
double get offset {
|
||||
if (_scrollPosition.pixels >= 500.w) return 1;
|
||||
if (_scrollPosition.pixels < 500.w && _scrollPosition.pixels >= 0) {
|
||||
return _scrollPosition.pixels / 500.w;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(bottom: 202.w - offset * 160.w),
|
||||
child: Text(widget.title),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
import 'package:akuCommunity/constants/api.dart';
|
||||
import 'package:akuCommunity/utils/headers.dart';
|
||||
import 'package:akuCommunity/widget/bee_back_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
|
||||
class TopicSliverHeader extends SliverPersistentHeaderDelegate {
|
||||
final String imgPath;
|
||||
final String title;
|
||||
final String subTitle;
|
||||
final int id;
|
||||
|
||||
TopicSliverHeader({
|
||||
this.imgPath,
|
||||
this.title,
|
||||
this.subTitle,
|
||||
@required this.id,
|
||||
});
|
||||
|
||||
_buildOverlay(double shrinkOffset) {
|
||||
return Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
child: Material(
|
||||
color: Colors.white.withOpacity(0 + 0.5 * _offset(shrinkOffset)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_buildBackButton() {
|
||||
return Positioned(
|
||||
left: 0,
|
||||
top: ScreenUtil().statusBarHeight,
|
||||
child: BeeBackButton().material(
|
||||
color: Colors.transparent,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_buildTitle(double shrinkOffset) {
|
||||
return Positioned(
|
||||
bottom: 202.w - 195.w * _filterOffset(shrinkOffset),
|
||||
left: 32.w + (95.w - 32.w) * _offset(shrinkOffset),
|
||||
child: '#$title'.text.bold.size(52.sp).make(),
|
||||
);
|
||||
}
|
||||
|
||||
_buildSubTitle(double shrinkOffset) {
|
||||
return Positioned(
|
||||
bottom: 104.w - 104.w * _offset(shrinkOffset) * 2,
|
||||
left: 32.w,
|
||||
child: Opacity(
|
||||
opacity: 1 - _offset(shrinkOffset),
|
||||
child: subTitle.text.size(24.sp).make(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(
|
||||
BuildContext context, double shrinkOffset, bool overlapsContent) {
|
||||
return Container(
|
||||
color: Colors.white,
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
Hero(
|
||||
tag: "$imgPath\_$id",
|
||||
child: FadeInImage.assetNetwork(
|
||||
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
|
||||
image: API.image(imgPath),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
_buildOverlay(shrinkOffset),
|
||||
_buildBackButton(),
|
||||
_buildTitle(shrinkOffset),
|
||||
_buildSubTitle(shrinkOffset),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
double _offset(double shrinkOffset) {
|
||||
if (shrinkOffset <= 0)
|
||||
return 0;
|
||||
else if (shrinkOffset > 0 && shrinkOffset <= maxExtent)
|
||||
return shrinkOffset / maxExtent;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
double _filterOffset(double shrinkOffset) {
|
||||
var offset = _offset(shrinkOffset);
|
||||
if (offset <= 0) return 0;
|
||||
if (offset < 0.7) return offset / 0.7;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@override
|
||||
double get maxExtent => 460.w + ScreenUtil().statusBarHeight;
|
||||
|
||||
@override
|
||||
double get minExtent => 48 + ScreenUtil().statusBarHeight;
|
||||
|
||||
@override
|
||||
bool shouldRebuild(covariant SliverPersistentHeaderDelegate oldDelegate) {
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ChatCard extends StatefulWidget {
|
||||
final String name;
|
||||
final String title;
|
||||
ChatCard({Key key, this.name, this.title}) : super(key: key);
|
||||
|
||||
@override
|
||||
_ChatCardState createState() => _ChatCardState();
|
||||
}
|
||||
|
||||
class _ChatCardState extends State<ChatCard> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container();
|
||||
}
|
||||
}
|
Loading…
Reference in new issue