97 lines
2.4 KiB
Dart
97 lines
2.4 KiB
Dart
// Author: fruit.com.cn
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../../../core/formatting/count_format.dart';
|
|
import '../../../core/theme/app_colors.dart';
|
|
|
|
const double _buttonSize = 44;
|
|
const double _iconSize = 32;
|
|
const double _itemGap = 24;
|
|
|
|
/// 互动栏单项:图标、计数与点击。
|
|
class InteractionRailItem {
|
|
const InteractionRailItem({
|
|
required this.key,
|
|
required this.asset,
|
|
required this.label,
|
|
required this.onTap,
|
|
this.count,
|
|
this.countKey,
|
|
this.selected = false,
|
|
});
|
|
|
|
final Key key;
|
|
final String asset;
|
|
final String label;
|
|
final VoidCallback onTap;
|
|
final int? count;
|
|
final Key? countKey;
|
|
final bool selected;
|
|
}
|
|
|
|
/// 播放页与首页 feed 共用的右侧互动栏:收藏/评论/喜欢/分享。
|
|
class InteractionRail extends StatelessWidget {
|
|
const InteractionRail({super.key, required this.items});
|
|
|
|
final List<InteractionRailItem> items;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
for (var index = 0; index < items.length; index++) ...[
|
|
if (index > 0) const SizedBox(height: _itemGap),
|
|
_RailButton(item: items[index]),
|
|
],
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
class _RailButton extends StatelessWidget {
|
|
const _RailButton({required this.item});
|
|
|
|
final InteractionRailItem item;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
key: item.key,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
SizedBox.square(
|
|
dimension: _buttonSize,
|
|
child: IconButton(
|
|
onPressed: item.onTap,
|
|
padding: EdgeInsets.zero,
|
|
icon: Image.asset(
|
|
item.asset,
|
|
width: _iconSize,
|
|
height: _iconSize,
|
|
fit: BoxFit.contain,
|
|
color: item.selected ? AppColors.blue : Colors.white,
|
|
colorBlendMode: BlendMode.srcIn,
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 2),
|
|
Text(
|
|
item.count == null ? item.label : formatInteractionCount(item.count!),
|
|
key: item.countKey,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: const TextStyle(
|
|
color: Colors.white,
|
|
height: 1,
|
|
fontSize: 12,
|
|
fontWeight: FontWeight.w600,
|
|
shadows: [Shadow(blurRadius: 6, color: Colors.black)],
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|