fixed header clipping when selection button pushes text on new line
This commit is contained in:
parent
aedd0de6c9
commit
e0d1e150bc
3 changed files with 57 additions and 30 deletions
|
@ -6,7 +6,6 @@ import 'package:aves/utils/android_file_utils.dart';
|
||||||
import 'package:aves/utils/constants.dart';
|
import 'package:aves/utils/constants.dart';
|
||||||
import 'package:aves/widgets/album/grid/header_album.dart';
|
import 'package:aves/widgets/album/grid/header_album.dart';
|
||||||
import 'package:aves/widgets/album/grid/header_date.dart';
|
import 'package:aves/widgets/album/grid/header_date.dart';
|
||||||
import 'package:aves/widgets/common/fx/outlined_text.dart';
|
|
||||||
import 'package:aves/widgets/common/icons.dart';
|
import 'package:aves/widgets/common/icons.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
|
@ -16,11 +15,13 @@ import 'package:provider/provider.dart';
|
||||||
class SectionHeader extends StatelessWidget {
|
class SectionHeader extends StatelessWidget {
|
||||||
final CollectionLens collection;
|
final CollectionLens collection;
|
||||||
final dynamic sectionKey;
|
final dynamic sectionKey;
|
||||||
|
final double height;
|
||||||
|
|
||||||
const SectionHeader({
|
const SectionHeader({
|
||||||
Key key,
|
Key key,
|
||||||
@required this.collection,
|
@required this.collection,
|
||||||
@required this.sectionKey,
|
@required this.sectionKey,
|
||||||
|
@required this.height,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -48,7 +49,12 @@ class SectionHeader extends StatelessWidget {
|
||||||
header = _buildAlbumSectionHeader();
|
header = _buildAlbumSectionHeader();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return header ?? const SizedBox.shrink();
|
return header != null
|
||||||
|
? SizedBox(
|
||||||
|
height: height,
|
||||||
|
child: header,
|
||||||
|
)
|
||||||
|
: const SizedBox.shrink();
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildAlbumSectionHeader() {
|
Widget _buildAlbumSectionHeader() {
|
||||||
|
@ -113,6 +119,7 @@ class TitleSectionHeader extends StatelessWidget {
|
||||||
static const leadingPadding = EdgeInsets.only(right: 8, bottom: 4);
|
static const leadingPadding = EdgeInsets.only(right: 8, bottom: 4);
|
||||||
static const trailingPadding = EdgeInsets.only(left: 8, bottom: 4);
|
static const trailingPadding = EdgeInsets.only(left: 8, bottom: 4);
|
||||||
static const padding = EdgeInsets.all(16);
|
static const padding = EdgeInsets.all(16);
|
||||||
|
static const widgetSpanAlignment = PlaceholderAlignment.middle;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -120,27 +127,37 @@ class TitleSectionHeader extends StatelessWidget {
|
||||||
alignment: AlignmentDirectional.centerStart,
|
alignment: AlignmentDirectional.centerStart,
|
||||||
padding: padding,
|
padding: padding,
|
||||||
constraints: const BoxConstraints(minHeight: leadingDimension),
|
constraints: const BoxConstraints(minHeight: leadingDimension),
|
||||||
child: OutlinedText(
|
child: RichText(
|
||||||
leadingBuilder: (context, isShadow) => SectionSelectableLeading(
|
text: TextSpan(
|
||||||
sectionKey: sectionKey,
|
children: [
|
||||||
browsingBuilder: (context) => leading != null
|
WidgetSpan(
|
||||||
? Container(
|
alignment: widgetSpanAlignment,
|
||||||
padding: leadingPadding,
|
child: SectionSelectableLeading(
|
||||||
width: leadingDimension,
|
sectionKey: sectionKey,
|
||||||
height: leadingDimension,
|
browsingBuilder: (context) => leading != null
|
||||||
child: isShadow ? null : leading,
|
? Container(
|
||||||
)
|
padding: leadingPadding,
|
||||||
: const SizedBox(height: leadingDimension),
|
width: leadingDimension,
|
||||||
),
|
height: leadingDimension,
|
||||||
text: title,
|
child: leading,
|
||||||
trailingBuilder: trailing != null
|
)
|
||||||
? (context, isShadow) => Container(
|
: const SizedBox(height: leadingDimension),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextSpan(
|
||||||
|
text: title,
|
||||||
|
style: Constants.titleTextStyle,
|
||||||
|
),
|
||||||
|
if (trailing != null)
|
||||||
|
WidgetSpan(
|
||||||
|
alignment: widgetSpanAlignment,
|
||||||
|
child: Container(
|
||||||
padding: trailingPadding,
|
padding: trailingPadding,
|
||||||
child: isShadow ? null : trailing,
|
child: trailing,
|
||||||
)
|
),
|
||||||
: null,
|
),
|
||||||
style: Constants.titleTextStyle,
|
],
|
||||||
outlineWidth: 2,
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,12 @@ class SectionedListLayoutProvider extends StatelessWidget {
|
||||||
maxOffset: sectionMaxOffset,
|
maxOffset: sectionMaxOffset,
|
||||||
headerExtent: headerExtent,
|
headerExtent: headerExtent,
|
||||||
tileExtent: tileExtent,
|
tileExtent: tileExtent,
|
||||||
builder: (context, listIndex) => _buildInSection(listIndex - sectionFirstIndex, collection, sectionKey),
|
builder: (context, listIndex) => _buildInSection(
|
||||||
|
listIndex - sectionFirstIndex,
|
||||||
|
collection,
|
||||||
|
sectionKey,
|
||||||
|
headerExtent,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -75,14 +80,9 @@ class SectionedListLayoutProvider extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildInSection(int sectionChildIndex, CollectionLens collection, dynamic sectionKey) {
|
Widget _buildInSection(int sectionChildIndex, CollectionLens collection, dynamic sectionKey, double headerExtent) {
|
||||||
if (sectionChildIndex == 0) {
|
if (sectionChildIndex == 0) {
|
||||||
return collection.showHeaders
|
return headerBuilder(collection, sectionKey, headerExtent);
|
||||||
? SectionHeader(
|
|
||||||
collection: collection,
|
|
||||||
sectionKey: sectionKey,
|
|
||||||
)
|
|
||||||
: const SizedBox.shrink();
|
|
||||||
}
|
}
|
||||||
sectionChildIndex--;
|
sectionChildIndex--;
|
||||||
|
|
||||||
|
@ -101,6 +101,16 @@ class SectionedListLayoutProvider extends StatelessWidget {
|
||||||
children: children,
|
children: children,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget headerBuilder(CollectionLens collection, dynamic sectionKey, double headerExtent) {
|
||||||
|
return collection.showHeaders
|
||||||
|
? SectionHeader(
|
||||||
|
collection: collection,
|
||||||
|
sectionKey: sectionKey,
|
||||||
|
height: headerExtent,
|
||||||
|
)
|
||||||
|
: const SizedBox.shrink();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SectionedListLayout {
|
class SectionedListLayout {
|
||||||
|
|
Loading…
Reference in a new issue