Skip to content

Commit

Permalink
fix: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
vanlooverenkoen committed Oct 7, 2024
1 parent 3260eb5 commit fde3a37
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import 'package:impaktfull_ui_example/src/component_library/components/avatar/av
import 'package:impaktfull_ui_example/src/component_library/config/component_library_item.dart';
import 'package:impaktfull_ui_example/src/util/network_images.dart';

class AvatarLibraryVariant extends ComponentLibraryVariant<AvatarLibraryPrimaryInputs> {
class AvatarLibraryVariant
extends ComponentLibraryVariant<AvatarLibraryPrimaryInputs> {
const AvatarLibraryVariant();

@override
Expand All @@ -19,7 +20,8 @@ class AvatarLibraryVariant extends ComponentLibraryVariant<AvatarLibraryPrimaryI
),
ImpaktfullUiAvatar(
url: null,
onTap: () => ImpaktfullUiNotification.show(title: 'Empty Avatar tapped'),
onTap: () =>
ImpaktfullUiNotification.show(title: 'Empty Avatar tapped'),
),
];
}
Expand Down
26 changes: 18 additions & 8 deletions lib/src/components/notification_badge/notification_badge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ enum ImpaktfullUiNotificationBadgeLocation {
const ImpaktfullUiNotificationBadgeLocation(this.alignment);
}

class ImpaktfullUiNotificationBadge extends StatelessWidget with ComponentDescriptorMixin {
class ImpaktfullUiNotificationBadge extends StatelessWidget
with ComponentDescriptorMixin {
static const dotSize = 4.0;

final bool show;
Expand All @@ -40,7 +41,8 @@ class ImpaktfullUiNotificationBadge extends StatelessWidget with ComponentDescri

@override
Widget build(BuildContext context) {
return ImpaktfullUiComponentThemeBuidler<ImpaktfullUiNotificationBadgeTheme>(
return ImpaktfullUiComponentThemeBuidler<
ImpaktfullUiNotificationBadgeTheme>(
overrideComponentTheme: theme,
builder: (context, theme, componentTheme) {
final showBadge = show || text != null;
Expand Down Expand Up @@ -113,9 +115,11 @@ class ImpaktfullUiNotificationBadge extends StatelessWidget with ComponentDescri
}

Size _textWidth(String text, TextStyle style) {
final TextPainter textPainter =
TextPainter(text: TextSpan(text: text, style: style), maxLines: 1, textDirection: TextDirection.ltr)
..layout(minWidth: 0, maxWidth: double.infinity);
final TextPainter textPainter = TextPainter(
text: TextSpan(text: text, style: style),
maxLines: 1,
textDirection: TextDirection.ltr)
..layout(minWidth: 0, maxWidth: double.infinity);
return textPainter.size;
}

Expand All @@ -132,7 +136,9 @@ class ImpaktfullUiNotificationBadge extends StatelessWidget with ComponentDescri

double? _getBottom(double dotSize, double textWidth, double textHeight) {
final alignment = location.alignment;
if (alignment == Alignment.topCenter || alignment == Alignment.topLeft || alignment == Alignment.topRight) {
if (alignment == Alignment.topCenter ||
alignment == Alignment.topLeft ||
alignment == Alignment.topRight) {
return null;
}
if (text == null) return -(dotSize / 2);
Expand All @@ -141,7 +147,9 @@ class ImpaktfullUiNotificationBadge extends StatelessWidget with ComponentDescri

double? _getRight(double dotSize, double textWidth, double textHeight) {
final alignment = location.alignment;
if (alignment == Alignment.centerLeft || alignment == Alignment.topLeft || alignment == Alignment.bottomLeft) {
if (alignment == Alignment.centerLeft ||
alignment == Alignment.topLeft ||
alignment == Alignment.bottomLeft) {
return null;
}
if (text == null) return -(dotSize / 2);
Expand All @@ -150,7 +158,9 @@ class ImpaktfullUiNotificationBadge extends StatelessWidget with ComponentDescri

double? _getLeft(double dotSize, double textWidth, double textHeight) {
final alignment = location.alignment;
if (alignment == Alignment.centerRight || alignment == Alignment.topRight || alignment == Alignment.bottomRight) {
if (alignment == Alignment.centerRight ||
alignment == Alignment.topRight ||
alignment == Alignment.bottomRight) {
return null;
}
if (text == null) return -(dotSize / 2);
Expand Down

0 comments on commit fde3a37

Please sign in to comment.