Skip to content

Commit

Permalink
Run swiftformat
Browse files Browse the repository at this point in the history
  • Loading branch information
salavert authored and github-actions[bot] committed Nov 26, 2024
1 parent 2d1d9ae commit b1753a2
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ struct PosterCardCatalogView: View {

enum AssetType: String, CaseIterable, Identifiable, Equatable {
var id: Self { self }

case none
case icon
case circledIcon
case image

func toPosterCardAssetType() -> PosterCardAssetType {
switch self {
case .none:
Expand All @@ -45,7 +45,7 @@ struct PosterCardCatalogView: View {
}
}
}

enum MediaType: String, CaseIterable, Identifiable, Equatable {
var id: Self { self }

Expand Down Expand Up @@ -158,7 +158,7 @@ struct PosterCardCatalogView: View {
}
.disabled(mediaType == .video)
}

section("Top Actions") {
Picker("Top Actions", selection: $topAction) {
ForEach(TopAction.allCases) {
Expand All @@ -167,7 +167,7 @@ struct PosterCardCatalogView: View {
}
.disabled(mediaType == .video)
}

section("Options") {
VStack {
Toggle("Has slot", isOn: $hasSlot)
Expand Down
163 changes: 81 additions & 82 deletions Sources/MisticaSwiftUI/Components/Cards/PosterCard/PosterCard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -188,90 +188,89 @@ public struct PosterCard<Slot>: View where Slot: View {
// MARK: - View Body

public var body: some View {
Button(action: { action() }) {
VStack(alignment: .leading, spacing: .zero) {

HStack(alignment: .top, spacing: .zero) {
assetView
.accessibilityLabel(assetAccessibilityLabel)
.accessibilityIdentifier(assetAccessibilityIdentifier)
Spacer()
topActionsView
}

Button(action: { action() }) {
VStack(alignment: .leading, spacing: .zero) {
HStack(alignment: .top, spacing: .zero) {
assetView
.accessibilityLabel(assetAccessibilityLabel)
.accessibilityIdentifier(assetAccessibilityIdentifier)
Spacer()
.frame(maxHeight: .infinity)

VStack(alignment: .leading, spacing: Constants.spacing) {
if let tag = tag {
tag
.inverse(true)
.padding(.bottom, Constants.spacing)
.accessibilityLabel(tagAccessibilityLabel)
.accessibilityIdentifier(tagAccessibilityIdentifier)
}

if let preTitle = preTitle {
Text(preTitle)
.font(.textPreset2(weight: .regular))
.foregroundColor(textPrimaryColor)
.padding(.bottom, -Constants.spacing)
.lineLimit(Constants.defaultLineLimit)
.fixedSize(horizontal: false, vertical: true)
.accessibilityLabel(preTitleAccessibilityLabel)
.accessibilityIdentifier(preTitleAccessibilityIdentifier)
}
topActionsView
}

Spacer()
.frame(maxHeight: .infinity)

VStack(alignment: .leading, spacing: Constants.spacing) {
if let tag = tag {
tag
.inverse(true)
.padding(.bottom, Constants.spacing)
.accessibilityLabel(tagAccessibilityLabel)
.accessibilityIdentifier(tagAccessibilityIdentifier)
}

Text(title)
.font(.textPreset4(weight: .regular))
if let preTitle = preTitle {
Text(preTitle)
.font(.textPreset2(weight: .regular))
.foregroundColor(textPrimaryColor)
.padding(.bottom, -Constants.spacing)
.lineLimit(Constants.defaultLineLimit)
.fixedSize(horizontal: false, vertical: true)
.accessibilityLabel(preTitleAccessibilityLabel)
.accessibilityIdentifier(preTitleAccessibilityIdentifier)
}

Text(title)
.font(.textPreset4(weight: .regular))
.foregroundColor(textPrimaryColor)
.lineLimit(Constants.longerLineLimit)
.multilineTextAlignment(.leading)
.fixedSize(horizontal: false, vertical: true)
.accessibilityLabel(titleAccessibilityLabel)
.accessibilityIdentifier(titleAccessibilityIdentifier)

if let subTitle = subTitle {
Text(subTitle)
.font(.textPreset2(weight: .regular))
.foregroundColor(textPrimaryColor)
.lineLimit(Constants.defaultLineLimit)
.fixedSize(horizontal: false, vertical: true)
.accessibilityLabel(subtitleAccessibilityLabel)
.accessibilityIdentifier(subtitleAccessibilityIdentifier)
}
if let description = description {
Text(description)
.font(.textPreset2(weight: .regular))
.foregroundColor(textPrimaryColor)
.lineLimit(Constants.longerLineLimit)
.multilineTextAlignment(.leading)
.fixedSize(horizontal: false, vertical: true)
.accessibilityLabel(titleAccessibilityLabel)
.accessibilityIdentifier(titleAccessibilityIdentifier)

if let subTitle = subTitle {
Text(subTitle)
.font(.textPreset2(weight: .regular))
.foregroundColor(textPrimaryColor)
.lineLimit(Constants.defaultLineLimit)
.fixedSize(horizontal: false, vertical: true)
.accessibilityLabel(subtitleAccessibilityLabel)
.accessibilityIdentifier(subtitleAccessibilityIdentifier)
}
if let description = description {
Text(description)
.font(.textPreset2(weight: .regular))
.foregroundColor(textPrimaryColor)
.lineLimit(Constants.longerLineLimit)
.multilineTextAlignment(.leading)
.fixedSize(horizontal: false, vertical: true)
.accessibilityLabel(descriptionAccessibilityLabel)
.accessibilityIdentifier(descriptionAccessibilityIdentifier)
}
if hasSlotView {
slot
.padding(.top, Constants.spacing * 2)
}
.accessibilityLabel(descriptionAccessibilityLabel)
.accessibilityIdentifier(descriptionAccessibilityIdentifier)
}
.padding(.top, Constants.spacing * 4)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)
}
.padding(.top, Constants.spacing * 2)
.padding(.horizontal, Constants.spacing * 2)
.padding(.bottom, Constants.spacing * 3)
.aspectRatio(aspectRatio.value, contentMode: .fill)
.background(
ZStack(alignment: .center) {
mediaContent
mediaContentOverlay
if hasSlotView {
slot
.padding(.top, Constants.spacing * 2)
}
)
.fixedSize(horizontal: false, vertical: true)
.border(borderColor, width: borderWidth)
.round(radiusStyle: .container)
}
.padding(.top, Constants.spacing * 4)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)
}
.padding(.top, Constants.spacing * 2)
.padding(.horizontal, Constants.spacing * 2)
.padding(.bottom, Constants.spacing * 3)
.aspectRatio(aspectRatio.value, contentMode: .fill)
.background(
ZStack(alignment: .center) {
mediaContent
mediaContentOverlay
}
)
.fixedSize(horizontal: false, vertical: true)
.border(borderColor, width: borderWidth)
.round(radiusStyle: .container)
}
}
}

Expand Down Expand Up @@ -483,7 +482,7 @@ private extension PosterCard {
}
case let .image(_, topActions),
let .customColor(_, topActions),
let .skinColor(_, topActions):
let .skinColor(_, topActions):
switch topActions {
case .none:
EmptyView()
Expand Down Expand Up @@ -513,21 +512,21 @@ private extension PosterCard {
.resizable()
.scaledToFit()
.frame(width: Constants.assetTypeImageSize, height: Constants.assetTypeImageSize)

case let .icon(image, foregroundColor, backgroundColor):
ZStack {
if let backgroundColor = backgroundColor {
Circle().fill(backgroundColor)
.frame(width: Constants.assetTypeImageSize, height: Constants.assetTypeImageSize)
}

image
.resizable()
.foregroundColor(foregroundColor)
.scaledToFit()
.frame(width: Constants.assetTypeIcontSize, height: Constants.assetTypeIcontSize)
}

case .none:
EmptyView()
}
Expand Down Expand Up @@ -583,7 +582,7 @@ public enum PosterCardTopActions: Equatable {

/// Two custom actions.
case twoActions(PosterCardAction, PosterCardAction)

public static func == (lhs: PosterCardTopActions, rhs: PosterCardTopActions) -> Bool {
switch (lhs, rhs) {
case (.none, .none):
Expand Down Expand Up @@ -619,9 +618,9 @@ public struct PosterCardAction: Equatable {
self.icon = icon
self.callback = callback
}

public static func == (lhs: PosterCardAction, rhs: PosterCardAction) -> Bool {
return lhs.icon == rhs.icon // Compare only the `icon` property
lhs.icon == rhs.icon // Compare only the `icon` property
}
}

Expand Down

0 comments on commit b1753a2

Please sign in to comment.