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

fix: Made comment and author text optional for ZdsComment #50

Merged
merged 1 commit into from
Dec 5, 2024
Merged
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
40 changes: 21 additions & 19 deletions lib/src/components/molecules/comment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import '../../../zds_flutter.dart';
class ZdsComment extends StatelessWidget {
/// Constructs a [ZdsComment] widget.
const ZdsComment({
required this.comment,
required this.author,
this.author,
this.comment,
this.isReply = false,
this.avatar,
this.timeStamp,
Expand All @@ -31,7 +31,7 @@ class ZdsComment extends StatelessWidget {
);

/// The comment text.
final String comment;
final String? comment;

/// The avatar widget to display.
/// Should be a [ZetaAvatar]
Expand All @@ -41,7 +41,7 @@ class ZdsComment extends StatelessWidget {
final String? timeStamp;

/// The author of the comment.
final String author;
final String? author;

/// Whether the comment is a reply.
/// If this is true, the reply action will automatically be hidden.
Expand Down Expand Up @@ -142,12 +142,13 @@ class ZdsComment extends StatelessWidget {
padding: EdgeInsets.only(right: spacing.small),
child: avatar,
),
Text(
author,
style: ZetaTextStyles.labelLarge.copyWith(
fontWeight: FontWeight.w500,
if (author != null)
Text(
author!,
style: ZetaTextStyles.labelLarge.copyWith(
fontWeight: FontWeight.w500,
),
),
),
const Spacer(),
if (timeStamp != null)
Padding(
Expand All @@ -160,17 +161,18 @@ class ZdsComment extends StatelessWidget {
],
),
),
Padding(
padding: EdgeInsets.only(
top: spacing.small,
left: spacing.minimum,
right: spacing.minimum,
),
child: Text(
comment,
style: Theme.of(context).textTheme.bodyMedium,
if (comment != null)
Padding(
padding: EdgeInsets.only(
top: spacing.small,
left: spacing.minimum,
right: spacing.minimum,
),
child: Text(
comment!,
style: Theme.of(context).textTheme.bodyMedium,
),
),
),
if (attachment != null)
Padding(
padding: EdgeInsets.only(top: spacing.medium),
Expand Down
Loading