Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] ♻️ Enabled to use ttf files placed in commonMain on iOS. #1047

Merged
merged 16 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app-ios/App/DroidKaigi2023/DroidKaigi2023/App.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import Navigation
import SwiftUI
import Theme

@main
struct MainApp: App {
init() { FontAssets.registerAllCustomFonts() }

var body: some Scene {
WindowGroup {
RootView()
Expand Down
8 changes: 4 additions & 4 deletions app-ios/Modules/Sources/About/AboutView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public struct AboutView<ContributorView: View, StaffView: View, SponsorView: Vie
Assets.Images.aboutKeyVisual.swiftUIImage
Spacer().frame(height: 16)
Text(L10n.About.description)
.font(Font.system(size: 16))
.font(Font.custom(FontAssets.Montserrat.medium, size: 16))
.frame(maxWidth: .infinity, alignment: .leading)
Spacer().frame(height: 12)
VStack(alignment: .leading, spacing: 12) {
Expand Down Expand Up @@ -123,14 +123,14 @@ public struct AboutView<ContributorView: View, StaffView: View, SponsorView: Vie
.padding(.vertical, 24)

Text(L10n.About.appVersion)
.font(Font.system(size: 14, weight: .medium))
.font(Font.custom(FontAssets.Montserrat.medium, size: 14))
Spacer().frame(height: 8)
Text(Bundle.main.formattedVersion)
.font(Font.system(size: 14, weight: .medium))
.font(Font.custom(FontAssets.Montserrat.medium, size: 14))
Spacer().frame(height: 8)
Text(L10n.About.androidRobotDescription)
.foregroundStyle(AssetColors.About.androidRobotDescription.swiftUIColor)
.font(Font.system(size: 11, weight: .medium))
.font(Font.custom(FontAssets.Montserrat.medium, size: 11))
.multilineTextAlignment(.center)
}
.padding(16)
Expand Down
2 changes: 1 addition & 1 deletion app-ios/Modules/Sources/About/ListTile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct ListTile: View {
.renderingMode(.template)
.foregroundStyle(AssetColors.Surface.onSurfaceVariant.swiftUIColor)
Text(title)
.font(Font.system(size: 14, weight: .medium))
.font(Font.custom(FontAssets.Montserrat.medium, size: 14))
.foregroundStyle(AssetColors.Surface.onSurface.swiftUIColor)
}
.padding(.horizontal, 12)
Expand Down
3 changes: 2 additions & 1 deletion app-ios/Modules/Sources/About/SectionTitle.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import SwiftUI
import Theme

struct SectionTitle: View {
let title: String

var body: some View {
Text(title)
.font(Font.system(size: 16, weight: .medium))
.font(Font.custom(FontAssets.Montserrat.medium, size: 16))
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.top, 16)
}
Expand Down
6 changes: 3 additions & 3 deletions app-ios/Modules/Sources/Component/InformationRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ public struct InformationRow: View {
icon
HStack(spacing: 12) {
Text(title)
.font(Font.system(size: 14, weight: .semibold))
.font(Font.custom(FontAssets.Montserrat.semiBold, size: 14))
HStack {
Text(content)
.font(Font.system(size: 14, weight: .semibold))
.font(Font.custom(FontAssets.Montserrat.semiBold, size: 14))
if let action = action {
Button {
action.action()
} label: {
Text(action.label)
.font(Font.system(size: 14, weight: .semibold))
.font(Font.custom(FontAssets.Montserrat.semiBold, size: 14))
.underline()
.foregroundStyle(
AssetColors.Primary.primary.swiftUIColor
Expand Down
4 changes: 2 additions & 2 deletions app-ios/Modules/Sources/Component/PersonLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ public struct PersonLabel: View {
VStack(alignment: .leading) {
Text(name)
.foregroundStyle(AssetColors.Surface.onSurface.swiftUIColor)
.font(Font.system(size: 16, weight: .medium))
.font(Font.custom(FontAssets.Montserrat.medium, size: 16))
.lineLimit(2)
if let notes = notes {
Text(notes)
.foregroundStyle(AssetColors.Surface.onSurfaceVariant.swiftUIColor)
.font(Font.system(size: 12))
.font(Font.custom(FontAssets.Montserrat.medium, size: 12))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct FloorMapFooterSegmentedButton: View {
Assets.Icons.checkmark.swiftUIImage
}
Text("1F")
.font(.system(size: 14, weight: .medium))
.font(Font.custom(FontAssets.Montserrat.medium, size: 14))
}
.foregroundStyle(AssetColors.Secondary.onSecondaryContainer.swiftUIColor)
}
Expand All @@ -49,7 +49,7 @@ struct FloorMapFooterSegmentedButton: View {
Assets.Icons.checkmark.swiftUIImage
}
Text("B1F")
.font(.system(size: 14, weight: .medium))
.font(Font.custom(FontAssets.Montserrat.medium, size: 14))
}
.foregroundStyle(AssetColors.Secondary.onSecondaryContainer.swiftUIColor)
}
Expand Down
4 changes: 2 additions & 2 deletions app-ios/Modules/Sources/FloorMap/FloorMapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public struct FloorMapView: View {
VStack(alignment: .leading, spacing: 24) {
VStack(alignment: .leading, spacing: 8) {
Text("1F")
.font(Font.system(size: 24, weight: .medium))
.font(Font.custom(FontAssets.Montserrat.medium, size: 24))
Assets.Images.floor1F.swiftUIImage
.resizable()
.scaledToFit()
Expand All @@ -64,7 +64,7 @@ public struct FloorMapView: View {
VStack(alignment: .leading, spacing: 24) {
VStack(alignment: .leading, spacing: 8) {
Text("B1F")
.font(Font.system(size: 24, weight: .medium))
.font(Font.custom(FontAssets.Montserrat.medium, size: 24))
Assets.Images.floorB1F.swiftUIImage
.resizable()
.scaledToFit()
Expand Down
7 changes: 4 additions & 3 deletions app-ios/Modules/Sources/FloorMap/SideEventRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,20 @@ struct SideEventRow: View {
.foregroundStyle(sideEvent.iconColor)

Text(sideEvent.title.currentLangTitle)
.font(.system(size: 14, weight: .bold))
.font(Font.custom(FontAssets.Montserrat.medium, size: 14))
.fontWeight(.bold)
}
// Description
Text(sideEvent.description_.currentLangTitle)
.font(.system(size: 14, weight: .medium))
.font(Font.custom(FontAssets.Montserrat.medium, size: 14))
}
// Date
HStack(alignment: .center, spacing: 4) {
Assets.Icons.accessTime.swiftUIImage
.frame(width: 16, height: 16)

Text(sideEvent.timeText.currentLangTitle)
.font(.system(size: 12, weight: .medium))
.font(Font.custom(FontAssets.Montserrat.medium, size: 12))
}
}
.foregroundStyle(AssetColors.Surface.onSurface.swiftUIColor)
Expand Down
14 changes: 7 additions & 7 deletions app-ios/Modules/Sources/Session/SessionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public struct SessionView: View {
ScrollView {
VStack(alignment: .leading) {
Text(viewModel.timetableItem.title.currentLangTitle)
.font(Font.system(size: 24, weight: .medium))
.font(Font.custom(FontAssets.Montserrat.medium, size: 24))
.foregroundStyle(AssetColors.Surface.onSurfaceVariant.swiftUIColor)
.padding(.horizontal, 16)
.padding(.vertical, 24)
Expand Down Expand Up @@ -87,7 +87,7 @@ public struct SessionView: View {
canBeExpanded = false
} label: {
Text("続きを読む")
.font(Font.system(size: 14, weight: .medium))
.font(Font.custom(FontAssets.Montserrat.medium, size: 14))
.foregroundStyle(AssetColors.Primary.primary.swiftUIColor)
.frame(maxWidth: .infinity, minHeight: 40, maxHeight: 40, alignment: .center)
.overlay {
Expand All @@ -105,10 +105,10 @@ public struct SessionView: View {

VStack(alignment: .leading, spacing: 16) {
Text("対象者")
.font(Font.system(size: 14, weight: .semibold))
.font(Font.custom(FontAssets.Montserrat.semiBold, size: 14))
.foregroundStyle(AssetColors.Surface.onSurfaceVariant.swiftUIColor)
Text(viewModel.timetableItem.targetAudience)
.font(Font.system(size: 16))
.font(Font.custom(FontAssets.Montserrat.medium, size: 16))
.foregroundStyle(AssetColors.Surface.onSurface.swiftUIColor)
}
.padding(.vertical, 24)
Expand All @@ -118,7 +118,7 @@ public struct SessionView: View {

VStack(alignment: .leading, spacing: 16) {
Text("スピーカー")
.font(Font.system(size: 14, weight: .semibold))
.font(Font.custom(FontAssets.Montserrat.semiBold, size: 14))
.foregroundStyle(AssetColors.Surface.onSurfaceVariant.swiftUIColor)

VStack(alignment: .leading, spacing: 8) {
Expand All @@ -138,10 +138,10 @@ public struct SessionView: View {
)
VStack(alignment: .leading, spacing: 0) {
Text(speaker.name)
.font(Font.system(size: 16))
.font(Font.custom(FontAssets.Montserrat.medium, size: 16))
.foregroundStyle(AssetColors.Surface.onSurface.swiftUIColor)
Text(speaker.tagLine)
.font(Font.system(size: 12))
.font(Font.custom(FontAssets.Montserrat.medium, size: 12))
.foregroundStyle(AssetColors.Surface.onSurfaceVariant.swiftUIColor)
}
}
Expand Down
2 changes: 1 addition & 1 deletion app-ios/Modules/Sources/Sponsor/SponsorGridView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct SponsorGridView: View {
var body: some View {
VStack(alignment: .leading, spacing: 16) {
Text(title)
.font(.system(size: 22, weight: .semibold, design: .default))
.font(Font.custom(FontAssets.Montserrat.medium, size: 22))
.foregroundStyle(AssetColors.Surface.onSurface.swiftUIColor)
LazyVGrid(columns: Array(repeating: GridItem(spacing: 16), count: columns), spacing: 16) {
ForEach(sponsors) { sponsor in
Expand Down
Binary file not shown.
Binary file not shown.
10 changes: 10 additions & 0 deletions app-ios/Modules/Sources/Theme/swiftgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,13 @@ xcassets:
enumName: AssetColors
publicAccess: true
bundle: Bundle.myModule

fonts:
inputs:
- Font
outputs:
templateName: swift5
output: Fonts.swift
params:
enumName: FontAssets
publicAccess: true
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ private struct BookmarkEmptyView: View {
.clipShape(RoundedRectangle(cornerRadius: 24))
Spacer().frame(height: 24)
Text("登録されたセッションがありません")
.font(Font.system(size: 22))
.font(Font.custom(FontAssets.Montserrat.medium, size: 22))
.multilineTextAlignment(.center)
.foregroundStyle(AssetColors.Surface.onSurface.swiftUIColor)
Spacer().frame(height: 8)
Text("気になるセッションをブックマークに追加して集めてみましょう!")
.font(Font.system(size: 14))
.font(Font.custom(FontAssets.Montserrat.medium, size: 14))
.multilineTextAlignment(.center)
.foregroundStyle(AssetColors.Surface.onSurfaceVariant.swiftUIColor)
}
Expand Down
2 changes: 1 addition & 1 deletion app-ios/Modules/Sources/Timetable/FilterLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct FilterLabel: View {
Assets.Icons.check.swiftUIImage
}
Text(title)
.font(Font.system(size: 14, weight: .medium))
.font(Font.custom(FontAssets.Montserrat.medium, size: 14))
if isSelection {
Assets.Icons.arrowDropDown.swiftUIImage
}
Expand Down
2 changes: 1 addition & 1 deletion app-ios/Modules/Sources/Timetable/PersonLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct PersonLabel: View {

Text(speaker.name)
.foregroundStyle(AssetColors.Surface.onSurface.swiftUIColor)
.font(Font.system(size: 14, weight: .medium))
.font(Font.custom(FontAssets.Montserrat.medium, size: 14))
.lineLimit(2)
}
.frame(maxWidth: .infinity, alignment: .leading)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ private struct SearchEmptyView: View {
.background(AssetColors.Secondary.secondaryContainer.swiftUIColor)
.clipShape(RoundedRectangle(cornerRadius: 24))
Text("「\(inputText)」と一致する検索結果がありません")
.font(Font.system(size: 16, weight: .medium))
.font(Font.custom(FontAssets.Montserrat.medium, size: 16))
.multilineTextAlignment(.center)
.foregroundStyle(AssetColors.Surface.onSurfaceVariant.swiftUIColor)
}
Expand Down
3 changes: 2 additions & 1 deletion app-ios/Modules/Sources/Timetable/SessionTag.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import SwiftUI
import Theme

struct SessionTag: View {

Expand All @@ -21,7 +22,7 @@ struct SessionTag: View {

var body: some View {
Text(label)
.font(Font.system(size: 12, weight: .medium))
.font(Font.custom(FontAssets.Montserrat.medium, size: 12))
.padding(.horizontal, 8)
.padding(.vertical, 4)
.foregroundColor(labelColor)
Expand Down
6 changes: 4 additions & 2 deletions app-ios/Modules/Sources/Timetable/SessionTimeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ struct SessionTimeView: View {
VStack(spacing: 4) {
Text(startsTimeString)
.foregroundStyle(AssetColors.Surface.onSurface.swiftUIColor)
.font(Font(UIFont.systemFont(ofSize: 16, weight: .bold)))
.font(Font.custom(FontAssets.Montserrat.medium, size: 16))
.fontWeight(.bold)
.frame(height: 24)
Rectangle()
.foregroundColor(AssetColors.Outline.outlineVariant.swiftUIColor)
.frame(width: 2, height: 8)
Text(endsTimeString)
.foregroundStyle(AssetColors.Secondary.secondary.swiftUIColor)
.font(Font(UIFont.systemFont(ofSize: 16, weight: .bold)))
.font(Font.custom(FontAssets.Montserrat.medium, size: 16))
.fontWeight(.bold)
.frame(height: 24)
}
}
Expand Down
5 changes: 2 additions & 3 deletions app-ios/Modules/Sources/Timetable/TimetableDayHeader.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Assets
import Model
import shared
import SwiftUI
Expand Down Expand Up @@ -32,10 +31,10 @@ struct TimetableDayHeader: View {
} label: {
VStack(spacing: 0) {
Text(day.name)
.font(Font.system(size: 12, weight: .semibold))
.font(Font.custom(FontAssets.Montserrat.semiBold, size: 12))
if !shouldCollapse {
Text("\(day.dayOfMonth)")
.font(Font.system(size: 24, weight: .semibold))
.font(Font.custom(FontAssets.Montserrat.semiBold, size: 24))
.frame(height: 32)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct TimetableListItemView: View {
Spacer().frame(height: 8)
Text(addHighlightAttributes(title: timetableItem.title.currentLangTitle, searchWord: searchWord))
.multilineTextAlignment(.leading)
.font(Font.system(size: 22, weight: .medium, design: .default))
.font(Font.custom(FontAssets.Montserrat.medium, size: 22))
.foregroundStyle(AssetColors.Surface.onSurface.swiftUIColor)
if let session = timetableItem as? TimetableItem.Session {
if let message = session.message {
Expand All @@ -44,7 +44,8 @@ struct TimetableListItemView: View {
.renderingMode(.template)
Text(message.currentLangTitle)
.multilineTextAlignment(.leading)
.font(Font.system(size: 12, weight: .regular, design: .default))
.font(Font.custom(FontAssets.Montserrat.medium, size: 12))
.fontWeight(.regular)
}
.foregroundStyle(AssetColors.Error.error.swiftUIColor)
Spacer().frame(height: 4)
Expand Down
4 changes: 2 additions & 2 deletions app-ios/Modules/Sources/Timetable/TimetableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public struct TimetableView<SessionView: View>: View {
HStack(spacing: 0) {
VStack(alignment: .leading, spacing: 0) {
Text("DroidKaigi\n2023")
.font(Font.system(size: 36))
.font(Font.custom(FontAssets.Montserrat.medium, size: 36))
Text("at Bellesalle Shibuya Garden")
.font(Font.system(size: 12, weight: .semibold))
.font(Font.custom(FontAssets.Montserrat.semiBold, size: 12))
}
.padding(.horizontal, 16)
.foregroundStyle(AssetColors.Surface.onSurfaceVariant.swiftUIColor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import org.jetbrains.compose.resources.resource
val fontMap: HashMap<String, FontFamily?> = HashMap()

// https://ishroid.medium.com/custom-font-loading-in-kmp-compose-multiplatform-2eb19865f61b
// FIXME We initially planned to use this implementation on the iOS side.
// However, when shared.swift is output by XCFramework, methods with Compose annotations are not output.
// Therefore, this implementation cannot be referenced from the iOS side.
@ExperimentalResourceApi
@Composable
actual fun fontFamilyResource(fontResource: FontResource): FontFamily? {
Expand Down
Loading