mod: 界面及无障碍调整

This commit is contained in:
orz12
2024-03-13 18:38:59 +08:00
parent cc6da716bc
commit 4d5f57b8d0
16 changed files with 277 additions and 222 deletions

View File

@@ -31,6 +31,7 @@ class StatDanMu extends StatelessWidget {
fontSize: size == 'medium' ? 12 : 11, fontSize: size == 'medium' ? 12 : 11,
color: color, color: color,
), ),
overflow: TextOverflow.clip,
semanticsLabel: '${Utils.numFormat(danmu!)}条弹幕', semanticsLabel: '${Utils.numFormat(danmu!)}条弹幕',
) )
], ],

View File

@@ -34,6 +34,7 @@ class StatView extends StatelessWidget {
fontSize: size == 'medium' ? 12 : 11, fontSize: size == 'medium' ? 12 : 11,
color: color, color: color,
), ),
overflow: TextOverflow.clip,
semanticsLabel: semanticsLabel:
'${Utils.numFormat(view!)}${goto == "picture" ? "浏览" : "播放"}', '${Utils.numFormat(view!)}${goto == "picture" ? "浏览" : "播放"}',
), ),

View File

@@ -38,7 +38,8 @@ class VideoCardH extends StatelessWidget {
final int aid = videoItem.aid; final int aid = videoItem.aid;
final String bvid = videoItem.bvid; final String bvid = videoItem.bvid;
final String heroTag = Utils.makeHeroTag(aid); final String heroTag = Utils.makeHeroTag(aid);
return Semantics( return Stack(children: [
Semantics(
label: Utils.videoItemSemantics(videoItem), label: Utils.videoItemSemantics(videoItem),
excludeSemantics: true, excludeSemantics: true,
child: GestureDetector( child: GestureDetector(
@@ -67,7 +68,8 @@ class VideoCardH extends StatelessWidget {
padding: const EdgeInsets.fromLTRB( padding: const EdgeInsets.fromLTRB(
StyleString.safeSpace, 5, StyleString.safeSpace, 5), StyleString.safeSpace, 5, StyleString.safeSpace, 5),
child: LayoutBuilder( child: LayoutBuilder(
builder: (BuildContext context, BoxConstraints boxConstraints) { builder:
(BuildContext context, BoxConstraints boxConstraints) {
final double width = (boxConstraints.maxWidth - final double width = (boxConstraints.maxWidth -
StyleString.cardSpace * StyleString.cardSpace *
6 / 6 /
@@ -86,7 +88,8 @@ class VideoCardH extends StatelessWidget {
builder: (BuildContext context, builder: (BuildContext context,
BoxConstraints boxConstraints) { BoxConstraints boxConstraints) {
final double maxWidth = boxConstraints.maxWidth; final double maxWidth = boxConstraints.maxWidth;
final double maxHeight = boxConstraints.maxHeight; final double maxHeight =
boxConstraints.maxHeight;
return Stack( return Stack(
children: [ children: [
Hero( Hero(
@@ -98,7 +101,8 @@ class VideoCardH extends StatelessWidget {
), ),
), ),
PBadge( PBadge(
text: Utils.timeFormat(videoItem.duration!), text:
Utils.timeFormat(videoItem.duration!),
right: 6.0, right: 6.0,
bottom: 6.0, bottom: 6.0,
type: 'gray', type: 'gray',
@@ -127,7 +131,18 @@ class VideoCardH extends StatelessWidget {
), ),
), ),
), ),
)); )),
if (source == 'normal')
Positioned(
bottom: 1,
right: 10,
child: VideoPopupMenu(
size: 30,
iconSize: 16,
videoItem: videoItem,
),
),
]);
} }
} }
@@ -227,6 +242,7 @@ class VideoContent extends StatelessWidget {
), ),
), ),
), ),
const SizedBox(height: 4),
Row( Row(
children: [ children: [
if (showView) ...[ if (showView) ...[
@@ -242,18 +258,10 @@ class VideoContent extends StatelessWidget {
danmu: videoItem.stat.danmu as int, danmu: videoItem.stat.danmu as int,
), ),
const Spacer(), const Spacer(),
if (source == 'normal') if (source == 'normal') const SizedBox(width: 24),
SizedBox(
width: 24,
height: 24,
child: VideoPopupMenu(
size: 32,
iconSize: 18,
videoItem: videoItem,
),
),
], ],
), ),
const SizedBox(height: 2),
], ],
), ),
), ),

View File

@@ -128,7 +128,8 @@ class VideoCardV extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
String heroTag = Utils.makeHeroTag(videoItem.id); String heroTag = Utils.makeHeroTag(videoItem.id);
return Semantics( return Stack(children: [
Semantics(
label: Utils.videoItemSemantics(videoItem), label: Utils.videoItemSemantics(videoItem),
excludeSemantics: true, excludeSemantics: true,
child: Card( child: Card(
@@ -184,7 +185,17 @@ class VideoCardV extends StatelessWidget {
), ),
), ),
)), )),
); ),
if (videoItem.goto == 'av')
Positioned(
right: 0,
bottom: 1,
child: VideoPopupMenu(
size: 30,
iconSize: 16,
videoItem: videoItem,
)),
]);
} }
} }
@@ -203,7 +214,7 @@ class VideoContent extends StatelessWidget {
Row( Row(
children: [ children: [
Expanded( Expanded(
child: Text(videoItem.title, child: Text(videoItem.title + "\n",
// semanticsLabel: "${videoItem.title}", // semanticsLabel: "${videoItem.title}",
maxLines: 2, maxLines: 2,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
@@ -260,23 +271,17 @@ class VideoContent extends StatelessWidget {
videoItem.owner.name, videoItem.owner.name,
// semanticsLabel: "Up主${videoItem.owner.name}", // semanticsLabel: "Up主${videoItem.owner.name}",
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.clip,
style: TextStyle( style: TextStyle(
height: 1.5,
fontSize: fontSize:
Theme.of(context).textTheme.labelMedium!.fontSize, Theme.of(context).textTheme.labelMedium!.fontSize,
color: Theme.of(context).colorScheme.outline, color: Theme.of(context).colorScheme.outline,
), ),
), ),
), ),
if (videoItem.goto == 'av') ...[ if (videoItem.goto == 'av')
VideoPopupMenu( const SizedBox(width: 24)
size: 24,
iconSize: 14,
videoItem: videoItem,
),
] else ...[
const SizedBox(height: 24)
]
], ],
), ),
], ],

View File

@@ -7,5 +7,5 @@ enum DynamicsType {
extension BusinessTypeExtension on DynamicsType { extension BusinessTypeExtension on DynamicsType {
String get values => ['all', 'video', 'pgc', 'article'][index]; String get values => ['all', 'video', 'pgc', 'article'][index];
String get labels => ['全部', '视频', '', '专栏'][index]; String get labels => ['全部', '投稿', '', '专栏'][index];
} }

View File

@@ -68,12 +68,10 @@ class RecVideoItemAppModel {
? RcmdReason.fromJson(json['rcmd_reason_style']) ? RcmdReason.fromJson(json['rcmd_reason_style'])
: null; : null;
// 由于app端api并不会直接返回与owner的关注状态 // 由于app端api并不会直接返回与owner的关注状态
// 所以借用推荐原因是否为“已关注”、“新关注”判别关注状态从而与web端接口等效 // 所以借用推荐原因是否为“已关注”、“新关注”判别关注状态从而与web端接口等效
isFollowed = rcmdReason != null && String rcmdReasonContent = rcmdReason?.content ?? '';
rcmdReason!.content != null && isFollowed =
rcmdReason!.content!.contains('关注') (rcmdReasonContent == '已关注') || (rcmdReasonContent == '关注') ? 1 : 0;
? 1
: 0;
// 如果是就无需再显示推荐原因交由view统一处理即可 // 如果是就无需再显示推荐原因交由view统一处理即可
if (isFollowed == 1) { if (isFollowed == 1) {
rcmdReason = null; rcmdReason = null;

View File

@@ -1,6 +1,8 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:PiliPalaX/common/constants.dart'; import 'package:PiliPalaX/common/constants.dart';
@@ -324,7 +326,8 @@ class _MemberPageState extends State<MemberPage>
Image.asset( Image.asset(
'assets/images/lv/lv${_memberController.memberInfo.value.level}.png', 'assets/images/lv/lv${_memberController.memberInfo.value.level}.png',
height: 11, height: 11,
semanticLabel: '等级${_memberController.memberInfo.value.level}', semanticLabel:
'等级${_memberController.memberInfo.value.level}',
), ),
const SizedBox(width: 6), const SizedBox(width: 6),
if (_memberController if (_memberController
@@ -337,7 +340,8 @@ class _MemberPageState extends State<MemberPage>
_memberController.memberInfo.value.vip! _memberController.memberInfo.value.vip!
.label!['img_label_uri_hans'], .label!['img_label_uri_hans'],
height: 20, height: 20,
semanticLabel: _memberController.memberInfo.value.vip!.label!['text'], semanticLabel: _memberController
.memberInfo.value.vip!.label!['text'],
), ),
] else if (_memberController ] else if (_memberController
.memberInfo.value.vip!.status == .memberInfo.value.vip!.status ==
@@ -349,9 +353,26 @@ class _MemberPageState extends State<MemberPage>
_memberController.memberInfo.value.vip! _memberController.memberInfo.value.vip!
.label!['img_label_uri_hans_static'], .label!['img_label_uri_hans_static'],
height: 20, height: 20,
semanticLabel: _memberController.memberInfo.value.vip!.label!['text'], semanticLabel: _memberController
.memberInfo.value.vip!.label!['text'],
), ),
] ],
TextButton(
child: Text("UID ${_memberController.mid}",
style: TextStyle(
color: Theme.of(context)
.colorScheme.secondary.withOpacity(0.5),
fontSize: 12,
// fontWeight: FontWeight.w200,
)),
onPressed: () {
Clipboard.setData(
ClipboardData(
text: _memberController.mid.toString()),
);
SmartDialog.showToast(
'已复制${_memberController.mid}至剪贴板');
}),
], ],
), ),
if (_memberController if (_memberController

View File

@@ -224,7 +224,7 @@ class ProfilePanel extends StatelessWidget {
onPressed: () { onPressed: () {
Get.toNamed('/webview', parameters: { Get.toNamed('/webview', parameters: {
'url': 'https://account.bilibili.com/account/home', 'url': 'https://account.bilibili.com/account/home',
'pageTitle': '编辑资料(建议浏览器打开)', 'pageTitle': '个人中心(建议浏览器打开)',
'type': 'url' 'type': 'url'
}); });
}, },
@@ -235,7 +235,7 @@ class ProfilePanel extends StatelessWidget {
backgroundColor: backgroundColor:
Theme.of(context).colorScheme.primary, Theme.of(context).colorScheme.primary,
), ),
child: const Text('编辑资料'), child: const Text('个人中心(web)'),
) )
], ],
if (ctr.ownerMid == -1) ...[ if (ctr.ownerMid == -1) ...[

View File

@@ -49,7 +49,7 @@ class _MemberArchivePageState extends State<MemberArchivePage> {
appBar: AppBar( appBar: AppBar(
titleSpacing: 0, titleSpacing: 0,
centerTitle: false, centerTitle: false,
title: Text('的投稿', style: Theme.of(context).textTheme.titleMedium), title: Text('Ta的投稿', style: Theme.of(context).textTheme.titleMedium),
actions: [ actions: [
Obx( Obx(
() => TextButton.icon( () => TextButton.icon(

View File

@@ -58,7 +58,7 @@ class _MemberDynamicsPageState extends State<MemberDynamicsPage> {
appBar: AppBar( appBar: AppBar(
titleSpacing: 0, titleSpacing: 0,
centerTitle: false, centerTitle: false,
title: Text('的动态', style: Theme.of(context).textTheme.titleMedium), title: Text('Ta的动态', style: Theme.of(context).textTheme.titleMedium),
), ),
body: CustomScrollView( body: CustomScrollView(
physics: const AlwaysScrollableScrollPhysics(), physics: const AlwaysScrollableScrollPhysics(),

View File

@@ -43,7 +43,7 @@ class _MemberSeasonsPageState extends State<MemberSeasonsPage> {
appBar: AppBar( appBar: AppBar(
titleSpacing: 0, titleSpacing: 0,
centerTitle: false, centerTitle: false,
title: Text('的专栏', style: Theme.of(context).textTheme.titleMedium), title: Text('Ta的专栏', style: Theme.of(context).textTheme.titleMedium),
), ),
body: Padding( body: Padding(
padding: const EdgeInsets.only( padding: const EdgeInsets.only(

View File

@@ -156,7 +156,7 @@ class _MinePageState extends State<MinePage> {
), ),
), ),
), ),
const SizedBox(height: 10), const SizedBox(height: 13),
Row( Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
@@ -173,7 +173,7 @@ class _MinePageState extends State<MinePage> {
), ),
], ],
), ),
const SizedBox(height: 5), const SizedBox(height: 8),
Row( Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
@@ -190,7 +190,7 @@ class _MinePageState extends State<MinePage> {
])) ]))
], ],
), ),
const SizedBox(height: 25), const SizedBox(height: 22),
if (_mineController.userInfo.value.levelInfo != null) ...[ if (_mineController.userInfo.value.levelInfo != null) ...[
LayoutBuilder( LayoutBuilder(
builder: (context, BoxConstraints box) { builder: (context, BoxConstraints box) {
@@ -246,7 +246,7 @@ class _MinePageState extends State<MinePage> {
}, },
), ),
], ],
const SizedBox(height: 30), const SizedBox(height: 26),
Padding( Padding(
padding: const EdgeInsets.only(left: 12, right: 12), padding: const EdgeInsets.only(left: 12, right: 12),
child: LayoutBuilder( child: LayoutBuilder(

View File

@@ -279,6 +279,7 @@ class _ImagePreviewState extends State<ImagePreview>
IconButton( IconButton(
onPressed: () => Get.back(), onPressed: () => Get.back(),
icon: const Icon(Icons.close, color: Colors.white), icon: const Icon(Icons.close, color: Colors.white),
tooltip: '关闭',
), ),
], ],
)), )),

View File

@@ -75,7 +75,7 @@ class RcmdController extends GetxController {
_currentPage += 1; _currentPage += 1;
// 若videoList数量太小可能会影响翻页此时再次请求 // 若videoList数量太小可能会影响翻页此时再次请求
// 为避免请求到的数据太少时还在反复请求要求本次返回数据大于1条才触发 // 为避免请求到的数据太少时还在反复请求要求本次返回数据大于1条才触发
if (res['data'].length > 1 && videoList.length < 10) { if (res['data'].length > 1 && videoList.length < 20) {
queryRcmdFeed('onLoad'); queryRcmdFeed('onLoad');
} }
} }

View File

@@ -149,13 +149,15 @@ class _RcmdPageState extends State<RcmdPage>
return SliverGrid( return SliverGrid(
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent( gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
// 行间距 // 行间距
mainAxisSpacing: StyleString.safeSpace, mainAxisSpacing: StyleString.cardSpace,
// 列间距 // 列间距
crossAxisSpacing: StyleString.safeSpace, crossAxisSpacing: StyleString.safeSpace,
// 最大宽度 // 最大宽度
maxCrossAxisExtent: Grid.maxRowWidth, maxCrossAxisExtent: Grid.maxRowWidth,
mainAxisExtent: Grid.calculateActualWidth(context, Grid.maxRowWidth, StyleString.safeSpace) / StyleString.aspectRatio+ mainAxisExtent: Grid.calculateActualWidth(
MediaQuery.textScalerOf(context).scale(96), context, Grid.maxRowWidth, StyleString.safeSpace) /
StyleString.aspectRatio +
MediaQuery.textScalerOf(context).scale(92),
), ),
delegate: SliverChildBuilderDelegate( delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) { (BuildContext context, int index) {

View File

@@ -214,7 +214,7 @@ class ReplyItem extends StatelessWidget {
margin: const EdgeInsets.only(top: 10, left: 45, right: 6, bottom: 4), margin: const EdgeInsets.only(top: 10, left: 45, right: 6, bottom: 4),
child: Semantics( child: Semantics(
label: replyItem?.content?.message ?? "", label: replyItem?.content?.message ?? "",
excludeSemantics: true, // excludeSemantics: true,
child: Text.rich( child: Text.rich(
style: const TextStyle(height: 1.75), style: const TextStyle(height: 1.75),
maxLines: maxLines:
@@ -231,6 +231,7 @@ class ReplyItem extends StatelessWidget {
stack: 'normal', stack: 'normal',
type: 'line', type: 'line',
fs: 9, fs: 9,
semanticsLabel: '置顶',
), ),
), ),
buildContent(context, replyItem!, replyReply, null), buildContent(context, replyItem!, replyReply, null),
@@ -389,7 +390,9 @@ class ReplyItemRow extends StatelessWidget {
i == 0 && (extraRow == 1 || replies!.length > 1) ? 5 : 6, i == 0 && (extraRow == 1 || replies!.length > 1) ? 5 : 6,
), ),
child: Semantics( child: Semantics(
label: replies![i].member.uname + ' ' + replies![i].content.message, label: replies![i].member.uname +
' ' +
replies![i].content.message,
excludeSemantics: true, excludeSemantics: true,
child: Text.rich( child: Text.rich(
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
@@ -538,11 +541,19 @@ InlineSpan buildContent(
final RegExp pattern = RegExp(patternStr); final RegExp pattern = RegExp(patternStr);
List<String> matchedStrs = []; List<String> matchedStrs = [];
void addPlainTextSpan(str) { void addPlainTextSpan(str) {
spanChilds.add(TextSpan( spanChilds.add(WidgetSpan(
text: str, alignment: PlaceholderAlignment.middle,
recognizer: TapGestureRecognizer() child: ExcludeSemantics(
..onTap = () => child: Text(
replyReply?.call(replyItem.root == 0 ? replyItem : fReplyItem))); str,
style: const TextStyle(height: 1.75),
))));
// TextSpan(
//
// text: str,
// recognizer: TapGestureRecognizer()
// ..onTap = () => replyReply
// ?.call(replyItem.root == 0 ? replyItem : fReplyItem)))));
} }
// 分割文本并处理每个部分 // 分割文本并处理每个部分
@@ -554,13 +565,14 @@ InlineSpan buildContent(
// 处理表情 // 处理表情
final int size = content.emote[matchStr]['meta']['size']; final int size = content.emote[matchStr]['meta']['size'];
spanChilds.add(WidgetSpan( spanChilds.add(WidgetSpan(
child: ExcludeSemantics(
child: NetworkImgLayer( child: NetworkImgLayer(
src: content.emote[matchStr]['url'], src: content.emote[matchStr]['url'],
type: 'emote', type: 'emote',
width: size * 20, width: size * 20,
height: size * 20, height: size * 20,
semanticsLabel: matchStr, semanticsLabel: matchStr,
), )),
)); ));
} else if (matchStr.startsWith("@") && } else if (matchStr.startsWith("@") &&
content.atNameToMid.containsKey(matchStr.substring(1))) { content.atNameToMid.containsKey(matchStr.substring(1))) {
@@ -836,6 +848,7 @@ InlineSpan buildContent(
src: pictureItem['img_src'], src: pictureItem['img_src'],
width: box.maxWidth / 2, width: box.maxWidth / 2,
height: height, height: height,
semanticsLabel: '图片1共1张',
), ),
), ),
height > Get.size.height * 0.9 height > Get.size.height * 0.9
@@ -875,7 +888,9 @@ InlineSpan buildContent(
width: box.maxWidth, width: box.maxWidth,
height: box.maxWidth, height: box.maxWidth,
origAspectRatio: content.pictures[i]['img_width'] / origAspectRatio: content.pictures[i]['img_width'] /
content.pictures[i]['img_height']), content.pictures[i]['img_height'],
semanticsLabel: '图片${i + 1},共$len张',
),
); );
}, },
), ),
@@ -883,6 +898,9 @@ InlineSpan buildContent(
} }
spanChilds.add( spanChilds.add(
WidgetSpan( WidgetSpan(
child: Semantics(
explicitChildNodes: true,
container: true,
child: LayoutBuilder( child: LayoutBuilder(
builder: (context, BoxConstraints box) { builder: (context, BoxConstraints box) {
double maxWidth = box.maxWidth; double maxWidth = box.maxWidth;
@@ -907,7 +925,7 @@ InlineSpan buildContent(
), ),
); );
}, },
), )),
), ),
); );
} }