mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-01 15:49:49 +08:00
opt: get theme color
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -127,10 +127,13 @@ class ActionItemState extends State<ActionItem>
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return widget.expand == false ? _buildItem : Expanded(child: _buildItem);
|
||||
final theme = Theme.of(context);
|
||||
return widget.expand == false
|
||||
? _buildItem(theme)
|
||||
: Expanded(child: _buildItem(theme));
|
||||
}
|
||||
|
||||
Widget get _buildItem => Semantics(
|
||||
Widget _buildItem(ThemeData theme) => Semantics(
|
||||
label: (widget.text ?? "") +
|
||||
(widget.selectStatus ? "已" : "") +
|
||||
widget.semanticsLabel,
|
||||
@@ -160,7 +163,7 @@ class ActionItemState extends State<ActionItem>
|
||||
CustomPaint(
|
||||
size: const Size(28, 28),
|
||||
painter: _ArcPainter(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
color: theme.colorScheme.primary,
|
||||
sweepAngle: _animation!.value,
|
||||
),
|
||||
)
|
||||
@@ -172,9 +175,8 @@ class ActionItemState extends State<ActionItem>
|
||||
: widget.icon.icon,
|
||||
size: 18,
|
||||
color: widget.selectStatus
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: widget.icon.color ??
|
||||
Theme.of(context).colorScheme.outline,
|
||||
? theme.colorScheme.primary
|
||||
: widget.icon.color ?? theme.colorScheme.outline,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -193,10 +195,9 @@ class ActionItemState extends State<ActionItem>
|
||||
key: ValueKey<String>(widget.text!),
|
||||
style: TextStyle(
|
||||
color: widget.selectStatus
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: Theme.of(context).colorScheme.outline,
|
||||
fontSize:
|
||||
Theme.of(context).textTheme.labelSmall!.fontSize,
|
||||
? theme.colorScheme.primary
|
||||
: theme.colorScheme.outline,
|
||||
fontSize: theme.textTheme.labelSmall!.fontSize,
|
||||
),
|
||||
semanticsLabel: "",
|
||||
),
|
||||
|
||||
@@ -23,10 +23,11 @@ class ActionRowItem extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Material(
|
||||
color: selectStatus
|
||||
? Theme.of(context).colorScheme.primaryContainer.withOpacity(0.6)
|
||||
: Theme.of(context).highlightColor.withOpacity(0.2),
|
||||
? theme.colorScheme.primaryContainer.withOpacity(0.6)
|
||||
: theme.highlightColor.withOpacity(0.2),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(30)),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: InkWell(
|
||||
@@ -47,8 +48,8 @@ class ActionRowItem extends StatelessWidget {
|
||||
Icon(icon!.icon!,
|
||||
size: 13,
|
||||
color: selectStatus
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: Theme.of(context).colorScheme.onSecondaryContainer),
|
||||
? theme.colorScheme.primary
|
||||
: theme.colorScheme.onSecondaryContainer),
|
||||
const SizedBox(width: 6),
|
||||
],
|
||||
AnimatedOpacity(
|
||||
@@ -64,11 +65,8 @@ class ActionRowItem extends StatelessWidget {
|
||||
text ?? '',
|
||||
key: ValueKey<String>(text ?? ''),
|
||||
style: TextStyle(
|
||||
color: selectStatus
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: null,
|
||||
fontSize:
|
||||
Theme.of(context).textTheme.labelMedium!.fontSize),
|
||||
color: selectStatus ? theme.colorScheme.primary : null,
|
||||
fontSize: theme.textTheme.labelMedium!.fontSize),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -61,6 +61,7 @@ class _CreateFavPageState extends State<CreateFavPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(_mediaId != null ? '编辑' : '创建'),
|
||||
@@ -94,7 +95,7 @@ class _CreateFavPageState extends State<CreateFavPage> {
|
||||
),
|
||||
body: _mediaId != null
|
||||
? _titleController.text.isNotEmpty
|
||||
? _buildBody
|
||||
? _buildBody(theme)
|
||||
: _errMsg?.isNotEmpty == true
|
||||
? Center(
|
||||
child: CustomScrollView(
|
||||
@@ -108,11 +109,11 @@ class _CreateFavPageState extends State<CreateFavPage> {
|
||||
),
|
||||
)
|
||||
: Center(child: CircularProgressIndicator())
|
||||
: _buildBody,
|
||||
: _buildBody(theme),
|
||||
);
|
||||
}
|
||||
|
||||
void _pickImg() async {
|
||||
void _pickImg(ThemeData theme) async {
|
||||
try {
|
||||
XFile? pickedFile = await _imagePicker.pickImage(
|
||||
source: ImageSource.gallery,
|
||||
@@ -124,9 +125,8 @@ class _CreateFavPageState extends State<CreateFavPage> {
|
||||
uiSettings: [
|
||||
AndroidUiSettings(
|
||||
toolbarTitle: '裁剪',
|
||||
toolbarColor: Theme.of(context).colorScheme.secondaryContainer,
|
||||
toolbarWidgetColor:
|
||||
Theme.of(context).colorScheme.onSecondaryContainer,
|
||||
toolbarColor: theme.colorScheme.secondaryContainer,
|
||||
toolbarWidgetColor: theme.colorScheme.onSecondaryContainer,
|
||||
aspectRatioPresets: [
|
||||
CropAspectRatioPreset.ratio16x9,
|
||||
],
|
||||
@@ -167,12 +167,12 @@ class _CreateFavPageState extends State<CreateFavPage> {
|
||||
|
||||
dynamic leadingStyle = TextStyle(fontSize: 14);
|
||||
|
||||
Widget get _buildBody => SingleChildScrollView(
|
||||
Widget _buildBody(ThemeData theme) => SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
if (_attr == null || !Utils.isDefaultFav(_attr!)) ...[
|
||||
ListTile(
|
||||
tileColor: Theme.of(context).colorScheme.onInverseSurface,
|
||||
tileColor: theme.colorScheme.onInverseSurface,
|
||||
onTap: () {
|
||||
EasyThrottle.throttle(
|
||||
'imagePicker', const Duration(milliseconds: 500),
|
||||
@@ -192,7 +192,7 @@ class _CreateFavPageState extends State<CreateFavPage> {
|
||||
dense: true,
|
||||
onTap: () {
|
||||
Get.back();
|
||||
_pickImg();
|
||||
_pickImg(theme);
|
||||
},
|
||||
title: const Text(
|
||||
'替换封面',
|
||||
@@ -217,7 +217,7 @@ class _CreateFavPageState extends State<CreateFavPage> {
|
||||
},
|
||||
);
|
||||
} else {
|
||||
_pickImg();
|
||||
_pickImg(theme);
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -248,7 +248,7 @@ class _CreateFavPageState extends State<CreateFavPage> {
|
||||
const SizedBox(width: 10),
|
||||
Icon(
|
||||
Icons.keyboard_arrow_right,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
color: theme.colorScheme.outline,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -256,7 +256,7 @@ class _CreateFavPageState extends State<CreateFavPage> {
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
ListTile(
|
||||
tileColor: Theme.of(context).colorScheme.onInverseSurface,
|
||||
tileColor: theme.colorScheme.onInverseSurface,
|
||||
leading: Text.rich(
|
||||
style: TextStyle(
|
||||
height: 1,
|
||||
@@ -269,7 +269,7 @@ class _CreateFavPageState extends State<CreateFavPage> {
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
height: 1,
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
color: theme.colorScheme.error,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
@@ -289,7 +289,7 @@ class _CreateFavPageState extends State<CreateFavPage> {
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: _attr != null && Utils.isDefaultFav(_attr!)
|
||||
? Theme.of(context).colorScheme.outline
|
||||
? theme.colorScheme.outline
|
||||
: null,
|
||||
),
|
||||
inputFormatters: [
|
||||
@@ -300,7 +300,7 @@ class _CreateFavPageState extends State<CreateFavPage> {
|
||||
hintText: '名称',
|
||||
hintStyle: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
color: theme.colorScheme.outline,
|
||||
),
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide.none,
|
||||
@@ -313,7 +313,7 @@ class _CreateFavPageState extends State<CreateFavPage> {
|
||||
const SizedBox(height: 16),
|
||||
if (_attr == null || !Utils.isDefaultFav(_attr!)) ...[
|
||||
ListTile(
|
||||
tileColor: Theme.of(context).colorScheme.onInverseSurface,
|
||||
tileColor: theme.colorScheme.onInverseSurface,
|
||||
title: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -324,9 +324,7 @@ class _CreateFavPageState extends State<CreateFavPage> {
|
||||
text: '简介',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.onSurfaceVariant,
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
@@ -351,7 +349,7 @@ class _CreateFavPageState extends State<CreateFavPage> {
|
||||
hintText: '可填写简介',
|
||||
hintStyle: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
color: theme.colorScheme.outline,
|
||||
),
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide.none,
|
||||
@@ -372,7 +370,7 @@ class _CreateFavPageState extends State<CreateFavPage> {
|
||||
_isPublic = !_isPublic;
|
||||
});
|
||||
},
|
||||
tileColor: Theme.of(context).colorScheme.onInverseSurface,
|
||||
tileColor: theme.colorScheme.onInverseSurface,
|
||||
leading: Text(
|
||||
'公开',
|
||||
style: leadingStyle,
|
||||
|
||||
@@ -31,6 +31,7 @@ class _FavPanelState extends State<FavPanel> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return NotificationListener<DraggableScrollableNotification>(
|
||||
onNotification: (notification) {
|
||||
if (notification.extent <= 1e-5) {
|
||||
@@ -62,7 +63,7 @@ class _FavPanelState extends State<FavPanel> {
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.add,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
label: const Text('新建收藏夹'),
|
||||
style: TextButton.styleFrom(
|
||||
@@ -156,7 +157,7 @@ class _FavPanelState extends State<FavPanel> {
|
||||
),
|
||||
Divider(
|
||||
height: 1,
|
||||
color: Theme.of(context).disabledColor.withOpacity(0.08),
|
||||
color: theme.disabledColor.withOpacity(0.08),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
@@ -177,9 +178,8 @@ class _FavPanelState extends State<FavPanel> {
|
||||
horizontal: -1,
|
||||
vertical: -2,
|
||||
),
|
||||
foregroundColor: Theme.of(context).colorScheme.outline,
|
||||
backgroundColor:
|
||||
Theme.of(context).colorScheme.onInverseSurface,
|
||||
foregroundColor: theme.colorScheme.outline,
|
||||
backgroundColor: theme.colorScheme.onInverseSurface,
|
||||
),
|
||||
child: const Text('取消'),
|
||||
),
|
||||
|
||||
@@ -68,6 +68,7 @@ class _GroupPanelState extends State<GroupPanel> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return NotificationListener<DraggableScrollableNotification>(
|
||||
onNotification: (notification) {
|
||||
if (notification.extent <= 1e-5) {
|
||||
@@ -159,7 +160,7 @@ class _GroupPanelState extends State<GroupPanel> {
|
||||
),
|
||||
Divider(
|
||||
height: 1,
|
||||
color: Theme.of(context).disabledColor.withOpacity(0.08),
|
||||
color: theme.disabledColor.withOpacity(0.08),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
@@ -175,8 +176,8 @@ class _GroupPanelState extends State<GroupPanel> {
|
||||
onPressed: () => onSave(),
|
||||
style: TextButton.styleFrom(
|
||||
padding: const EdgeInsets.only(left: 30, right: 30),
|
||||
foregroundColor: Theme.of(context).colorScheme.onPrimary,
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
foregroundColor: theme.colorScheme.onPrimary,
|
||||
backgroundColor: theme.colorScheme.primary,
|
||||
),
|
||||
child: Text(showDefaultBtn ? '保存至默认分组' : '保存'),
|
||||
),
|
||||
|
||||
@@ -10,9 +10,10 @@ class MenuRow extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
color: theme.colorScheme.surface,
|
||||
padding: const EdgeInsets.only(top: 9, bottom: 9, left: 12),
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
@@ -50,11 +51,11 @@ class MenuRow extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget actionRowLineItem(
|
||||
BuildContext context, Function? onTap, bool? loadingStatus, String? text,
|
||||
ThemeData theme, Function? onTap, bool? loadingStatus, String? text,
|
||||
{bool selectStatus = false}) {
|
||||
return Material(
|
||||
color: selectStatus
|
||||
? Theme.of(context).highlightColor.withOpacity(0.2)
|
||||
? theme.highlightColor.withOpacity(0.2)
|
||||
: Colors.transparent,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(30)),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
@@ -70,7 +71,7 @@ class MenuRow extends StatelessWidget {
|
||||
border: Border.all(
|
||||
color: selectStatus
|
||||
? Colors.transparent
|
||||
: Theme.of(context).highlightColor.withOpacity(0.2),
|
||||
: theme.highlightColor.withOpacity(0.2),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
@@ -84,8 +85,8 @@ class MenuRow extends StatelessWidget {
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: selectStatus
|
||||
? Theme.of(context).colorScheme.onSurface
|
||||
: Theme.of(context).colorScheme.outline),
|
||||
? theme.colorScheme.onSurface
|
||||
: theme.colorScheme.outline),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -115,9 +116,10 @@ class ActionRowLineItem extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Material(
|
||||
color: selectStatus
|
||||
? Theme.of(context).colorScheme.secondaryContainer
|
||||
? theme.colorScheme.secondaryContainer
|
||||
: Colors.transparent,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(30)),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
@@ -133,7 +135,7 @@ class ActionRowLineItem extends StatelessWidget {
|
||||
border: Border.all(
|
||||
color: selectStatus
|
||||
? Colors.transparent
|
||||
: Theme.of(context).colorScheme.secondaryContainer,
|
||||
: theme.colorScheme.secondaryContainer,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
@@ -144,8 +146,8 @@ class ActionRowLineItem extends StatelessWidget {
|
||||
iconData,
|
||||
size: 13,
|
||||
color: selectStatus
|
||||
? Theme.of(context).colorScheme.onSecondaryContainer
|
||||
: Theme.of(context).colorScheme.outline,
|
||||
? theme.colorScheme.onSecondaryContainer
|
||||
: theme.colorScheme.outline,
|
||||
)
|
||||
else if (icon != null)
|
||||
icon!,
|
||||
@@ -157,8 +159,8 @@ class ActionRowLineItem extends StatelessWidget {
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: selectStatus
|
||||
? Theme.of(context).colorScheme.onSecondaryContainer
|
||||
: Theme.of(context).colorScheme.outline),
|
||||
? theme.colorScheme.onSecondaryContainer
|
||||
: theme.colorScheme.outline),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -87,6 +87,7 @@ class _PagesPanelState extends State<PagesPanel> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
if (widget.showEpisodes != null)
|
||||
@@ -102,7 +103,7 @@ class _PagesPanelState extends State<PagesPanel> {
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
color: theme.colorScheme.outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -145,7 +146,7 @@ class _PagesPanelState extends State<PagesPanel> {
|
||||
right: i != pages.length - 1 ? 10 : 0,
|
||||
),
|
||||
child: Material(
|
||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
||||
color: theme.colorScheme.onInverseSurface,
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: InkWell(
|
||||
@@ -175,7 +176,7 @@ class _PagesPanelState extends State<PagesPanel> {
|
||||
if (isCurrentIndex) ...<Widget>[
|
||||
Image.asset(
|
||||
'assets/images/live.png',
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
color: theme.colorScheme.primary,
|
||||
height: 12,
|
||||
semanticLabel: "正在播放:",
|
||||
),
|
||||
@@ -188,8 +189,8 @@ class _PagesPanelState extends State<PagesPanel> {
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: isCurrentIndex
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: Theme.of(context).colorScheme.onSurface,
|
||||
? theme.colorScheme.primary
|
||||
: theme.colorScheme.onSurface,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
))
|
||||
|
||||
@@ -88,6 +88,7 @@ class _SeasonPanelState extends State<SeasonPanel> {
|
||||
if (episodes.isEmpty) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
final theme = Theme.of(context);
|
||||
return Builder(builder: (BuildContext context) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(
|
||||
@@ -96,7 +97,7 @@ class _SeasonPanelState extends State<SeasonPanel> {
|
||||
right: 2,
|
||||
),
|
||||
child: Material(
|
||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
||||
color: theme.colorScheme.onInverseSurface,
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: InkWell(
|
||||
@@ -117,14 +118,14 @@ class _SeasonPanelState extends State<SeasonPanel> {
|
||||
Expanded(
|
||||
child: Text(
|
||||
'合集:${videoDetail.ugcSeason!.title!}',
|
||||
style: Theme.of(context).textTheme.labelMedium,
|
||||
style: theme.textTheme.labelMedium,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 15),
|
||||
Image.asset(
|
||||
'assets/images/live.png',
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
color: theme.colorScheme.primary,
|
||||
height: 12,
|
||||
semanticLabel: "正在播放:",
|
||||
),
|
||||
@@ -132,7 +133,7 @@ class _SeasonPanelState extends State<SeasonPanel> {
|
||||
Obx(
|
||||
() => Text(
|
||||
'${currentIndex.value + 1}/${episodes.length}',
|
||||
style: Theme.of(context).textTheme.labelMedium,
|
||||
style: theme.textTheme.labelMedium,
|
||||
semanticsLabel:
|
||||
'第${currentIndex.value + 1}集,共${episodes.length}集',
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user