feat(component): 섹션 타이틀 컴포넌트를 추가한다

This commit is contained in:
Yu Sung
2026-05-19 21:26:47 +09:00
parent 942c581eaf
commit ca8da51991
5 changed files with 332 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "ic_chevron_right.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

View File

@@ -0,0 +1,63 @@
//
// SectionTitle.swift
// SodaLive
//
import SwiftUI
struct SectionTitle: View {
let title: String
let action: (() -> Void)?
init(
title: String,
action: (() -> Void)? = nil
) {
self.title = title
self.action = action
}
var body: some View {
content
}
private var content: some View {
HStack(alignment: .center, spacing: 0) {
Text(title)
.appFont(.heading3)
.foregroundColor(.white)
.lineLimit(1)
.truncationMode(.tail)
Spacer(minLength: 0)
if let action {
Button(action: action) {
Image("ic_chevron_right")
.resizable()
.renderingMode(.template)
.foregroundColor(.white)
.scaledToFit()
.frame(width: 24, height: 24)
}
.buttonStyle(.plain)
.accessibilityLabel(title)
.accessibilityAddTraits(.isButton)
}
}
.padding(.horizontal, SodaSpacing.s20)
.frame(maxWidth: .infinity)
.frame(height: 42, alignment: .center)
}
}
struct SectionTitle_Previews: PreviewProvider {
static var previews: some View {
VStack(spacing: SodaSpacing.s12) {
SectionTitle(title: "텍스트")
SectionTitle(title: "긴 섹션 타이틀은 한 줄로 줄임 처리됩니다 한 줄로 줄임 처리됩니다") {}
}
.background(Color.black)
.previewLayout(.sizeThatFits)
}
}