highlight title review
This commit is contained in:
parent
f9c2156fed
commit
07abd4091c
6 changed files with 50 additions and 32 deletions
|
@ -8,6 +8,9 @@ class OutlinedText extends StatelessWidget {
|
||||||
final Color outlineColor;
|
final Color outlineColor;
|
||||||
final double outlineBlurSigma;
|
final double outlineBlurSigma;
|
||||||
final TextAlign? textAlign;
|
final TextAlign? textAlign;
|
||||||
|
final bool? softWrap;
|
||||||
|
final TextOverflow? overflow;
|
||||||
|
final int? maxLines;
|
||||||
|
|
||||||
static const widgetSpanAlignment = PlaceholderAlignment.middle;
|
static const widgetSpanAlignment = PlaceholderAlignment.middle;
|
||||||
|
|
||||||
|
@ -18,6 +21,9 @@ class OutlinedText extends StatelessWidget {
|
||||||
Color? outlineColor,
|
Color? outlineColor,
|
||||||
double? outlineBlurSigma,
|
double? outlineBlurSigma,
|
||||||
this.textAlign,
|
this.textAlign,
|
||||||
|
this.softWrap,
|
||||||
|
this.overflow,
|
||||||
|
this.maxLines,
|
||||||
}) : outlineWidth = outlineWidth ?? 1,
|
}) : outlineWidth = outlineWidth ?? 1,
|
||||||
outlineColor = outlineColor ?? Colors.black,
|
outlineColor = outlineColor ?? Colors.black,
|
||||||
outlineBlurSigma = outlineBlurSigma ?? 0;
|
outlineBlurSigma = outlineBlurSigma ?? 0;
|
||||||
|
@ -49,6 +55,9 @@ class OutlinedText extends StatelessWidget {
|
||||||
children: textSpans.map(_toStrokeSpan).toList(),
|
children: textSpans.map(_toStrokeSpan).toList(),
|
||||||
),
|
),
|
||||||
textAlign: textAlign,
|
textAlign: textAlign,
|
||||||
|
softWrap: softWrap,
|
||||||
|
overflow: overflow,
|
||||||
|
maxLines: maxLines,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text.rich(
|
Text.rich(
|
||||||
|
@ -56,6 +65,9 @@ class OutlinedText extends StatelessWidget {
|
||||||
children: hasOutline ? textSpans.map(_toFillSpan).toList() : textSpans,
|
children: hasOutline ? textSpans.map(_toFillSpan).toList() : textSpans,
|
||||||
),
|
),
|
||||||
textAlign: textAlign,
|
textAlign: textAlign,
|
||||||
|
softWrap: softWrap,
|
||||||
|
overflow: overflow,
|
||||||
|
maxLines: maxLines,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
|
@ -24,7 +24,8 @@ class _HighlightDecorationPainter extends BoxPainter {
|
||||||
final confHeight = size.height;
|
final confHeight = size.height;
|
||||||
final paintHeight = confHeight * .4;
|
final paintHeight = confHeight * .4;
|
||||||
final rect = Rect.fromLTWH(offset.dx, offset.dy + confHeight - paintHeight, size.width, paintHeight);
|
final rect = Rect.fromLTWH(offset.dx, offset.dy + confHeight - paintHeight, size.width, paintHeight);
|
||||||
|
final rrect = RRect.fromRectAndRadius(rect, Radius.circular(paintHeight));
|
||||||
final paint = Paint()..color = decoration.color;
|
final paint = Paint()..color = decoration.color;
|
||||||
canvas.drawRect(rect, paint);
|
canvas.drawRRect(rrect, paint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import 'dart:ui';
|
||||||
import 'package:aves/model/settings/enums/enums.dart';
|
import 'package:aves/model/settings/enums/enums.dart';
|
||||||
import 'package:aves/model/settings/settings.dart';
|
import 'package:aves/model/settings/settings.dart';
|
||||||
import 'package:aves/theme/colors.dart';
|
import 'package:aves/theme/colors.dart';
|
||||||
|
import 'package:aves/widgets/common/basic/outlined_text.dart';
|
||||||
import 'package:aves/widgets/common/fx/highlight_decoration.dart';
|
import 'package:aves/widgets/common/fx/highlight_decoration.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
@ -11,7 +12,7 @@ class HighlightTitle extends StatelessWidget {
|
||||||
final String title;
|
final String title;
|
||||||
final Color? color;
|
final Color? color;
|
||||||
final double fontSize;
|
final double fontSize;
|
||||||
final bool enabled, selectable;
|
final bool enabled;
|
||||||
final bool showHighlight;
|
final bool showHighlight;
|
||||||
|
|
||||||
const HighlightTitle({
|
const HighlightTitle({
|
||||||
|
@ -20,24 +21,23 @@ class HighlightTitle extends StatelessWidget {
|
||||||
this.color,
|
this.color,
|
||||||
this.fontSize = 18,
|
this.fontSize = 18,
|
||||||
this.enabled = true,
|
this.enabled = true,
|
||||||
this.selectable = false,
|
|
||||||
this.showHighlight = true,
|
this.showHighlight = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
static const disabledColor = Colors.grey;
|
static const disabledColor = Colors.grey;
|
||||||
|
|
||||||
static const shadows = [
|
static List<Shadow> shadows(BuildContext context) => [
|
||||||
Shadow(
|
Shadow(
|
||||||
color: Colors.black,
|
color: Theme.of(context).brightness == Brightness.dark ? Colors.black : Colors.white,
|
||||||
offset: Offset(1, 1),
|
offset: const Offset(0, 1),
|
||||||
blurRadius: 2,
|
blurRadius: 2,
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final style = TextStyle(
|
final style = TextStyle(
|
||||||
shadows: Theme.of(context).brightness == Brightness.dark ? shadows : null,
|
shadows: shadows(context),
|
||||||
fontSize: fontSize,
|
fontSize: fontSize,
|
||||||
letterSpacing: 1.0,
|
letterSpacing: 1.0,
|
||||||
fontFeatures: const [FontFeature.enable('smcp')],
|
fontFeatures: const [FontFeature.enable('smcp')],
|
||||||
|
@ -47,25 +47,25 @@ class HighlightTitle extends StatelessWidget {
|
||||||
return Align(
|
return Align(
|
||||||
alignment: AlignmentDirectional.centerStart,
|
alignment: AlignmentDirectional.centerStart,
|
||||||
child: Container(
|
child: Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 2),
|
||||||
decoration: showHighlight && context.select<Settings, bool>((v) => v.themeColorMode == AvesThemeColorMode.polychrome)
|
decoration: showHighlight && context.select<Settings, bool>((v) => v.themeColorMode == AvesThemeColorMode.polychrome)
|
||||||
? HighlightDecoration(
|
? HighlightDecoration(
|
||||||
color: enabled ? color ?? colors.fromString(title) : disabledColor,
|
color: enabled ? color ?? colors.fromString(title) : disabledColor,
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
margin: const EdgeInsets.symmetric(vertical: 4.0),
|
margin: const EdgeInsets.symmetric(vertical: 4.0),
|
||||||
child: selectable
|
child: OutlinedText(
|
||||||
? SelectableText(
|
textSpans: [
|
||||||
title,
|
TextSpan(
|
||||||
style: style,
|
text: title,
|
||||||
maxLines: 1,
|
style: style,
|
||||||
)
|
),
|
||||||
: Text(
|
],
|
||||||
title,
|
outlineColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
style: style,
|
softWrap: false,
|
||||||
softWrap: false,
|
overflow: TextOverflow.fade,
|
||||||
overflow: TextOverflow.fade,
|
maxLines: 1,
|
||||||
maxLines: 1,
|
),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import 'package:aves/model/settings/settings.dart';
|
||||||
import 'package:aves/ref/brand_colors.dart';
|
import 'package:aves/ref/brand_colors.dart';
|
||||||
import 'package:aves/theme/colors.dart';
|
import 'package:aves/theme/colors.dart';
|
||||||
import 'package:aves/theme/durations.dart';
|
import 'package:aves/theme/durations.dart';
|
||||||
|
import 'package:aves/widgets/common/basic/outlined_text.dart';
|
||||||
import 'package:aves/widgets/common/extensions/build_context.dart';
|
import 'package:aves/widgets/common/extensions/build_context.dart';
|
||||||
import 'package:aves/widgets/common/fx/highlight_decoration.dart';
|
import 'package:aves/widgets/common/fx/highlight_decoration.dart';
|
||||||
import 'package:aves/widgets/common/identity/highlight_title.dart';
|
import 'package:aves/widgets/common/identity/highlight_title.dart';
|
||||||
|
@ -100,15 +101,21 @@ class _RemoveEntryMetadataDialogState extends State<RemoveEntryMetadataDialog> {
|
||||||
|
|
||||||
Widget _toTile(MetadataType type) {
|
Widget _toTile(MetadataType type) {
|
||||||
final text = type.getText();
|
final text = type.getText();
|
||||||
Widget child = Text(
|
Widget child = OutlinedText(
|
||||||
text,
|
textSpans: [
|
||||||
style: TextStyle(
|
TextSpan(
|
||||||
shadows: Theme.of(context).brightness == Brightness.dark ? HighlightTitle.shadows : null,
|
text: text,
|
||||||
),
|
style: TextStyle(
|
||||||
|
shadows: HighlightTitle.shadows(context),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
outlineColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
);
|
);
|
||||||
if (context.select<Settings, bool>((v) => v.themeColorMode == AvesThemeColorMode.polychrome)) {
|
if (context.select<Settings, bool>((v) => v.themeColorMode == AvesThemeColorMode.polychrome)) {
|
||||||
final colors = context.watch<AvesColorsData>();
|
final colors = context.watch<AvesColorsData>();
|
||||||
child = DecoratedBox(
|
child = Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 2),
|
||||||
decoration: HighlightDecoration(
|
decoration: HighlightDecoration(
|
||||||
color: colors.fromBrandColor(BrandColors.get(text)) ?? colors.fromString(text),
|
color: colors.fromBrandColor(BrandColors.get(text)) ?? colors.fromString(text),
|
||||||
),
|
),
|
||||||
|
|
|
@ -92,7 +92,6 @@ class _XmpCardState extends State<XmpCard> {
|
||||||
Expanded(
|
Expanded(
|
||||||
child: HighlightTitle(
|
child: HighlightTitle(
|
||||||
title: widget.title,
|
title: widget.title,
|
||||||
selectable: true,
|
|
||||||
showHighlight: false,
|
showHighlight: false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -116,7 +116,6 @@ class XmpNamespace extends Equatable {
|
||||||
child: HighlightTitle(
|
child: HighlightTitle(
|
||||||
title: displayTitle,
|
title: displayTitle,
|
||||||
color: context.select<AvesColorsData, Color?>((v) => v.fromBrandColor(BrandColors.get(displayTitle))),
|
color: context.select<AvesColorsData, Color?>((v) => v.fromBrandColor(BrandColors.get(displayTitle))),
|
||||||
selectable: true,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
...content
|
...content
|
||||||
|
|
Loading…
Reference in a new issue