-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(neon_rich_text): Separate building rich object from text spa…
…n rendering Signed-off-by: provokateurin <kate@provokateurin.de>
- Loading branch information
1 parent
98c102f
commit 4f486d7
Showing
5 changed files
with
56 additions
and
47 deletions.
There are no files selected for viewing
5 changes: 1 addition & 4 deletions
5
packages/neon_framework/packages/neon_rich_text/lib/neon_rich_text.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
export 'src/rich_objects/deck_card.dart'; | ||
export 'src/rich_objects/fallback.dart'; | ||
export 'src/rich_objects/file.dart'; | ||
export 'src/rich_objects/mention.dart'; | ||
export 'src/rich_objects/rich_objects.dart' hide buildRichObjectParameter; | ||
export 'src/rich_text.dart'; |
52 changes: 52 additions & 0 deletions
52
packages/neon_framework/packages/neon_rich_text/lib/src/rich_objects/rich_objects.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:meta/meta.dart'; | ||
import 'package:neon_rich_text/src/rich_objects/deck_card.dart'; | ||
import 'package:neon_rich_text/src/rich_objects/fallback.dart'; | ||
import 'package:neon_rich_text/src/rich_objects/file.dart'; | ||
import 'package:neon_rich_text/src/rich_objects/mention.dart'; | ||
import 'package:nextcloud/core.dart' as core; | ||
|
||
export 'deck_card.dart'; | ||
export 'fallback.dart'; | ||
export 'file.dart'; | ||
export 'mention.dart'; | ||
|
||
/// Renders a rich object [parameter] to be interactive. | ||
@internal | ||
InlineSpan buildRichObjectParameter({ | ||
required core.RichObjectParameter parameter, | ||
required TextStyle? textStyle, | ||
required bool isPreview, | ||
}) { | ||
if (isPreview) { | ||
return TextSpan( | ||
text: parameter.name, | ||
style: textStyle, | ||
); | ||
} | ||
|
||
return WidgetSpan( | ||
alignment: PlaceholderAlignment.middle, | ||
child: switch (parameter.type) { | ||
core.RichObjectParameter_Type.user || | ||
core.RichObjectParameter_Type.call || | ||
core.RichObjectParameter_Type.guest || | ||
core.RichObjectParameter_Type.userGroup => | ||
NeonRichObjectMention( | ||
parameter: parameter, | ||
textStyle: textStyle, | ||
), | ||
core.RichObjectParameter_Type.file => NeonRichObjectFile( | ||
parameter: parameter, | ||
textStyle: textStyle, | ||
), | ||
core.RichObjectParameter_Type.deckCard => NeonRichObjectDeckCard( | ||
parameter: parameter, | ||
), | ||
_ => NeonRichObjectFallback( | ||
parameter: parameter, | ||
textStyle: textStyle, | ||
), | ||
}, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters