Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional text diagrams demonstrating overflow #228

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed assets/widgets/text.png
Binary file not shown.
Binary file modified assets/widgets/text_ellipsis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/widgets/text_fade_max_lines.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/widgets/text_fade_soft_wrap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 27 additions & 19 deletions packages/diagrams/lib/src/text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import 'package:flutter/rendering.dart';

import 'diagram_step.dart';

const String _text = 'text';
const String _textEllipsis = 'text_ellipsis';
const String _textFadeMaxLines = 'text_fade_max_lines';
const String _textFadeSoftWrap = 'text_fade_soft_wrap';
const String _textRich = 'text_rich';
const String _textBorder = 'text_border';
const String _textGradient = 'text_gradient';
Expand All @@ -28,24 +29,30 @@ class TextDiagram extends StatelessWidget with DiagramMetadata {
Widget returnWidget;

switch (name) {
case _text:
returnWidget = const Text(
'Hello, Ruth! How are you?',
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontWeight: FontWeight.bold),
);
break;
case _textEllipsis:
returnWidget = ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 100),
child: const Text(
'Hello, Ruth! How are you?',
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontWeight: FontWeight.bold),
),
);
returnWidget = Container(
width: 100,
decoration: BoxDecoration(border: Border.all()),
child: const Text(
overflow: TextOverflow.ellipsis, 'Hello Ruth, how are you?'));
break;
case _textFadeMaxLines:
returnWidget = Container(
width: 100,
decoration: BoxDecoration(border: Border.all()),
child: const Text(
overflow: TextOverflow.fade,
maxLines: 1,
'Hello Ruth, how are you?'));
break;
case _textFadeSoftWrap:
returnWidget = Container(
width: 100,
decoration: BoxDecoration(border: Border.all()),
child: const Text(
overflow: TextOverflow.fade,
softWrap: false,
'Hello Ruth, how are you?'));
break;
case _textRich:
returnWidget = const Text.rich(
Expand Down Expand Up @@ -1063,8 +1070,9 @@ class TextDiagramStep extends DiagramStep {

@override
Future<List<TextDiagram>> get diagrams async => <TextDiagram>[
const TextDiagram(_text),
const TextDiagram(_textEllipsis),
const TextDiagram(_textFadeMaxLines),
const TextDiagram(_textFadeSoftWrap),
const TextDiagram(_textRich),
const TextDiagram(_textBorder),
const TextDiagram(_textGradient),
Expand Down