feat(component): 섹션 타이틀 컴포넌트를 추가한다
This commit is contained in:
21
SodaLive/Resources/Assets.xcassets/v2/ic_chevron_right.imageset/Contents.json
vendored
Normal file
21
SodaLive/Resources/Assets.xcassets/v2/ic_chevron_right.imageset/Contents.json
vendored
Normal 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
|
||||
}
|
||||
}
|
||||
BIN
SodaLive/Resources/Assets.xcassets/v2/ic_chevron_right.imageset/ic_chevron_right.png
vendored
Normal file
BIN
SodaLive/Resources/Assets.xcassets/v2/ic_chevron_right.imageset/ic_chevron_right.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 210 B |
63
SodaLive/Sources/V2/Component/SectionTitle.swift
Normal file
63
SodaLive/Sources/V2/Component/SectionTitle.swift
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user