opt: dynamic up panel

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2024-12-28 21:09:03 +08:00
parent 93560a6fb2
commit d6ed1edc6f
4 changed files with 166 additions and 157 deletions

View File

@@ -317,7 +317,6 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
Expanded( Expanded(
flex: _ratio[0].toInt(), flex: _ratio[0].toInt(),
child: CustomScrollView( child: CustomScrollView(
controller: ScrollController(),
physics: const AlwaysScrollableScrollPhysics(), physics: const AlwaysScrollableScrollPhysics(),
slivers: [ slivers: [
SliverPadding( SliverPadding(

View File

@@ -123,14 +123,12 @@ class _DynamicsPageState extends State<DynamicsPage>
} }
Widget upPanelPart() { Widget upPanelPart() {
return Padding( return Container(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: Container(
//抽屉模式增加底色 //抽屉模式增加底色
color: upPanelPosition.index > 1 color: upPanelPosition.index > 1
? Theme.of(context).colorScheme.surface ? Theme.of(context).colorScheme.surface
: Colors.transparent, : Colors.transparent,
width: 56, width: 64,
child: FutureBuilder( child: FutureBuilder(
future: _futureBuilderFutureUp, future: _futureBuilderFutureUp,
builder: (context, snapshot) { builder: (context, snapshot) {
@@ -143,8 +141,7 @@ class _DynamicsPageState extends State<DynamicsPage>
return HttpError( return HttpError(
isSliver: false, isSliver: false,
callback: () => setState(() { callback: () => setState(() {
_futureBuilderFutureUp = _futureBuilderFutureUp = _dynamicsController.queryFollowUp();
_dynamicsController.queryFollowUp();
}), }),
); );
} }
@@ -170,7 +167,7 @@ class _DynamicsPageState extends State<DynamicsPage>
} }
}, },
), ),
)); );
} }
@override @override

View File

@@ -45,12 +45,11 @@ class _UpPanelState extends State<UpPanel> {
child: SizedBox( child: SizedBox(
height: 45, height: 45,
child: TextButton( child: TextButton(
style: ButtonStyle( style: TextButton.styleFrom(
padding: WidgetStateProperty.all(const EdgeInsets.only()), padding: EdgeInsets.zero,
), ),
child: Column( child: Column(
children: [ children: [
const Spacer(),
const SizedBox(height: 12), const SizedBox(height: 12),
Text( Text(
'Live(${liveList.length})', 'Live(${liveList.length})',
@@ -60,9 +59,10 @@ class _UpPanelState extends State<UpPanel> {
semanticsLabel: semanticsLabel:
'${_showLiveItems ? '展开' : '收起'}直播中的${liveList.length}个Up', '${_showLiveItems ? '展开' : '收起'}直播中的${liveList.length}个Up',
), ),
Icon(_showLiveItems ? Icons.expand_less : Icons.expand_more, Icon(
size: 12), _showLiveItems ? Icons.expand_less : Icons.expand_more,
const Spacer(), size: 12,
),
], ],
), ),
onPressed: () { onPressed: () {
@@ -74,9 +74,7 @@ class _UpPanelState extends State<UpPanel> {
), ),
), ),
const SliverToBoxAdapter( const SliverToBoxAdapter(
child: SizedBox( child: SizedBox(height: 10),
height: 10,
),
), ),
SliverGrid( SliverGrid(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
@@ -99,18 +97,19 @@ class _UpPanelState extends State<UpPanel> {
uname: '', uname: '',
mid: userInfo?.mid, mid: userInfo?.mid,
), ),
1), 1,
),
for (int i = 0; i < upList.length; i++) ...[ for (int i = 0; i < upList.length; i++) ...[
upItemBuild(upList[i], i + 2) upItemBuild(upList[i], i + 2)
], ],
], ],
)), ),
),
const SliverToBoxAdapter( const SliverToBoxAdapter(
child: SizedBox( child: SizedBox(height: 200),
height: 200,
), ),
), ],
]); );
} }
Widget upItemBuild(data, i) { Widget upItemBuild(data, i) {
@@ -172,22 +171,11 @@ class _UpPanelState extends State<UpPanel> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Badge( Stack(
smallSize: 8, clipBehavior: Clip.none,
label: data.type == 'live' ? const Text('Live') : null, children: [
textColor: Theme.of(context).colorScheme.onSecondaryContainer, Padding(
alignment: data.type == 'live' padding: const EdgeInsets.symmetric(horizontal: 4),
? AlignmentDirectional.topCenter
: AlignmentDirectional.topEnd,
padding: const EdgeInsets.only(left: 6, right: 6),
isLabelVisible: data.type == 'live' ||
(data.type == 'up' && (data.hasUpdate ?? false)),
backgroundColor: data.type == 'live'
? Theme.of(context)
.colorScheme
.secondaryContainer
.withOpacity(0.7)
: Theme.of(context).colorScheme.primary,
child: data.face != '' child: data.face != ''
? NetworkImgLayer( ? NetworkImgLayer(
width: 38, width: 38,
@@ -202,8 +190,31 @@ class _UpPanelState extends State<UpPanel> {
), ),
), ),
), ),
Positioned(
top: 0,
right: data.type == 'live' ? -6 : 4,
child: Badge(
smallSize: 8,
label: data.type == 'live' ? const Text(' Live ') : null,
textColor:
Theme.of(context).colorScheme.onSecondaryContainer,
alignment: AlignmentDirectional.topStart,
isLabelVisible: data.type == 'live' ||
(data.type == 'up' && (data.hasUpdate ?? false)),
backgroundColor: data.type == 'live'
? Theme.of(context)
.colorScheme
.secondaryContainer
.withOpacity(0.7)
: Theme.of(context).colorScheme.primary,
),
),
],
),
const SizedBox(height: 3), const SizedBox(height: 3),
Text( Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: Text(
data.uname, data.uname,
overflow: TextOverflow.clip, overflow: TextOverflow.clip,
maxLines: 2, maxLines: 2,
@@ -214,7 +225,9 @@ class _UpPanelState extends State<UpPanel> {
? Theme.of(context).colorScheme.primary ? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.outline, : Theme.of(context).colorScheme.outline,
height: 1.1, height: 1.1,
fontSize: 12.5), fontSize: 12.5,
),
),
), ),
], ],
), ),

View File

@@ -281,7 +281,7 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
child: CustomScrollView( child: CustomScrollView(
controller: orientation == Orientation.portrait controller: orientation == Orientation.portrait
? _htmlRenderCtr.scrollController ? _htmlRenderCtr.scrollController
: ScrollController(), : null,
slivers: [ slivers: [
SliverPadding( SliverPadding(
padding: orientation == Orientation.portrait padding: orientation == Orientation.portrait
@@ -331,8 +331,8 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
if (orientation == Orientation.landscape) ...[ if (orientation == Orientation.landscape) ...[
VerticalDivider( VerticalDivider(
thickness: 8, thickness: 8,
color: color: Theme.of(context).dividerColor.withOpacity(0.05),
Theme.of(context).dividerColor.withOpacity(0.05)), ),
Expanded( Expanded(
flex: _ratio[1].toInt(), flex: _ratio[1].toInt(),
child: Scaffold( child: Scaffold(