-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extracts a new control from the Favorites section of the OriginDestin…
…ationSheetView This change DRYs up the Favorites section a bit
- Loading branch information
1 parent
fafc43b
commit 007e48f
Showing
4 changed files
with
59 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// FavoriteView.swift | ||
// OTPKit | ||
// | ||
// Created by Aaron Brethorst on 7/31/24. | ||
// | ||
|
||
import SwiftUI | ||
|
||
/// A button that wraps a circle with an icon above a line of text. | ||
struct FavoriteView: View { | ||
private let title: String | ||
private let imageName: String | ||
private let action: VoidBlock? | ||
|
||
init(title: String, imageName: String, action: VoidBlock? = nil) { | ||
self.title = title | ||
self.imageName = imageName | ||
self.action = action | ||
} | ||
var body: some View { | ||
Button(action: { | ||
action?() | ||
}, label: { | ||
VStack(alignment: .center) { | ||
Image(systemName: imageName) | ||
.frame(width: 48, height: 48) | ||
.background(Color.gray.opacity(0.5)) | ||
.clipShape(Circle()) | ||
|
||
Text(title) | ||
.font(.caption) | ||
.frame(width: 64) | ||
.lineLimit(1) | ||
.truncationMode(.tail) | ||
} | ||
.padding(.all, 4) | ||
.foregroundStyle(.black) | ||
}) | ||
} | ||
} | ||
|
||
#Preview { | ||
FavoriteView(title: "Hello, world!", imageName: "mappin") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// | ||
// Utilities.swift | ||
// OTPKit | ||
// | ||
// Created by Aaron Brethorst on 7/31/24. | ||
// | ||
|
||
import Foundation | ||
|
||
typealias VoidBlock = () -> Void |