diff --git a/secant.xcodeproj/project.pbxproj b/secant.xcodeproj/project.pbxproj index 229482d..ac5b36c 100644 --- a/secant.xcodeproj/project.pbxproj +++ b/secant.xcodeproj/project.pbxproj @@ -35,7 +35,7 @@ 0D4E7A1B26B364180058B01E /* secantTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D4E7A1A26B364180058B01E /* secantTests.swift */; }; 0D4E7A2626B364180058B01E /* secantUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D4E7A2526B364180058B01E /* secantUITests.swift */; }; 0D5D16F526E24CCF00AD33D1 /* AppError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D5D16F426E24CCF00AD33D1 /* AppError.swift */; }; - 0D7DF08C271DCC0E00530046 /* Background.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D7DF08B271DCC0E00530046 /* Background.swift */; }; + 0D7DF08C271DCC0E00530046 /* VLinearGradient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D7DF08B271DCC0E00530046 /* VLinearGradient.swift */; }; 0D864A0526E1546000A61879 /* LoadingScreenTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D864A0426E1546000A61879 /* LoadingScreenTests.swift */; }; 0D864A0926E154FD00A61879 /* InitFailedScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D864A0726E154FD00A61879 /* InitFailedScreen.swift */; }; 0D864A0A26E154FD00A61879 /* InitFailedScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D864A0826E154FD00A61879 /* InitFailedScreenViewModel.swift */; }; @@ -119,7 +119,7 @@ 0D4E7A2526B364180058B01E /* secantUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = secantUITests.swift; sourceTree = ""; }; 0D4E7A2726B364180058B01E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 0D5D16F426E24CCF00AD33D1 /* AppError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppError.swift; sourceTree = ""; }; - 0D7DF08B271DCC0E00530046 /* Background.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Background.swift; sourceTree = ""; }; + 0D7DF08B271DCC0E00530046 /* VLinearGradient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VLinearGradient.swift; sourceTree = ""; }; 0D864A0426E1546000A61879 /* LoadingScreenTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingScreenTests.swift; sourceTree = ""; }; 0D864A0726E154FD00A61879 /* InitFailedScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InitFailedScreen.swift; sourceTree = ""; }; 0D864A0826E154FD00A61879 /* InitFailedScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InitFailedScreenViewModel.swift; sourceTree = ""; }; @@ -406,7 +406,7 @@ 663FAB9A271D873300E495F8 /* Buttons */, 66A0807A271993C500118B79 /* OnboardingProgressIndicator.swift */, 0DB8AA80271DC7520035BC9D /* DesignGuide.swift */, - 0D7DF08B271DCC0E00530046 /* Background.swift */, + 0D7DF08B271DCC0E00530046 /* VLinearGradient.swift */, ); path = "UI Components"; sourceTree = ""; @@ -723,7 +723,7 @@ 0DA13C9026C15D1D00E3B610 /* WelcomeScreenViewModel.swift in Sources */, 66A0807B271993C500118B79 /* OnboardingProgressIndicator.swift in Sources */, 663FAB9E271D875700E495F8 /* CreateButton.swift in Sources */, - 0D7DF08C271DCC0E00530046 /* Background.swift in Sources */, + 0D7DF08C271DCC0E00530046 /* VLinearGradient.swift in Sources */, 0DA13C8F26C15D1D00E3B610 /* WelcomeScreen.swift in Sources */, 0D32282826C586E000262533 /* RequestZcashScreen.swift in Sources */, 0D32283226C5877A00262533 /* BalanceScreen.swift in Sources */, diff --git a/secant/UI Components/Background.swift b/secant/UI Components/Background.swift deleted file mode 100644 index 31c1357..0000000 --- a/secant/UI Components/Background.swift +++ /dev/null @@ -1,32 +0,0 @@ -// -// Background.swift -// secant-testnet -// -// Created by Francisco Gindre on 10/18/21. -// - -import SwiftUI - -struct Background: View { - var colors = [ - Asset.Colors.Background.linearGradientStart.color, - Asset.Colors.Background.linearGradientEnd.color - ] - var body: some View { - LinearGradient( - colors: colors, - startPoint: UnitPoint(x: 0.5, y: 0), - endPoint: UnitPoint(x: 0.5, y: 1) - ) - .edgesIgnoringSafeArea(.all) - } -} - -struct Background_Previews: PreviewProvider { - static var previews: some View { - Background() - .preferredColorScheme(.light) - Background() - .preferredColorScheme(.dark) - } -} diff --git a/secant/UI Components/DesignGuide.swift b/secant/UI Components/DesignGuide.swift index e9c334d..e59e776 100644 --- a/secant/UI Components/DesignGuide.swift +++ b/secant/UI Components/DesignGuide.swift @@ -9,35 +9,33 @@ import SwiftUI struct DesignGuide: View { var body: some View { - ZStack { - Background() - VStack(spacing: 30) { - Button(action: {}) { - Text("Primary Button") - } - .primaryButtonStyle - .frame(height: 50) - - Button(action: {}) { - Text("Primary Active Button") - } - .createButtonStyle - .frame(height: 50) - - Button(action: {}) { - Text("Secondary Button") - } - .secondaryButtonStyle - .frame(height: 50) - - Button(action: {}) { - Text("Action Button") - } - .activeButtonStyle - .frame(height: 50) + VStack(spacing: 30) { + Button(action: {}) { + Text("Primary Button") } - .padding(.horizontal, 30) + .primaryButtonStyle + .frame(height: 50) + + Button(action: {}) { + Text("Primary Active Button") + } + .createButtonStyle + .frame(height: 50) + + Button(action: {}) { + Text("Secondary Button") + } + .secondaryButtonStyle + .frame(height: 50) + + Button(action: {}) { + Text("Action Button") + } + .activeButtonStyle + .frame(height: 50) } + .padding(.horizontal, 30) + .linearGradientBackground() } } diff --git a/secant/UI Components/VLinearGradient.swift b/secant/UI Components/VLinearGradient.swift new file mode 100644 index 0000000..27f5227 --- /dev/null +++ b/secant/UI Components/VLinearGradient.swift @@ -0,0 +1,55 @@ +// +// Background.swift +// secant-testnet +// +// Created by Francisco Gindre on 10/18/21. +// + +import SwiftUI +/** + A Vertical LinearGradient that takes an array of Colors and renders them vertically in a centered fashion. +*/ +struct VLinearGradient: View { + var colors = [ + Asset.Colors.Background.linearGradientStart.color, + Asset.Colors.Background.linearGradientEnd.color + ] + var body: some View { + LinearGradient( + colors: colors, + startPoint: UnitPoint(x: 0.5, y: 0), + endPoint: UnitPoint(x: 0.5, y: 1) + ) + } +} + +struct VLinearGradientBackgroundModifier: ViewModifier { + func body(content: Content) -> some View { + ZStack { + VLinearGradient() + .edgesIgnoringSafeArea(.all) + content + } + } +} + +extension View { + /** + Adds a Vertical Linear Gradient with the default Colors of VLinearGradient. Supports both Light and Dark Mode + */ + func linearGradientBackground() -> some View { + self.modifier( + VLinearGradientBackgroundModifier() + ) + } +} + +struct Background_Previews: PreviewProvider { + static var previews: some View { + VStack { + Text("Hello") + } + .linearGradientBackground() + .preferredColorScheme(.light) + } +}