opt: get theme color

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-04-28 21:32:30 +08:00
parent 451a84e696
commit ca993df0c6
149 changed files with 4415 additions and 4803 deletions

View File

@@ -275,6 +275,9 @@ abstract class CommonPublishPageState<T extends CommonPublishPage>
}
Widget buildImage(int index, double height) {
final color =
Theme.of(context).colorScheme.secondaryContainer.withOpacity(0.5);
void onClear() {
pathList.removeAt(index);
if (pathList.isEmpty && editController.text.trim().isEmpty) {
@@ -319,10 +322,7 @@ abstract class CommonPublishPageState<T extends CommonPublishPage>
},
size: 24,
iconSize: 14,
bgColor: Theme.of(context)
.colorScheme
.secondaryContainer
.withOpacity(0.5),
bgColor: color,
),
),
Positioned(
@@ -334,10 +334,7 @@ abstract class CommonPublishPageState<T extends CommonPublishPage>
onPressed: onClear,
size: 24,
iconSize: 14,
bgColor: Theme.of(context)
.colorScheme
.secondaryContainer
.withOpacity(0.5),
bgColor: color,
),
),
],
@@ -345,14 +342,14 @@ abstract class CommonPublishPageState<T extends CommonPublishPage>
}
void onCropImage(int index) async {
final theme = Theme.of(context);
CroppedFile? croppedFile = await ImageCropper().cropImage(
sourcePath: pathList[index],
uiSettings: [
AndroidUiSettings(
toolbarTitle: '裁剪',
toolbarColor: Theme.of(context).colorScheme.secondaryContainer,
toolbarWidgetColor:
Theme.of(context).colorScheme.onSecondaryContainer,
toolbarColor: theme.colorScheme.secondaryContainer,
toolbarWidgetColor: theme.colorScheme.onSecondaryContainer,
),
IOSUiSettings(
title: '裁剪',

View File

@@ -19,19 +19,20 @@ abstract class CommonSlidePageState<T extends CommonSlidePage>
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return enableSlide
? Padding(
padding: EdgeInsets.only(top: padding),
child: buildPage,
child: buildPage(theme),
)
: buildPage;
: buildPage(theme);
}
Widget get buildPage;
Widget buildPage(ThemeData theme);
Widget get buildList => throw UnimplementedError();
Widget buildList(ThemeData theme) => throw UnimplementedError();
Widget slideList([Widget? buildList]) => GestureDetector(
Widget slideList(ThemeData theme, [Widget? buildList]) => GestureDetector(
onPanDown: (event) {
if (event.localPosition.dx > 30) {
isSliding = false;
@@ -86,6 +87,6 @@ abstract class CommonSlidePageState<T extends CommonSlidePage>
downPos = null;
isSliding = null;
},
child: buildList ?? this.buildList,
child: buildList ?? this.buildList(theme),
);
}