Skip to content

Commit

Permalink
Mark card size variable
Browse files Browse the repository at this point in the history
  • Loading branch information
milanvarady committed Jan 7, 2025
1 parent 8f7fd99 commit 41e1a30
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 33 deletions.
9 changes: 6 additions & 3 deletions Applite/Views/Components/Card.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ import SwiftUI

/// A reusabe view that adds a rounded rectange background shadow
struct Card<Content: View>: View {
let cardWidth: CGFloat
let cardHeight: CGFloat
let paddig: CGFloat
@ViewBuilder let content: Content

init(paddig: CGFloat = 5, content: () -> Content) {
self.paddig = paddig
self.content = content()
}

var body: some View {
content
.frame(maxWidth: .infinity, maxHeight: .infinity) // Take available space
.padding(paddig)
.frame(width: cardWidth, height: cardHeight)
.background(.regularMaterial)
.clipShape(RoundedRectangle(cornerRadius: 8))
.shadow(radius: 3)
Expand Down
37 changes: 17 additions & 20 deletions Applite/Views/Detail Views/App Migration/AppMigrationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,28 @@ import SwiftUI

struct AppMigrationView: View {
let width: CGFloat = 620
let columnSpacing: CGFloat = 40

var cardWidth: CGFloat {
(width - columnSpacing) / 2
}
let cardHeight: CGFloat = 220
let cardPadding: CGFloat = 24

var body: some View {
VStack {
titleAndDescription
.padding(.vertical, 40)

HStack(spacing: columnSpacing) {
Card(cardWidth: cardWidth, cardHeight: cardHeight, paddig: cardPadding) {
ExportView()
}

Card(cardWidth: cardWidth, cardHeight: cardHeight, paddig: cardPadding) {
ImportView()
ScrollView {
VStack {
titleAndDescription
.padding(.vertical, 40)

HStack(spacing: 40) {
Card(paddig: cardPadding) {
ExportView()
}

Card(paddig: cardPadding) {
ImportView()
}
}

Spacer()
}

Spacer()
.frame(maxWidth: width)
}
.frame(maxWidth: width)
}

var titleAndDescription: some View {
Expand All @@ -50,4 +46,5 @@ struct AppMigrationView: View {

#Preview {
AppMigrationView()
.padding()
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ extension BrewManagementView {
@Binding var modifyingBrew: Bool
let cardWidth: CGFloat
let cardPadding: CGFloat
let cardHeight: CGFloat = 210

@State var updateDone = false
@State var reinstallDone = false
Expand All @@ -39,8 +38,6 @@ extension BrewManagementView {

HStack {
ActionCard(
cardWidth: cardWidth,
cardHeight: cardHeight,
paddig: cardPadding,
actionSuccessful: $updateDone,
remarks: [
Expand All @@ -49,10 +46,9 @@ extension BrewManagementView {
) {
updateButton
}
.frame(width: cardWidth)

ActionCard(
cardWidth: cardWidth,
cardHeight: cardHeight,
paddig: cardPadding,
actionSuccessful: $reinstallDone,
remarks: [
Expand All @@ -62,6 +58,7 @@ extension BrewManagementView {
) {
reinstallButton
}
.frame(width: cardWidth)
}
.padding(.bottom, 10)

Expand All @@ -82,15 +79,13 @@ extension BrewManagementView {
}

private struct ActionCard<ActionButton: View>: View {
let cardWidth: CGFloat
let cardHeight: CGFloat
let paddig: CGFloat
@Binding var actionSuccessful: Bool
let remarks: [Remark]
@ViewBuilder let actionButton: ActionButton

var body: some View {
Card(cardWidth: cardWidth, cardHeight: cardHeight, paddig: paddig) {
Card(paddig: paddig) {
VStack(alignment: .leading) {
HStack {
actionButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ extension BrewManagementView {

HStack {
infoCard(title: "Homebrew Version", info: homebrewVersion)
.frame(width: cardWidth)

infoCard(title: "Apps Installed", info: numberOfCasks)
.frame(width: cardWidth)
}
}
.task {
Expand All @@ -45,7 +47,7 @@ extension BrewManagementView {
}

private func infoCard(title: LocalizedStringKey, info: String) -> some View {
Card(cardWidth: cardWidth, cardHeight: cardHeight, paddig: cardPadding) {
Card {
VStack {
Text(title)
.font(.system(size: 16, weight: .bold))
Expand Down
3 changes: 2 additions & 1 deletion Applite/Views/Setup/SetupView+BrewPathDetectedView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ extension SetupView {

Text("A brew installation was detected at:")

Card(cardWidth: 200, cardHeight: 30, paddig: 5) {
Card {
HStack {
Image(systemName: "mug")
Text(BrewPaths.currentBrewDirectory)
.font(.system(size: 12, design: .monospaced))
}
}
.frame(maxWidth: 200, maxHeight: 20)
.padding(.bottom)

Text("Continue to use detected installation or select another option below.")
Expand Down

0 comments on commit 41e1a30

Please sign in to comment.