From e89393217df3d3992d9812272b30801271c0bfc3 Mon Sep 17 00:00:00 2001 From: Vincent Nguyen Date: Wed, 16 Nov 2022 21:52:11 -0600 Subject: [PATCH 1/2] Add SwiftUI Label Missing some border and shadow cases, but can come back to it if encounter those cases --- HackIllinois.xcodeproj/project.pbxproj | 10 +- .../xcschemes/HackIllinois.xcscheme | 78 +++++ HackIllinois/UI/HILabelSUI.swift | 269 ++++++++++++++++++ HackIllinois/UI/Identifiable.swift | 6 +- 4 files changed, 358 insertions(+), 5 deletions(-) create mode 100644 HackIllinois.xcodeproj/xcshareddata/xcschemes/HackIllinois.xcscheme create mode 100644 HackIllinois/UI/HILabelSUI.swift diff --git a/HackIllinois.xcodeproj/project.pbxproj b/HackIllinois.xcodeproj/project.pbxproj index 5735868e..49ed6815 100644 --- a/HackIllinois.xcodeproj/project.pbxproj +++ b/HackIllinois.xcodeproj/project.pbxproj @@ -133,6 +133,7 @@ BF0FDA3925F4DCCD003B5DB1 /* HIScheduleSegmentedControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF0FDA3825F4DCCD003B5DB1 /* HIScheduleSegmentedControl.swift */; }; BFB1FD3E26105EA400500008 /* HIEditProfileCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFB1FD3D26105EA400500008 /* HIEditProfileCell.swift */; }; D3A309BC2211175200CBA351 /* PassKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D3A309BB2211175200CBA351 /* PassKit.framework */; }; + E1E4A5DD291C9F3F00780BA1 /* HILabelSUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1E4A5DC291C9F3F00780BA1 /* HILabelSUI.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -306,6 +307,7 @@ BFB1FD3D26105EA400500008 /* HIEditProfileCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HIEditProfileCell.swift; sourceTree = ""; }; D3A309BA221116A600CBA351 /* HackIllinois.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = HackIllinois.entitlements; sourceTree = ""; }; D3A309BB2211175200CBA351 /* PassKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PassKit.framework; path = System/Library/Frameworks/PassKit.framework; sourceTree = SDKROOT; }; + E1E4A5DC291C9F3F00780BA1 /* HILabelSUI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HILabelSUI.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -525,6 +527,7 @@ ACAA7177260186EF000F42B0 /* CollectionView */, 95FC79BD21E0199600715036 /* HIAppearance.swift */, 95A7D27B203D4F54005EAEAF /* HIButton.swift */, + E1E4A5DC291C9F3F00780BA1 /* HILabelSUI.swift */, 9523A28F2218BA2600341EBD /* HIImageView.swift */, 95A7D29D203D5BA4005EAEAF /* HILabel.swift */, 95A7D27C203D4F54005EAEAF /* HISegmentedControl.swift */, @@ -882,6 +885,7 @@ 95CA9230201E60D300C46037 /* UIImage+QRCode.swift in Sources */, AC3B621325E86053002386A2 /* Profile+CoreDataClass.swift in Sources */, 95A7D2A0203D60E9005EAEAF /* HIBubbleCell.swift in Sources */, + E1E4A5DD291C9F3F00780BA1 /* HILabelSUI.swift in Sources */, 9552D92821758E4C00A8C869 /* UIView+AutoLayout.swift in Sources */, ACB53AED261B8ACD007B1643 /* HIInterestDataSource.swift in Sources */, 083C643327A7457000087018 /* HIHomeSegmentedControl.swift in Sources */, @@ -1063,7 +1067,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -1116,7 +1120,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_COMPILATION_MODE = wholemodule; @@ -1136,6 +1140,7 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 8VNQTQM2L6; INFOPLIST_FILE = HackIllinois/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1159,6 +1164,7 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 8VNQTQM2L6; INFOPLIST_FILE = HackIllinois/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/HackIllinois.xcodeproj/xcshareddata/xcschemes/HackIllinois.xcscheme b/HackIllinois.xcodeproj/xcshareddata/xcschemes/HackIllinois.xcscheme new file mode 100644 index 00000000..26d872be --- /dev/null +++ b/HackIllinois.xcodeproj/xcshareddata/xcschemes/HackIllinois.xcscheme @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/HackIllinois/UI/HILabelSUI.swift b/HackIllinois/UI/HILabelSUI.swift new file mode 100644 index 00000000..b9809e47 --- /dev/null +++ b/HackIllinois/UI/HILabelSUI.swift @@ -0,0 +1,269 @@ +// +// HILabelSUI.swift +// HackIllinois +// +// Created by Vincent Nguyen on 11/9/22. +// Copyright © 2022 HackIllinois. All rights reserved. +// + +import SwiftUI + +struct HILabelSUI: View { + // MARK: - Properties + let labelText: String + let textHIColor: HIColor + let font: UIFont? + let backgroundHIColor: HIColor + var textAlignment: TextAlignment = .leading + var borderWidth: CGFloat = 0 + var borderColor: Color = .clear + // MARK: - Init + init(labelText: String, style: Style) { + self.labelText = labelText + switch style { + + case .location: + self.textHIColor = \.baseText + backgroundHIColor = \.clear + font = HIAppearance.Font.contentText + + case .event: + textHIColor = \.baseText + backgroundHIColor = \.clear + font = HIAppearance.Font.eventTitle + + case .eventTime: + textHIColor = \.baseText + backgroundHIColor = \.clear + font = HIAppearance.Font.eventTime + + case .eventType: + textHIColor = \.baseText + backgroundHIColor = \.clear + font = HIAppearance.Font.eventCategoryText + + case .sponsor: + textHIColor = \.baseText + backgroundHIColor = \.clear + font = HIAppearance.Font.sponsorText + + case .detailTitle: + textHIColor = \.baseText + backgroundHIColor = \.clear + font = HIAppearance.Font.detailTitle + + case .detailSubtitle: + textHIColor = \.baseText + backgroundHIColor = \.clear + font = HIAppearance.Font.detailSubtitle + + case .detailText: + textHIColor = \.baseText + backgroundHIColor = \.clear + font = HIAppearance.Font.detailText + + case .project: + textHIColor = \.baseText + backgroundHIColor = \.clear + font = HIAppearance.Font.contentTitle + + case .viewTitle: + textHIColor = \.baseText + backgroundHIColor = \.clear + textAlignment = .center + font = HIAppearance.Font.viewTitle + + case .subtitle: + textHIColor = \.accent + backgroundHIColor = \.clear + font = HIAppearance.Font.contentSubtitle + + case .description: + textHIColor = \.baseText + backgroundHIColor = \.clear + font = HIAppearance.Font.descriptionText + + case .cellDescription: + textHIColor = \.baseText + backgroundHIColor = \.clear + font = HIAppearance.Font.eventDetails + + case .loginHeader: + textHIColor = \.loginTitleBackground + backgroundHIColor = \.clear + font = HIAppearance.Font.loginTitle + + case .welcomeTitle: + textHIColor = \.loginSelectionText + backgroundHIColor = \.clear + font = HIAppearance.Font.loginTitle + + case .backgroundTitle: + textHIColor = \.baseText + backgroundHIColor = \.clear + textAlignment = .center + font = HIAppearance.Font.navigationSubtitle + + case .loginSelection: + textHIColor = \.loginSelectionText + backgroundHIColor = \.clear + textAlignment = .center + font = HIAppearance.Font.loginSelection +// borderWidth = 2.0 +// borderColor = Color((\HIAppearance.loginSelectionText).value.cgColor) + + case .profileName: // Used to display the profile owner's name + textHIColor = \.baseText + backgroundHIColor = \.clear + textAlignment = .center + font = HIAppearance.Font.profileName + + case .profileSubtitle: // Used to display profile subtitle, "points", and whatever that says "time zone" + backgroundHIColor = \.clear + textHIColor = \.baseText + textAlignment = .center + font = HIAppearance.Font.profileSubtitle + + case .profileNumberFigure: // Used to display number of points and time (?) + textHIColor = \.baseText + backgroundHIColor = \.clear + textAlignment = .center + font = HIAppearance.Font.profileNumberFigure + + case .profileTier: // Used to display "short description" + textHIColor = \.baseText + backgroundHIColor = \.clear + textAlignment = .leading + font = HIAppearance.Font.profileTier + + case .profileUsername: // Used to display Discord username, etc. + textHIColor = \.whiteTagFont + backgroundHIColor = \.clear + textAlignment = .leading + font = HIAppearance.Font.profileUsername + + case .profileInterests: + textHIColor = \.whiteTagFont + backgroundHIColor = \.clear + textAlignment = .center + font = HIAppearance.Font.profileInterests + + case .navigationInfo: + textHIColor = \.titleText + backgroundHIColor = \.clear + font = HIAppearance.Font.navigationInfoText + textAlignment = .leading + + case .countdown: + textHIColor = \.titleText + backgroundHIColor = \.clear + font = HIAppearance.Font.countdownText + + case .pointsText: + textHIColor = \.baseText + backgroundHIColor = \.clear + font = HIAppearance.Font.eventButtonText + textAlignment = .center + + case .error: + textHIColor = \.baseText + backgroundHIColor = \.clear + font = HIAppearance.Font.detailSubtitle + textAlignment = .center + + case .codeError: + textHIColor = \.baseText + backgroundHIColor = \.clear + font = HIAppearance.Font.detailSubtitle + textAlignment = .center + + case .onboardingDescription: + textHIColor = \.baseText + backgroundHIColor = \.clear + font = HIAppearance.Font.onboardingDescription + textAlignment = .center + + case .onboardingTitle: + textHIColor = \.baseText + backgroundHIColor = \.clear + font = HIAppearance.Font.onboardingTitle + textAlignment = .center + + case .clock: + textHIColor = \.baseText + backgroundHIColor = \.clear + font = HIAppearance.Font.clockText + textAlignment = .center + + // Leaderboard label fonts + case .leaderboardRank: + textHIColor = \.leaderboardText + backgroundHIColor = \.clear + font = HIAppearance.Font.leaderboardRank + //layer.shadowOffset = CGSize(width: 2, height: 2) + //layer.shadowRadius = 2.0 + //layer.shadowOpacity = 0.25 + case .leaderboardName: + textHIColor = \.leaderboardText + backgroundHIColor = \.clear + font = HIAppearance.Font.leaderboardPoints + case .leaderboardPoints: + textHIColor = \.leaderboardText + backgroundHIColor = \.pointsBackground + font = HIAppearance.Font.leaderboardPoints + } + + } + var body: some View { + Text(labelText) + .foregroundColor(Color(textHIColor.value)) + .background(Color(backgroundHIColor.value)) + .font(Font(font!)) + .multilineTextAlignment(textAlignment) + .border(borderColor, width: borderWidth) + } + + // MARK: - Types + enum Style { + case location + case event + case eventTime + case eventType + case sponsor + case project + case viewTitle + case detailTitle + case subtitle + case description + case cellDescription + case loginHeader + case loginSelection + case welcomeTitle + case backgroundTitle + case detailSubtitle + case detailText + case profileName + case profileSubtitle + case profileNumberFigure + case profileTier + case profileUsername + case profileInterests + case navigationInfo + case countdown + case pointsText + case error + case codeError + case onboardingDescription + case onboardingTitle + case clock + case leaderboardRank + case leaderboardName + case leaderboardPoints + } +} + +struct HILabelSUI_Previews: PreviewProvider { + static var previews: some View { + HILabelSUI(labelText: "HELLO", style: .loginSelection) + } +} diff --git a/HackIllinois/UI/Identifiable.swift b/HackIllinois/UI/Identifiable.swift index 7ec996fd..28eaa4ad 100644 --- a/HackIllinois/UI/Identifiable.swift +++ b/HackIllinois/UI/Identifiable.swift @@ -13,9 +13,9 @@ import Foundation import UIKit -protocol Identifiable { - static var identifier: String { get } -} +//protocol Identifiable { +// static var identifier: String { get } +//} extension UITableViewCell: Identifiable { static var identifier: String = String(describing: self) From bf57a2da71b2d7299f63389c30dffddbd647f500 Mon Sep 17 00:00:00 2001 From: Vincent Nguyen <72878425+vincentbanguyen@users.noreply.github.com> Date: Mon, 19 Dec 2022 15:33:15 -0600 Subject: [PATCH 2/2] fix weird error --- HackIllinois.xcodeproj/project.pbxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HackIllinois.xcodeproj/project.pbxproj b/HackIllinois.xcodeproj/project.pbxproj index 008c9b82..ceb98ce3 100644 --- a/HackIllinois.xcodeproj/project.pbxproj +++ b/HackIllinois.xcodeproj/project.pbxproj @@ -309,7 +309,7 @@ BF0FDA3825F4DCCD003B5DB1 /* HIScheduleSegmentedControl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HIScheduleSegmentedControl.swift; sourceTree = ""; }; BFB1FD3D26105EA400500008 /* HIEditProfileCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HIEditProfileCell.swift; sourceTree = ""; }; D3A309BA221116A600CBA351 /* HackIllinois.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = HackIllinois.entitlements; sourceTree = ""; }; - D3A309BB2211175200CBA351 /* PassKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PassKit.framework; path = System/Library/Frameworks/PassKit.framewor + D3A309BB2211175200CBA351 /* PassKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PassKit.framework; path = System/Library/Frameworks/PassKit.framework; sourceTree = SDKROOT; }; E1E4A5DC291C9F3F00780BA1 /* HILabelSUI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HILabelSUI.swift; sourceTree = ""; }; E1E4A5D6291C9BF700780BA1 /* HICarouselSwiftUIView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HICarouselSwiftUIView.swift; sourceTree = ""; }; E1E4A5D7291C9BF700780BA1 /* HIOnboardingView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HIOnboardingView.swift; sourceTree = ""; };