From 74dd0e603949c56eea0b14e23d602f0de1420392 Mon Sep 17 00:00:00 2001 From: Celio Junior Date: Mon, 8 Dec 2025 21:50:39 -0300 Subject: [PATCH] Replace all hardcoded values with DesignSystem tokens in HomeView and LoginView. --- TabNews.xcodeproj/project.pbxproj | 23 ++++++++++++++++++++ TabNews/Views/HomeView.swift | 19 +++++++++-------- TabNews/Views/LoginView.swift | 35 ++++++++++++++++--------------- 3 files changed, 51 insertions(+), 26 deletions(-) diff --git a/TabNews.xcodeproj/project.pbxproj b/TabNews.xcodeproj/project.pbxproj index ccf1f74..4e6e9bc 100644 --- a/TabNews.xcodeproj/project.pbxproj +++ b/TabNews.xcodeproj/project.pbxproj @@ -6,6 +6,10 @@ objectVersion = 77; objects = { +/* Begin PBXBuildFile section */ + 4A0C9F4B2EE7A14100A85E22 /* DesignSystem in Frameworks */ = {isa = PBXBuildFile; productRef = 4A0C9F4A2EE7A14100A85E22 /* DesignSystem */; }; +/* End PBXBuildFile section */ + /* Begin PBXFileReference section */ 896D06FA2EDFD3DB0019833A /* TabNews.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TabNews.app; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -23,6 +27,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 4A0C9F4B2EE7A14100A85E22 /* DesignSystem in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -65,6 +70,7 @@ ); name = TabNews; packageProductDependencies = ( + 4A0C9F4A2EE7A14100A85E22 /* DesignSystem */, ); productName = TabNews; productReference = 896D06FA2EDFD3DB0019833A /* TabNews.app */; @@ -94,6 +100,9 @@ ); mainGroup = 896D06F12EDFD3DB0019833A; minimizedProjectReferenceProxies = 1; + packageReferences = ( + 4A0C9F492EE7A14100A85E22 /* XCLocalSwiftPackageReference "../../XCodeProjects/DesignSystem" */, + ); preferredProjectObjectVersion = 77; productRefGroup = 896D06FB2EDFD3DB0019833A /* Products */; projectDirPath = ""; @@ -332,6 +341,20 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCLocalSwiftPackageReference section */ + 4A0C9F492EE7A14100A85E22 /* XCLocalSwiftPackageReference "../../XCodeProjects/DesignSystem" */ = { + isa = XCLocalSwiftPackageReference; + relativePath = ../../XCodeProjects/DesignSystem; + }; +/* End XCLocalSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 4A0C9F4A2EE7A14100A85E22 /* DesignSystem */ = { + isa = XCSwiftPackageProductDependency; + productName = DesignSystem; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = 896D06F22EDFD3DB0019833A /* Project object */; } diff --git a/TabNews/Views/HomeView.swift b/TabNews/Views/HomeView.swift index 2c5f5d8..e97e101 100644 --- a/TabNews/Views/HomeView.swift +++ b/TabNews/Views/HomeView.swift @@ -6,6 +6,7 @@ // import SwiftUI +import DesignSystem struct HomeView: View { @ObservedObject var authViewModel: AuthViewModel @@ -53,7 +54,7 @@ struct HomeView: View { Button { showingLoginSheet = true } label: { - HStack(spacing: 4) { + HStack(spacing: .space.x2) { Image(systemName: "person.circle") Text("Entrar") } @@ -90,7 +91,7 @@ private extension HomeView { } func loadingView() -> some View { - VStack(spacing: 12) { + VStack(spacing: .space.x6) { ProgressView() Text("Carregando conteúdos...") .font(.subheadline) @@ -99,14 +100,14 @@ private extension HomeView { } func errorView(with errorMessage: String) -> some View { - VStack(spacing: 16) { + VStack(spacing: .space.x8) { Image(systemName: "exclamationmark.triangle.fill") .foregroundColor(.orange) .font(.largeTitle) Text(errorMessage) .multilineTextAlignment(.center) .foregroundColor(.primary) - + Button("Tentar novamente") { Task { await homeViewModel.loadContents() } } @@ -117,22 +118,22 @@ private extension HomeView { } func contentRow(index: Int, content: ContentResponse) -> some View { - HStack(alignment: .top, spacing: 12) { + HStack(alignment: .top, spacing: .space.x6) { Text("\(index).") .font(.headline) .foregroundColor(.secondary) - - VStack(alignment: .leading, spacing: 6) { + + VStack(alignment: .leading, spacing: .space.x3) { Text(content.title) .font(.headline) .foregroundColor(.primary) - + Text(rowSubtitle(for: content)) .font(.footnote) .foregroundColor(.secondary) } } - .padding(.vertical, 8) + .padding(.vertical, .space.x4) } func rowSubtitle(for content: ContentResponse) -> String { diff --git a/TabNews/Views/LoginView.swift b/TabNews/Views/LoginView.swift index 4520cac..961638d 100644 --- a/TabNews/Views/LoginView.swift +++ b/TabNews/Views/LoginView.swift @@ -6,6 +6,7 @@ // import SwiftUI +import DesignSystem struct LoginView: View { @ObservedObject var authViewModel: AuthViewModel @@ -23,10 +24,10 @@ struct LoginView: View { .ignoresSafeArea() ScrollView { - VStack(spacing: 24) { - VStack(spacing: 12) { + VStack(spacing: .space.x12) { + VStack(spacing: .space.x6) { Image(systemName: "newspaper.fill") - .font(.system(size: 60)) + .font(.system(size: .fontSize.xl9)) .foregroundColor(.blue) Text("TabNews") @@ -37,11 +38,11 @@ struct LoginView: View { .font(.subheadline) .foregroundColor(.secondary) } - .padding(.top, 40) - .padding(.bottom, 20) - - VStack(spacing: 16) { - VStack(alignment: .leading, spacing: 8) { + .padding(.top, .space.x20) + .padding(.bottom, .space.x10) + + VStack(spacing: .space.x8) { + VStack(alignment: .leading, spacing: .space.x4) { Text("Email") .font(.subheadline) .fontWeight(.medium) @@ -51,7 +52,7 @@ struct LoginView: View { .textFieldStyle(.plain) .padding() .background(Color(.systemBackground)) - .cornerRadius(10) + .cornerRadius(.radius.x5) .textContentType(.emailAddress) .keyboardType(.emailAddress) .autocapitalization(.none) @@ -61,8 +62,8 @@ struct LoginView: View { focusedField = .password } } - - VStack(alignment: .leading, spacing: 8) { + + VStack(alignment: .leading, spacing: .space.x4) { Text("Senha") .font(.subheadline) .fontWeight(.medium) @@ -72,7 +73,7 @@ struct LoginView: View { .textFieldStyle(.plain) .padding() .background(Color(.systemBackground)) - .cornerRadius(10) + .cornerRadius(.radius.x5) .textContentType(.password) .focused($focusedField, equals: .password) .submitLabel(.go) @@ -92,8 +93,8 @@ struct LoginView: View { .foregroundColor(.red) .padding() .frame(maxWidth: .infinity, alignment: .leading) - .background(Color.red.opacity(0.1)) - .cornerRadius(10) + .background(Color.red.opacity(.opacity.level1)) + .cornerRadius(.radius.x5) } Button(action: { @@ -113,13 +114,13 @@ struct LoginView: View { } .frame(maxWidth: .infinity) .padding() - .background(authViewModel.isLoading ? Color.blue.opacity(0.6) : Color.blue) + .background(authViewModel.isLoading ? Color.blue.opacity(.opacity.level6) : Color.blue) .foregroundColor(.white) - .cornerRadius(10) + .cornerRadius(.radius.x5) } .disabled(authViewModel.isLoading) } - .padding(.horizontal, 24) + .padding(.horizontal, .space.x12) Spacer() }