Skip to content

Commit

Permalink
fix: Made comment and author text optional for ZdsComment (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecoomber authored Dec 5, 2024
1 parent 3752c60 commit 34ef2f5
Showing 1 changed file with 21 additions and 19 deletions.
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

0 comments on commit 34ef2f5

Please sign in to comment.