Last active
March 29, 2021 00:19
-
-
Save marlonjames71/63dc5461235ac3d88e7542ce42788ea1 to your computer and use it in GitHub Desktop.
DropDownMenu Code Snippets
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
extension Color { | |
static let bg = Color("mainBG") | |
static let secondaryBG = Color("secondaryBG") | |
static let greyText = Color("greyText") | |
} |
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
extension View { | |
@ViewBuilder func embedInScrollView(_ shouldEmbed: Bool = true, | |
axis: Axis.Set = .vertical, | |
showsIndicators: Bool = true) -> some View { | |
if shouldEmbed { | |
ScrollView(axis, showsIndicators: showsIndicators) { | |
self | |
} | |
} else { | |
self | |
} | |
} | |
} |
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
import SwiftUI | |
struct SelectionHighlightView: View { | |
let color: Color | |
let opacity: Double | |
let padding: Bool | |
init(_ color: Color = .blue, | |
opacity: Double, | |
padding: Bool = true) { | |
self.color = color | |
self.opacity = opacity | |
self.padding = padding | |
} | |
var body: some View { | |
color | |
.opacity(opacity) | |
.mask(RoundedRectangle(cornerRadius: 10.0)) | |
.padding(.horizontal, padding ? 6 : 0) | |
} | |
} |
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
import SwiftUI | |
struct SmoothRoundedCorners: ViewModifier { | |
let cornerRadius: CGFloat | |
init(_ cornerRadius: CGFloat) { | |
self.cornerRadius = cornerRadius | |
} | |
func body(content: Content) -> some View { | |
content | |
.clipShape(RoundedRectangle(cornerRadius: cornerRadius, style: .continuous)) | |
} | |
} | |
extension View { | |
func smoothRoundedCorners(_ cornerRadius: CGFloat = 10.0) -> some View { | |
modifier(SmoothRoundedCorners(cornerRadius)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment