From 5f08b6eb3594a414ee4f670d8ce467438d166500 Mon Sep 17 00:00:00 2001 From: vixer93 Date: Sun, 23 Jun 2024 20:26:10 +0900 Subject: [PATCH] Added color theme --- .../xcshareddata/swiftpm/Package.resolved | 9 +++++ app-ios/Package.swift | 12 +++++++ app-ios/Sources/Theme/File.swift | 3 ++ .../Resources/Colors.xcassets/Contents.json | 6 ++++ .../Custom/Arctic Fox.colorset/Contents.json | 20 +++++++++++ .../Colors.xcassets/Custom/Contents.json | 9 +++++ .../Colors.xcassets/Outline/Contents.json | 9 +++++ .../Outline Variant.colorset/Contents.json | 20 +++++++++++ .../Outline/Outline.colorset/Contents.json | 20 +++++++++++ .../Colors.xcassets/Primary/Contents.json | 9 +++++ .../Primary/On Primary.colorset/Contents.json | 20 +++++++++++ .../Colors.xcassets/Surface/Contents.json | 9 +++++ .../On Surface Variant.colorset/Contents.json | 20 +++++++++++ .../Surface/On Surface.colorset/Contents.json | 20 +++++++++++ .../Surface Container.colorset/Contents.json | 20 +++++++++++ .../Surface/Surface.colorset/Contents.json | 20 +++++++++++ app-ios/Sources/Theme/swiftgen.yml | 11 ++++++ .../InformationRow.swift | 5 +-- .../SessionDescriptionView.swift | 9 ++--- .../TimetableDetailView.swift | 35 ++++++++++--------- 20 files changed, 263 insertions(+), 23 deletions(-) create mode 100644 app-ios/Sources/Theme/File.swift create mode 100644 app-ios/Sources/Theme/Resources/Colors.xcassets/Contents.json create mode 100644 app-ios/Sources/Theme/Resources/Colors.xcassets/Custom/Arctic Fox.colorset/Contents.json create mode 100644 app-ios/Sources/Theme/Resources/Colors.xcassets/Custom/Contents.json create mode 100644 app-ios/Sources/Theme/Resources/Colors.xcassets/Outline/Contents.json create mode 100644 app-ios/Sources/Theme/Resources/Colors.xcassets/Outline/Outline Variant.colorset/Contents.json create mode 100644 app-ios/Sources/Theme/Resources/Colors.xcassets/Outline/Outline.colorset/Contents.json create mode 100644 app-ios/Sources/Theme/Resources/Colors.xcassets/Primary/Contents.json create mode 100644 app-ios/Sources/Theme/Resources/Colors.xcassets/Primary/On Primary.colorset/Contents.json create mode 100644 app-ios/Sources/Theme/Resources/Colors.xcassets/Surface/Contents.json create mode 100644 app-ios/Sources/Theme/Resources/Colors.xcassets/Surface/On Surface Variant.colorset/Contents.json create mode 100644 app-ios/Sources/Theme/Resources/Colors.xcassets/Surface/On Surface.colorset/Contents.json create mode 100644 app-ios/Sources/Theme/Resources/Colors.xcassets/Surface/Surface Container.colorset/Contents.json create mode 100644 app-ios/Sources/Theme/Resources/Colors.xcassets/Surface/Surface.colorset/Contents.json create mode 100644 app-ios/Sources/Theme/swiftgen.yml diff --git a/app-ios/App/App.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/app-ios/App/App.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index a63625dcd..ea2864c01 100644 --- a/app-ios/App/App.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/app-ios/App/App.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -226,6 +226,15 @@ "version" : "510.0.2" } }, + { + "identity" : "swiftgenplugin", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SwiftGen/SwiftGenPlugin", + "state" : { + "revision" : "879b85a470cacd70c19e22eb7e11a3aed66f4068", + "version" : "6.6.2" + } + }, { "identity" : "swiftui-navigation", "kind" : "remoteSourceControl", diff --git a/app-ios/Package.swift b/app-ios/Package.swift index 806311f51..25a46c1b2 100644 --- a/app-ios/Package.swift +++ b/app-ios/Package.swift @@ -39,6 +39,7 @@ let package = Package( .package(url: "https://github.com/pointfreeco/swift-composable-architecture.git", exact: "1.10.2"), .package(url: "https://github.com/firebase/firebase-ios-sdk.git", exact: "10.26.0"), .package(url: "https://github.com/cybozu/LicenseList.git", exact: "0.7.0"), + .package(url: "https://github.com/SwiftGen/SwiftGenPlugin", from: "6.6.2"), ], targets: [ .target( @@ -96,6 +97,7 @@ let package = Package( name: "TimetableDetailFeature", dependencies: [ .tca, + .theme, ] ), .testTarget( @@ -131,6 +133,15 @@ let package = Package( ] ), + .target( + name: "Theme", + resources: [ + .process("Resources"), + .process("swiftgen.yml"), + ], + plugins: [.plugin(name: "SwiftGenPlugin", package: "SwiftGenPlugin")] + ), + // Please run ./gradlew app-ios-shared:assembleSharedXCFramework first .binaryTarget(name: "KmpModule", path: "../app-ios-shared/build/XCFrameworks/debug/shared.xcframework"), ] @@ -155,6 +166,7 @@ extension Target.Dependency { static let aboutFeature: Target.Dependency = "AboutFeature" static let favoriteFeature: Target.Dependency = "FavoriteFeature" static let kmpModule: Target.Dependency = "KmpModule" + static let theme: Target.Dependency = "Theme" static let firebaseAuth: Target.Dependency = .product(name: "FirebaseAuth", package: "firebase-ios-sdk") static let firebaseRemoteConfig: Target.Dependency = .product(name: "FirebaseRemoteConfig", package: "firebase-ios-sdk") diff --git a/app-ios/Sources/Theme/File.swift b/app-ios/Sources/Theme/File.swift new file mode 100644 index 000000000..944d844c9 --- /dev/null +++ b/app-ios/Sources/Theme/File.swift @@ -0,0 +1,3 @@ +// empty file +// Due to SPM specifications, an error occurs if a Swift file of some kind does not exist, so an empty file is added. +// Currently there is no implementation that requires a Swift file, but this will be added later. diff --git a/app-ios/Sources/Theme/Resources/Colors.xcassets/Contents.json b/app-ios/Sources/Theme/Resources/Colors.xcassets/Contents.json new file mode 100644 index 000000000..73c00596a --- /dev/null +++ b/app-ios/Sources/Theme/Resources/Colors.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/app-ios/Sources/Theme/Resources/Colors.xcassets/Custom/Arctic Fox.colorset/Contents.json b/app-ios/Sources/Theme/Resources/Colors.xcassets/Custom/Arctic Fox.colorset/Contents.json new file mode 100644 index 000000000..c53a22c6e --- /dev/null +++ b/app-ios/Sources/Theme/Resources/Colors.xcassets/Custom/Arctic Fox.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x61", + "green" : "0xE7", + "red" : "0x45" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/app-ios/Sources/Theme/Resources/Colors.xcassets/Custom/Contents.json b/app-ios/Sources/Theme/Resources/Colors.xcassets/Custom/Contents.json new file mode 100644 index 000000000..6e965652d --- /dev/null +++ b/app-ios/Sources/Theme/Resources/Colors.xcassets/Custom/Contents.json @@ -0,0 +1,9 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "provides-namespace" : true + } +} diff --git a/app-ios/Sources/Theme/Resources/Colors.xcassets/Outline/Contents.json b/app-ios/Sources/Theme/Resources/Colors.xcassets/Outline/Contents.json new file mode 100644 index 000000000..6e965652d --- /dev/null +++ b/app-ios/Sources/Theme/Resources/Colors.xcassets/Outline/Contents.json @@ -0,0 +1,9 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "provides-namespace" : true + } +} diff --git a/app-ios/Sources/Theme/Resources/Colors.xcassets/Outline/Outline Variant.colorset/Contents.json b/app-ios/Sources/Theme/Resources/Colors.xcassets/Outline/Outline Variant.colorset/Contents.json new file mode 100644 index 000000000..be63032f8 --- /dev/null +++ b/app-ios/Sources/Theme/Resources/Colors.xcassets/Outline/Outline Variant.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x49", + "green" : "0x48", + "red" : "0x41" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/app-ios/Sources/Theme/Resources/Colors.xcassets/Outline/Outline.colorset/Contents.json b/app-ios/Sources/Theme/Resources/Colors.xcassets/Outline/Outline.colorset/Contents.json new file mode 100644 index 000000000..aaa0abc59 --- /dev/null +++ b/app-ios/Sources/Theme/Resources/Colors.xcassets/Outline/Outline.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x93", + "green" : "0x92", + "red" : "0x8B" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/app-ios/Sources/Theme/Resources/Colors.xcassets/Primary/Contents.json b/app-ios/Sources/Theme/Resources/Colors.xcassets/Primary/Contents.json new file mode 100644 index 000000000..6e965652d --- /dev/null +++ b/app-ios/Sources/Theme/Resources/Colors.xcassets/Primary/Contents.json @@ -0,0 +1,9 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "provides-namespace" : true + } +} diff --git a/app-ios/Sources/Theme/Resources/Colors.xcassets/Primary/On Primary.colorset/Contents.json b/app-ios/Sources/Theme/Resources/Colors.xcassets/Primary/On Primary.colorset/Contents.json new file mode 100644 index 000000000..838d58536 --- /dev/null +++ b/app-ios/Sources/Theme/Resources/Colors.xcassets/Primary/On Primary.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x15", + "green" : "0x39", + "red" : "0x00" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/app-ios/Sources/Theme/Resources/Colors.xcassets/Surface/Contents.json b/app-ios/Sources/Theme/Resources/Colors.xcassets/Surface/Contents.json new file mode 100644 index 000000000..6e965652d --- /dev/null +++ b/app-ios/Sources/Theme/Resources/Colors.xcassets/Surface/Contents.json @@ -0,0 +1,9 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "provides-namespace" : true + } +} diff --git a/app-ios/Sources/Theme/Resources/Colors.xcassets/Surface/On Surface Variant.colorset/Contents.json b/app-ios/Sources/Theme/Resources/Colors.xcassets/Surface/On Surface Variant.colorset/Contents.json new file mode 100644 index 000000000..09e40bdce --- /dev/null +++ b/app-ios/Sources/Theme/Resources/Colors.xcassets/Surface/On Surface Variant.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xC9", + "green" : "0xC8", + "red" : "0xC1" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/app-ios/Sources/Theme/Resources/Colors.xcassets/Surface/On Surface.colorset/Contents.json b/app-ios/Sources/Theme/Resources/Colors.xcassets/Surface/On Surface.colorset/Contents.json new file mode 100644 index 000000000..6ce422fa1 --- /dev/null +++ b/app-ios/Sources/Theme/Resources/Colors.xcassets/Surface/On Surface.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xC4", + "green" : "0xC7", + "red" : "0xC5" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/app-ios/Sources/Theme/Resources/Colors.xcassets/Surface/Surface Container.colorset/Contents.json b/app-ios/Sources/Theme/Resources/Colors.xcassets/Surface/Surface Container.colorset/Contents.json new file mode 100644 index 000000000..26006eca7 --- /dev/null +++ b/app-ios/Sources/Theme/Resources/Colors.xcassets/Surface/Surface Container.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x20", + "green" : "0x20", + "red" : "0x1F" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/app-ios/Sources/Theme/Resources/Colors.xcassets/Surface/Surface.colorset/Contents.json b/app-ios/Sources/Theme/Resources/Colors.xcassets/Surface/Surface.colorset/Contents.json new file mode 100644 index 000000000..71581aa1a --- /dev/null +++ b/app-ios/Sources/Theme/Resources/Colors.xcassets/Surface/Surface.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x14", + "green" : "0x14", + "red" : "0x12" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/app-ios/Sources/Theme/swiftgen.yml b/app-ios/Sources/Theme/swiftgen.yml new file mode 100644 index 000000000..fa1c30b88 --- /dev/null +++ b/app-ios/Sources/Theme/swiftgen.yml @@ -0,0 +1,11 @@ +input_dir: Resources/ +output_dir: ${DERIVED_SOURCES_DIR}/ + +xcassets: + inputs: Colors.xcassets + outputs: + templateName: swift5 + output: AssetColors.generated.swift + params: + enumName: AssetColors + publicAccess: true diff --git a/app-ios/Sources/TimetableDetailFeature/InformationRow.swift b/app-ios/Sources/TimetableDetailFeature/InformationRow.swift index 907d52b9f..2fa108cf4 100644 --- a/app-ios/Sources/TimetableDetailFeature/InformationRow.swift +++ b/app-ios/Sources/TimetableDetailFeature/InformationRow.swift @@ -1,4 +1,5 @@ import SwiftUI +import Theme struct InformationRow: View { private let icon: Image @@ -21,12 +22,12 @@ struct InformationRow: View { HStack(spacing: 12) { Text(title) .font(.callout) - .foregroundStyle(Color(.surfaceVariant)) + .foregroundStyle(AssetColors.Surface.onSurfaceVariant.swiftUIColor) .bold() HStack { Text(content) .font(.callout) - .foregroundStyle(Color(.onSurface)) + .foregroundStyle(AssetColors.Surface.onSurface.swiftUIColor) } } diff --git a/app-ios/Sources/TimetableDetailFeature/SessionDescriptionView.swift b/app-ios/Sources/TimetableDetailFeature/SessionDescriptionView.swift index 8e8ceaff3..074eda849 100644 --- a/app-ios/Sources/TimetableDetailFeature/SessionDescriptionView.swift +++ b/app-ios/Sources/TimetableDetailFeature/SessionDescriptionView.swift @@ -1,4 +1,5 @@ import SwiftUI +import Theme struct SessionDescriptionView: View { @State private var isDescriptionExpanded: Bool = false @@ -15,7 +16,7 @@ struct SessionDescriptionView: View { .textSelection(.enabled) .lineLimit(isDescriptionExpanded ? nil : 5) .font(.callout) - .foregroundStyle(Color(.surfaceVariant)) + .foregroundStyle(AssetColors.Surface.onSurfaceVariant.swiftUIColor) .background { ViewThatFits(in: .vertical) { Text(content) @@ -33,11 +34,11 @@ struct SessionDescriptionView: View { canBeExpanded = false } label: { Text(String(localized: "TimeTableDetailReadMore", bundle: .module)) - .foregroundStyle(Color(.primary)) + .foregroundStyle(AssetColors.Custom.arcticFox.swiftUIColor) .frame(width: 120, height: 40, alignment: .center) .overlay { Capsule() - .stroke(Color(.outline)) + .stroke(AssetColors.Outline.outline.swiftUIColor) } } } @@ -50,5 +51,5 @@ struct SessionDescriptionView: View { SessionDescriptionView(content: SampleData.sessionDescription) .padding(.horizontal, 16) } - .background(Color(.background)) + .background(AssetColors.Surface.surface.swiftUIColor) } diff --git a/app-ios/Sources/TimetableDetailFeature/TimetableDetailView.swift b/app-ios/Sources/TimetableDetailFeature/TimetableDetailView.swift index d78597c56..c0335e6ea 100644 --- a/app-ios/Sources/TimetableDetailFeature/TimetableDetailView.swift +++ b/app-ios/Sources/TimetableDetailFeature/TimetableDetailView.swift @@ -1,5 +1,6 @@ import SwiftUI import ComposableArchitecture +import Theme public struct TimetableDetailView: View { private let store: StoreOf @@ -10,17 +11,17 @@ public struct TimetableDetailView: View { sessionDetail .padding(.horizontal, 16) - Divider().background(Color(.outlineVariant)) + Divider().background(AssetColors.Outline.outlineVariant.swiftUIColor) targetUser .padding(16) - Divider().background(Color(.outlineVariant)) + Divider().background(AssetColors.Outline.outlineVariant.swiftUIColor) speaker .padding(16) - Divider().background(Color(.outlineVariant)) + Divider().background(AssetColors.Outline.outlineVariant.swiftUIColor) archive .padding(16) @@ -28,7 +29,7 @@ public struct TimetableDetailView: View { footer } - .background(Color(.background)) + .background(AssetColors.Surface.surface.swiftUIColor) .frame(maxWidth: .infinity) } @@ -58,21 +59,21 @@ public struct TimetableDetailView: View { Image(.icFavorite) } .frame(width: 56, height: 56) - .background(Color(.secondaryContainer)) + .background(AssetColors.Surface.surfaceContainer.swiftUIColor) .clipShape(RoundedRectangle(cornerRadius: 16)) } } .frame(height: 80) .frame(maxWidth: .infinity) .padding(.horizontal, 16) - .background(Color(.surfaceContainer)) + .background(AssetColors.Surface.surfaceContainer.swiftUIColor) } @ViewBuilder var sessionDetail: some View { VStack(alignment: .leading, spacing: 20) { Text(SampleData.title) .font(.title) - .foregroundStyle(Color(.surfaceVariant)) + .foregroundStyle(AssetColors.Surface.onSurfaceVariant.swiftUIColor) VStack(spacing: 16) { InformationRow( icon: Image(.icSchedule), @@ -98,7 +99,7 @@ public struct TimetableDetailView: View { .padding(16) .overlay( RoundedRectangle(cornerRadius: 12) - .stroke(Color(.onSurface), lineWidth: 1) + .stroke(AssetColors.Surface.onSurface.swiftUIColor, lineWidth: 1) ) SessionDescriptionView(content: SampleData.sessionDescription) @@ -110,11 +111,11 @@ public struct TimetableDetailView: View { VStack(alignment: .leading, spacing: 16) { Text(String(localized: "TimeTableDetailApplicants", bundle: .module)) .font(.title3) - .foregroundStyle(Color(.surfaceVariant)) + .foregroundStyle(AssetColors.Surface.onSurfaceVariant.swiftUIColor) Text(SampleData.applicants) .font(.callout) - .foregroundStyle(Color(.surfaceVariant)) + .foregroundStyle(AssetColors.Surface.onSurfaceVariant.swiftUIColor) } } @@ -122,14 +123,14 @@ public struct TimetableDetailView: View { VStack(alignment: .leading, spacing: 16) { Text(String(localized: "TimeTableDetailSpeaker", bundle: .module)) .font(.title3) - .foregroundStyle(Color(.surfaceVariant)) + .foregroundStyle(AssetColors.Surface.onSurfaceVariant.swiftUIColor) HStack { Image(.avatar) .padding(.trailing, 24) Text(SampleData.name) .font(.callout) - .foregroundStyle(Color(.onSurface)) + .foregroundStyle(AssetColors.Surface.onSurface.swiftUIColor) Spacer() } } @@ -139,7 +140,7 @@ public struct TimetableDetailView: View { VStack(alignment: .leading, spacing: 16) { Text(String(localized: "TimeTableDetailArchive", bundle: .module)) .font(.title3) - .foregroundStyle(Color(.surfaceVariant)) + .foregroundStyle(AssetColors.Surface.onSurfaceVariant.swiftUIColor) HStack { Button { @@ -147,13 +148,13 @@ public struct TimetableDetailView: View { } label: { VStack { Label( - title: { Text(String(localized: "TimeTableDetailSlide", bundle: .module)).foregroundStyle(Color(.onPrimary)) }, + title: { Text(String(localized: "TimeTableDetailSlide", bundle: .module)).foregroundStyle(AssetColors.Primary.onPrimary.swiftUIColor) }, icon: { Image(.icDocument) } ) } .frame(height: 40) .frame(maxWidth: .infinity) - .background(Color(.button)) + .background(AssetColors.Custom.arcticFox.swiftUIColor) .clipShape(Capsule()) } Button { @@ -161,13 +162,13 @@ public struct TimetableDetailView: View { } label: { VStack { Label( - title: { Text(String(localized: "TimeTableDetailVideo", bundle: .module)).foregroundStyle(Color(.onPrimary)) }, + title: { Text(String(localized: "TimeTableDetailVideo", bundle: .module)).foregroundStyle(AssetColors.Primary.onPrimary.swiftUIColor) }, icon: { Image(.icPlay) } ) } .frame(height: 40) .frame(maxWidth: .infinity) - .background(Color(.button)) + .background(AssetColors.Custom.arcticFox.swiftUIColor) .clipShape(Capsule()) } }