fixed multiline section header with leading widget
This commit is contained in:
parent
a7e4389519
commit
6f31f03451
2 changed files with 76 additions and 44 deletions
|
@ -54,36 +54,38 @@ class TitleSectionHeader extends StatelessWidget {
|
|||
|
||||
const TitleSectionHeader({Key key, this.leading, this.title}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final text = OutlinedText(
|
||||
title,
|
||||
style: TextStyle(
|
||||
color: Colors.grey[200],
|
||||
static const leadingDimension = 32.0;
|
||||
static const leadingPadding = EdgeInsets.only(right: 8, bottom: 4);
|
||||
static const textStyle = TextStyle(
|
||||
color: Color(0xFFEEEEEE),
|
||||
fontSize: 20,
|
||||
fontFamily: 'Concourse Caps',
|
||||
shadows: [
|
||||
Shadow(
|
||||
offset: const Offset(0, 2),
|
||||
offset: Offset(0, 2),
|
||||
blurRadius: 3,
|
||||
color: Colors.grey[900],
|
||||
color: Color(0xFF212121),
|
||||
),
|
||||
],
|
||||
),
|
||||
outlineColor: Colors.black87,
|
||||
outlineWidth: 2,
|
||||
);
|
||||
return Container(
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: leading != null
|
||||
? Row(
|
||||
children: [
|
||||
leading,
|
||||
const SizedBox(width: 8),
|
||||
text,
|
||||
],
|
||||
child: OutlinedText(
|
||||
leadingBuilder: leading != null
|
||||
? (context, isShadow) => Container(
|
||||
padding: leadingPadding,
|
||||
width: leadingDimension,
|
||||
height: leadingDimension,
|
||||
child: isShadow ? null : leading,
|
||||
)
|
||||
: text,
|
||||
: null,
|
||||
text: title,
|
||||
style: textStyle,
|
||||
outlineWidth: 2,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +1,41 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
typedef OutlinedWidgetBuilder = Widget Function(BuildContext context, bool isShadow);
|
||||
|
||||
class OutlinedText extends StatelessWidget {
|
||||
final String data;
|
||||
final OutlinedWidgetBuilder leadingBuilder;
|
||||
final String text;
|
||||
final TextStyle style;
|
||||
final double outlineWidth;
|
||||
final Color outlineColor;
|
||||
|
||||
const OutlinedText(
|
||||
this.data, {
|
||||
static const leadingAlignment = PlaceholderAlignment.middle;
|
||||
|
||||
const OutlinedText({
|
||||
Key key,
|
||||
this.style,
|
||||
@required this.outlineWidth,
|
||||
@required this.outlineColor,
|
||||
}) : super(key: key);
|
||||
this.leadingBuilder,
|
||||
@required this.text,
|
||||
@required this.style,
|
||||
double outlineWidth,
|
||||
Color outlineColor,
|
||||
}) : outlineWidth = outlineWidth ?? 1,
|
||||
outlineColor = outlineColor ?? Colors.black,
|
||||
super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Stack(
|
||||
children: [
|
||||
Text(
|
||||
data,
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
if (leadingBuilder != null)
|
||||
WidgetSpan(
|
||||
alignment: leadingAlignment,
|
||||
child: leadingBuilder(context, true),
|
||||
),
|
||||
TextSpan(
|
||||
text: text,
|
||||
style: style.copyWith(
|
||||
foreground: Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
|
@ -27,11 +43,25 @@ class OutlinedText extends StatelessWidget {
|
|||
..color = outlineColor,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
data,
|
||||
],
|
||||
),
|
||||
),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
if (leadingBuilder != null)
|
||||
WidgetSpan(
|
||||
alignment: leadingAlignment,
|
||||
child: leadingBuilder(context, false),
|
||||
),
|
||||
TextSpan(
|
||||
text: text,
|
||||
style: style,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue