-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create common component for information row
- Loading branch information
Showing
5 changed files
with
104 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import SwiftUI | ||
import Theme | ||
|
||
public struct InformationRow: View { | ||
private let icon: Image | ||
private let title: String | ||
private let content: String | ||
private let action: Action? | ||
|
||
public struct Action { | ||
let label: String | ||
let action: () -> Void | ||
|
||
public init(label: String, action: @escaping () -> Void) { | ||
self.label = label | ||
self.action = action | ||
} | ||
} | ||
|
||
public init( | ||
icon: Image, | ||
title: String, | ||
content: String, | ||
action: Action? = nil | ||
) { | ||
self.icon = icon | ||
self.title = title | ||
self.content = content | ||
self.action = action | ||
} | ||
|
||
public var body: some View { | ||
HStack { | ||
icon | ||
HStack(spacing: 12) { | ||
Text(title) | ||
.font(Font.system(size: 14, weight: .semibold)) | ||
HStack { | ||
Text(content) | ||
.font(Font.system(size: 14, weight: .semibold)) | ||
if let action = action { | ||
Button { | ||
action.action() | ||
} label: { | ||
Text(action.label) | ||
.font(Font.system(size: 14, weight: .semibold)) | ||
.underline() | ||
.foregroundStyle( | ||
AssetColors.Primary.primary.swiftUIColor | ||
) | ||
} | ||
} | ||
} | ||
|
||
} | ||
} | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
.foregroundStyle( | ||
AssetColors.Surface.onSurfaceVariant.swiftUIColor | ||
) | ||
} | ||
} | ||
|
||
#Preview { | ||
InformationRow( | ||
icon: Image(systemName: "clock"), | ||
title: "日付", | ||
content: "2023.09.14 / 11:20 ~ 12:00 (40分)", | ||
action: .init( | ||
label: "地図を見る", | ||
action: {} | ||
) | ||
) | ||
} |
32 changes: 0 additions & 32 deletions
32
app-ios/Modules/Sources/Session/SessionInformationRow.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters