From 8847064f4524166df04795073b82e44ead34b0b6 Mon Sep 17 00:00:00 2001 From: Francisco Gindre Date: Mon, 18 Oct 2021 13:04:15 -0300 Subject: [PATCH 1/5] Background Linear Gradient component + Design Guide --- secant.xcodeproj/project.pbxproj | 12 ++-- .../Colors.xcassets/Background/Contents.json | 6 ++ .../LinearGradientEnd.colorset/Contents.json | 38 ++++++++++++ .../Contents.json | 38 ++++++++++++ secant/Generated/XCAssets+Generated.swift | 4 ++ secant/Screens/Home/HomeScreen.swift | 9 ++- .../Restore Wallet/RestoreWalletScreen.swift | 3 +- .../Welcome Screen/WelcomeScreen.swift | 6 +- secant/UI Components/Background.swift | 32 ++++++++++ .../UI Components/Buttons/PlainButton.swift | 62 ------------------- secant/UI Components/DesignGuide.swift | 52 ++++++++++++++++ 11 files changed, 190 insertions(+), 72 deletions(-) create mode 100644 secant/Colors.xcassets/Background/Contents.json create mode 100644 secant/Colors.xcassets/Background/LinearGradientEnd.colorset/Contents.json create mode 100644 secant/Colors.xcassets/Background/LinearGradientStart.colorset/Contents.json create mode 100644 secant/UI Components/Background.swift delete mode 100644 secant/UI Components/Buttons/PlainButton.swift create mode 100644 secant/UI Components/DesignGuide.swift diff --git a/secant.xcodeproj/project.pbxproj b/secant.xcodeproj/project.pbxproj index d92dc9f..229482d 100644 --- a/secant.xcodeproj/project.pbxproj +++ b/secant.xcodeproj/project.pbxproj @@ -35,6 +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 */; }; 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 */; }; @@ -42,7 +43,6 @@ 0D864A0F26E1583000A61879 /* LoadingScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D864A0D26E1583000A61879 /* LoadingScreenViewModel.swift */; }; 0DA13C8F26C15D1D00E3B610 /* WelcomeScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DA13C8D26C15D1D00E3B610 /* WelcomeScreen.swift */; }; 0DA13C9026C15D1D00E3B610 /* WelcomeScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DA13C8E26C15D1D00E3B610 /* WelcomeScreenViewModel.swift */; }; - 0DA13C9326C15E2F00E3B610 /* PlainButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DA13C9226C15E2F00E3B610 /* PlainButton.swift */; }; 0DA13C9726C186FF00E3B610 /* RestoreWalletScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DA13C9526C186FF00E3B610 /* RestoreWalletScreen.swift */; }; 0DA13C9826C186FF00E3B610 /* RestoreWalletScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DA13C9626C186FF00E3B610 /* RestoreWalletScreenViewModel.swift */; }; 0DA13C9C26C1942100E3B610 /* BackupWalletScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DA13C9A26C1942100E3B610 /* BackupWalletScreen.swift */; }; @@ -50,6 +50,7 @@ 0DA13CA126C1955600E3B610 /* HomeScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DA13C9F26C1955600E3B610 /* HomeScreen.swift */; }; 0DA13CA226C1955600E3B610 /* HomeScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DA13CA026C1955600E3B610 /* HomeScreenViewModel.swift */; }; 0DA13CA526C1963000E3B610 /* Balance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DA13CA426C1963000E3B610 /* Balance.swift */; }; + 0DB8AA81271DC7520035BC9D /* DesignGuide.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DB8AA80271DC7520035BC9D /* DesignGuide.swift */; }; 660558E9270C7A54009D6954 /* Colors.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 660558E8270C7A54009D6954 /* Colors.xcassets */; }; 660558F7270C862F009D6954 /* Fonts+Generated.swift in Sources */ = {isa = PBXBuildFile; fileRef = 660558F5270C862F009D6954 /* Fonts+Generated.swift */; }; 660558F8270C862F009D6954 /* XCAssets+Generated.swift in Sources */ = {isa = PBXBuildFile; fileRef = 660558F6270C862F009D6954 /* XCAssets+Generated.swift */; }; @@ -118,6 +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 = ""; }; 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 = ""; }; @@ -125,7 +127,6 @@ 0D864A0D26E1583000A61879 /* LoadingScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingScreenViewModel.swift; sourceTree = ""; }; 0DA13C8D26C15D1D00E3B610 /* WelcomeScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WelcomeScreen.swift; sourceTree = ""; }; 0DA13C8E26C15D1D00E3B610 /* WelcomeScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WelcomeScreenViewModel.swift; sourceTree = ""; }; - 0DA13C9226C15E2F00E3B610 /* PlainButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlainButton.swift; sourceTree = ""; }; 0DA13C9526C186FF00E3B610 /* RestoreWalletScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RestoreWalletScreen.swift; sourceTree = ""; }; 0DA13C9626C186FF00E3B610 /* RestoreWalletScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RestoreWalletScreenViewModel.swift; sourceTree = ""; }; 0DA13C9A26C1942100E3B610 /* BackupWalletScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackupWalletScreen.swift; sourceTree = ""; }; @@ -133,6 +134,7 @@ 0DA13C9F26C1955600E3B610 /* HomeScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeScreen.swift; sourceTree = ""; }; 0DA13CA026C1955600E3B610 /* HomeScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeScreenViewModel.swift; sourceTree = ""; }; 0DA13CA426C1963000E3B610 /* Balance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Balance.swift; sourceTree = ""; }; + 0DB8AA80271DC7520035BC9D /* DesignGuide.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DesignGuide.swift; sourceTree = ""; }; 660558E8270C7A54009D6954 /* Colors.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Colors.xcassets; sourceTree = ""; }; 660558F5270C862F009D6954 /* Fonts+Generated.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Fonts+Generated.swift"; sourceTree = ""; }; 660558F6270C862F009D6954 /* XCAssets+Generated.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "XCAssets+Generated.swift"; sourceTree = ""; }; @@ -403,6 +405,8 @@ children = ( 663FAB9A271D873300E495F8 /* Buttons */, 66A0807A271993C500118B79 /* OnboardingProgressIndicator.swift */, + 0DB8AA80271DC7520035BC9D /* DesignGuide.swift */, + 0D7DF08B271DCC0E00530046 /* Background.swift */, ); path = "UI Components"; sourceTree = ""; @@ -454,7 +458,6 @@ 663FAB9A271D873300E495F8 /* Buttons */ = { isa = PBXGroup; children = ( - 0DA13C9226C15E2F00E3B610 /* PlainButton.swift */, 66DC733E271D88CC0053CBB6 /* StandardButtonStyle.swift */, 663FAB9B271D874D00E495F8 /* ActiveButton.swift */, 663FAB9D271D875700E495F8 /* CreateButton.swift */, @@ -697,6 +700,7 @@ 0DA13C9826C186FF00E3B610 /* RestoreWalletScreenViewModel.swift in Sources */, 0D32283326C5877A00262533 /* BalanceScreenViewModel.swift in Sources */, 0D5D16F526E24CCF00AD33D1 /* AppError.swift in Sources */, + 0DB8AA81271DC7520035BC9D /* DesignGuide.swift in Sources */, 0D32282326C586A800262533 /* HistoryScreen.swift in Sources */, 0D864A0A26E154FD00A61879 /* InitFailedScreenViewModel.swift in Sources */, 0DA13CA526C1963000E3B610 /* Balance.swift in Sources */, @@ -719,8 +723,8 @@ 0DA13C9026C15D1D00E3B610 /* WelcomeScreenViewModel.swift in Sources */, 66A0807B271993C500118B79 /* OnboardingProgressIndicator.swift in Sources */, 663FAB9E271D875700E495F8 /* CreateButton.swift in Sources */, + 0D7DF08C271DCC0E00530046 /* Background.swift in Sources */, 0DA13C8F26C15D1D00E3B610 /* WelcomeScreen.swift in Sources */, - 0DA13C9326C15E2F00E3B610 /* PlainButton.swift in Sources */, 0D32282826C586E000262533 /* RequestZcashScreen.swift in Sources */, 0D32283226C5877A00262533 /* BalanceScreen.swift in Sources */, 0D354A0A26D5A9D000315F45 /* KeyStoring.swift in Sources */, diff --git a/secant/Colors.xcassets/Background/Contents.json b/secant/Colors.xcassets/Background/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/secant/Colors.xcassets/Background/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/secant/Colors.xcassets/Background/LinearGradientEnd.colorset/Contents.json b/secant/Colors.xcassets/Background/LinearGradientEnd.colorset/Contents.json new file mode 100644 index 0000000..ded04f0 --- /dev/null +++ b/secant/Colors.xcassets/Background/LinearGradientEnd.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "extended-linear-srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xF3", + "green" : "0xE4", + "red" : "0xD2" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x5A", + "green" : "0x36", + "red" : "0x29" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/secant/Colors.xcassets/Background/LinearGradientStart.colorset/Contents.json b/secant/Colors.xcassets/Background/LinearGradientStart.colorset/Contents.json new file mode 100644 index 0000000..dd90c61 --- /dev/null +++ b/secant/Colors.xcassets/Background/LinearGradientStart.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "0xF9", + "green" : "0xEF", + "red" : "0xE3" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x55", + "green" : "0x31", + "red" : "0x24" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/secant/Generated/XCAssets+Generated.swift b/secant/Generated/XCAssets+Generated.swift index 7977694..1efff95 100644 --- a/secant/Generated/XCAssets+Generated.swift +++ b/secant/Generated/XCAssets+Generated.swift @@ -30,6 +30,10 @@ internal enum Asset { } } internal enum Colors { + internal enum Background { + internal static let linearGradientEnd = ColorAsset(name: "LinearGradientEnd") + internal static let linearGradientStart = ColorAsset(name: "LinearGradientStart") + } internal enum Buttons { internal static let activeButton = ColorAsset(name: "ActiveButton") internal static let createButton = ColorAsset(name: "CreateButton") diff --git a/secant/Screens/Home/HomeScreen.swift b/secant/Screens/Home/HomeScreen.swift index 337b5ca..fe64fec 100644 --- a/secant/Screens/Home/HomeScreen.swift +++ b/secant/Screens/Home/HomeScreen.swift @@ -56,21 +56,24 @@ struct HomeScreen: View { Button(action: {}, label: { Text("Request ZEC") }) - .buttonStyle(PlainButton()) + .primaryButtonStyle + .frame(height: 50) } @ViewBuilder var sendButton: some View { Button(action: {}, label: { Text("Send ZEC") }) - .buttonStyle(PlainButton()) + .primaryButtonStyle + .frame(height: 50) } @ViewBuilder var historyButton: some View { Button(action: {}, label: { Text("History") }) - .buttonStyle(PlainButton(style: .light)) + .primaryButtonStyle + .frame(height: 50) } } diff --git a/secant/Screens/Restore Wallet/RestoreWalletScreen.swift b/secant/Screens/Restore Wallet/RestoreWalletScreen.swift index 5289af7..722757d 100644 --- a/secant/Screens/Restore Wallet/RestoreWalletScreen.swift +++ b/secant/Screens/Restore Wallet/RestoreWalletScreen.swift @@ -23,7 +23,8 @@ struct RestoreWalletScreen: View { Button(action: {}, label: { Text("Restore Seed Phrase") }) - .buttonStyle(PlainButton()) + .primaryButtonStyle + .frame(height: 50) } .padding(.horizontal, 30) .padding(.vertical) diff --git a/secant/Screens/Welcome Screen/WelcomeScreen.swift b/secant/Screens/Welcome Screen/WelcomeScreen.swift index c88e900..b4ab3b7 100644 --- a/secant/Screens/Welcome Screen/WelcomeScreen.swift +++ b/secant/Screens/Welcome Screen/WelcomeScreen.swift @@ -28,14 +28,16 @@ struct WelcomeScreen: View { }, label: { Text("RESTORE WALLET") }) - .buttonStyle(PlainButton()) + .primaryButtonStyle + .frame(height: 50) Button(action: { self.viewModel.createNew() }, label: { Text("CREATE NEW WALLET") }) - .buttonStyle(PlainButton()) + .primaryButtonStyle + .frame(height: 50) } } .padding() diff --git a/secant/UI Components/Background.swift b/secant/UI Components/Background.swift new file mode 100644 index 0000000..31c1357 --- /dev/null +++ b/secant/UI Components/Background.swift @@ -0,0 +1,32 @@ +// +// 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/Buttons/PlainButton.swift b/secant/UI Components/Buttons/PlainButton.swift deleted file mode 100644 index b5a55fe..0000000 --- a/secant/UI Components/Buttons/PlainButton.swift +++ /dev/null @@ -1,62 +0,0 @@ -// -// PlainButton.swift -// secant -// -// Created by Francisco Gindre on 8/9/21. -// - -import SwiftUI - -struct PlainButton: ButtonStyle { - enum Theme { - case light - case bold - } - - var style = Theme.bold - - func makeBody(configuration: Configuration) -> some View { - configuration.label - .foregroundColor(style.foregroundColor) - .padding() - .frame(minWidth: 0, maxWidth: .infinity, minHeight: 48, maxHeight: 48) - .background(style.background) - } -} - -// MARK: - Previews - -struct PlainButton_Previews: PreviewProvider { - static var previews: some View { - VStack { - Button(action: {}, label: { - Text("Button") - }) - .buttonStyle(PlainButton()) - - Button(action: {}, label: { - Text("Button") - }) - .buttonStyle(PlainButton(style: .bold)) - } - .padding(.horizontal, 30) - } -} - -// MARK: - Theme - -extension PlainButton.Theme { - var background: some View { - switch self { - case .bold: return Color.black - default: return Color.white - } - } - - var foregroundColor: Color { - switch self { - case .bold: return Color.white - default: return Color.black - } - } -} diff --git a/secant/UI Components/DesignGuide.swift b/secant/UI Components/DesignGuide.swift new file mode 100644 index 0000000..e9c334d --- /dev/null +++ b/secant/UI Components/DesignGuide.swift @@ -0,0 +1,52 @@ +// +// DesignGuide.swift +// secant-testnet +// +// Created by Francisco Gindre on 10/18/21. +// + +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) + } + .padding(.horizontal, 30) + } + } +} + +struct DesignGuide_Previews: PreviewProvider { + static var previews: some View { + DesignGuide() + .preferredColorScheme(.dark) + + DesignGuide() + .preferredColorScheme(.light) + } +} From ec76786bf29a53565aed89698a41c6499e83ff33 Mon Sep 17 00:00:00 2001 From: Francisco Gindre Date: Mon, 18 Oct 2021 15:13:04 -0300 Subject: [PATCH 2/5] Rename Background View to VLinearGradient. Create ViewModifier --- secant.xcodeproj/project.pbxproj | 8 ++-- secant/UI Components/Background.swift | 32 ------------- secant/UI Components/DesignGuide.swift | 52 ++++++++++---------- secant/UI Components/VLinearGradient.swift | 55 ++++++++++++++++++++++ 4 files changed, 84 insertions(+), 63 deletions(-) delete mode 100644 secant/UI Components/Background.swift create mode 100644 secant/UI Components/VLinearGradient.swift 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) + } +} From fbe81e732074378047eb6b669ddf7c163b075a05 Mon Sep 17 00:00:00 2001 From: Francisco Gindre Date: Mon, 18 Oct 2021 16:45:57 -0300 Subject: [PATCH 3/5] specify background component naming --- secant.xcodeproj/project.pbxproj | 8 ++++---- secant/UI Components/DesignGuide.swift | 2 +- ...LinearGradient.swift => ScreenBackground.swift} | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) rename secant/UI Components/{VLinearGradient.swift => ScreenBackground.swift} (76%) diff --git a/secant.xcodeproj/project.pbxproj b/secant.xcodeproj/project.pbxproj index ac5b36c..caeb7c0 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 /* VLinearGradient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D7DF08B271DCC0E00530046 /* VLinearGradient.swift */; }; + 0D7DF08C271DCC0E00530046 /* ScreenBackground.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D7DF08B271DCC0E00530046 /* ScreenBackground.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 /* VLinearGradient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VLinearGradient.swift; sourceTree = ""; }; + 0D7DF08B271DCC0E00530046 /* ScreenBackground.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScreenBackground.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 /* VLinearGradient.swift */, + 0D7DF08B271DCC0E00530046 /* ScreenBackground.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 /* VLinearGradient.swift in Sources */, + 0D7DF08C271DCC0E00530046 /* ScreenBackground.swift in Sources */, 0DA13C8F26C15D1D00E3B610 /* WelcomeScreen.swift in Sources */, 0D32282826C586E000262533 /* RequestZcashScreen.swift in Sources */, 0D32283226C5877A00262533 /* BalanceScreen.swift in Sources */, diff --git a/secant/UI Components/DesignGuide.swift b/secant/UI Components/DesignGuide.swift index e59e776..b6d87d4 100644 --- a/secant/UI Components/DesignGuide.swift +++ b/secant/UI Components/DesignGuide.swift @@ -35,7 +35,7 @@ struct DesignGuide: View { .frame(height: 50) } .padding(.horizontal, 30) - .linearGradientBackground() + .applyScreenBackground() } } diff --git a/secant/UI Components/VLinearGradient.swift b/secant/UI Components/ScreenBackground.swift similarity index 76% rename from secant/UI Components/VLinearGradient.swift rename to secant/UI Components/ScreenBackground.swift index 27f5227..c18aad5 100644 --- a/secant/UI Components/VLinearGradient.swift +++ b/secant/UI Components/ScreenBackground.swift @@ -7,9 +7,9 @@ import SwiftUI /** - A Vertical LinearGradient that takes an array of Colors and renders them vertically in a centered fashion. + A Vertical LinearGradient that takes an array of Colors and renders them vertically in a centered fashion mostly used as a background for Screen views.. */ -struct VLinearGradient: View { +struct ScreenBackground: View { var colors = [ Asset.Colors.Background.linearGradientStart.color, Asset.Colors.Background.linearGradientEnd.color @@ -23,10 +23,10 @@ struct VLinearGradient: View { } } -struct VLinearGradientBackgroundModifier: ViewModifier { +struct ScreenBackgroundModifier: ViewModifier { func body(content: Content) -> some View { ZStack { - VLinearGradient() + ScreenBackground() .edgesIgnoringSafeArea(.all) content } @@ -37,9 +37,9 @@ extension View { /** Adds a Vertical Linear Gradient with the default Colors of VLinearGradient. Supports both Light and Dark Mode */ - func linearGradientBackground() -> some View { + func applyScreenBackground() -> some View { self.modifier( - VLinearGradientBackgroundModifier() + ScreenBackgroundModifier() ) } } @@ -49,7 +49,7 @@ struct Background_Previews: PreviewProvider { VStack { Text("Hello") } - .linearGradientBackground() + .applyScreenBackground() .preferredColorScheme(.light) } } From 931a78b67a8ac065a57f6fc9af131a784dce4e7b Mon Sep 17 00:00:00 2001 From: Francisco Gindre Date: Mon, 18 Oct 2021 17:13:25 -0300 Subject: [PATCH 4/5] amend the rename refactor xcode didn't do --- secant/UI Components/ScreenBackground.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/secant/UI Components/ScreenBackground.swift b/secant/UI Components/ScreenBackground.swift index c18aad5..5ff6854 100644 --- a/secant/UI Components/ScreenBackground.swift +++ b/secant/UI Components/ScreenBackground.swift @@ -1,5 +1,5 @@ // -// Background.swift +// ScreenBackground.swift // secant-testnet // // Created by Francisco Gindre on 10/18/21. @@ -44,7 +44,7 @@ extension View { } } -struct Background_Previews: PreviewProvider { +struct ScreenBackground_Previews: PreviewProvider { static var previews: some View { VStack { Text("Hello") From 7dffe415f292e12ec7df78e17744177f1a878908 Mon Sep 17 00:00:00 2001 From: Francisco Gindre Date: Mon, 18 Oct 2021 18:51:45 -0300 Subject: [PATCH 5/5] rename colors and their components --- .../{Background => ScreenBackground}/Contents.json | 0 .../gradientEnd.colorset}/Contents.json | 0 .../gradientStart.colorset}/Contents.json | 0 secant/Generated/XCAssets+Generated.swift | 8 ++++---- secant/UI Components/ScreenBackground.swift | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) rename secant/Colors.xcassets/{Background => ScreenBackground}/Contents.json (100%) rename secant/Colors.xcassets/{Background/LinearGradientEnd.colorset => ScreenBackground/gradientEnd.colorset}/Contents.json (100%) rename secant/Colors.xcassets/{Background/LinearGradientStart.colorset => ScreenBackground/gradientStart.colorset}/Contents.json (100%) diff --git a/secant/Colors.xcassets/Background/Contents.json b/secant/Colors.xcassets/ScreenBackground/Contents.json similarity index 100% rename from secant/Colors.xcassets/Background/Contents.json rename to secant/Colors.xcassets/ScreenBackground/Contents.json diff --git a/secant/Colors.xcassets/Background/LinearGradientEnd.colorset/Contents.json b/secant/Colors.xcassets/ScreenBackground/gradientEnd.colorset/Contents.json similarity index 100% rename from secant/Colors.xcassets/Background/LinearGradientEnd.colorset/Contents.json rename to secant/Colors.xcassets/ScreenBackground/gradientEnd.colorset/Contents.json diff --git a/secant/Colors.xcassets/Background/LinearGradientStart.colorset/Contents.json b/secant/Colors.xcassets/ScreenBackground/gradientStart.colorset/Contents.json similarity index 100% rename from secant/Colors.xcassets/Background/LinearGradientStart.colorset/Contents.json rename to secant/Colors.xcassets/ScreenBackground/gradientStart.colorset/Contents.json diff --git a/secant/Generated/XCAssets+Generated.swift b/secant/Generated/XCAssets+Generated.swift index 1efff95..f61657c 100644 --- a/secant/Generated/XCAssets+Generated.swift +++ b/secant/Generated/XCAssets+Generated.swift @@ -30,10 +30,6 @@ internal enum Asset { } } internal enum Colors { - internal enum Background { - internal static let linearGradientEnd = ColorAsset(name: "LinearGradientEnd") - internal static let linearGradientStart = ColorAsset(name: "LinearGradientStart") - } internal enum Buttons { internal static let activeButton = ColorAsset(name: "ActiveButton") internal static let createButton = ColorAsset(name: "CreateButton") @@ -57,6 +53,10 @@ internal enum Asset { internal static let gradientRight = ColorAsset(name: "GradientRight") internal static let negativeSpace = ColorAsset(name: "NegativeSpace") } + internal enum ScreenBackground { + internal static let gradientEnd = ColorAsset(name: "gradientEnd") + internal static let gradientStart = ColorAsset(name: "gradientStart") + } internal enum Text { internal static let activeButtonText = ColorAsset(name: "ActiveButtonText") internal static let button = ColorAsset(name: "Button") diff --git a/secant/UI Components/ScreenBackground.swift b/secant/UI Components/ScreenBackground.swift index 5ff6854..21601a8 100644 --- a/secant/UI Components/ScreenBackground.swift +++ b/secant/UI Components/ScreenBackground.swift @@ -11,8 +11,8 @@ import SwiftUI */ struct ScreenBackground: View { var colors = [ - Asset.Colors.Background.linearGradientStart.color, - Asset.Colors.Background.linearGradientEnd.color + Asset.Colors.ScreenBackground.gradientStart.color, + Asset.Colors.ScreenBackground.gradientEnd.color ] var body: some View { LinearGradient(