item-atlas/apps/ios/ItemAtlas/WelcomeView.swift

125 lines
4.8 KiB
Swift

import SwiftUI
struct EntryBrand: View {
var prominent = false
var body: some View {
let size: CGFloat = prominent ? 52 : 32
HStack(spacing: prominent ? 12 : 9) {
Image("BrandMark")
.resizable()
.frame(width: size, height: size)
.clipShape(.rect(cornerRadius: prominent ? 12 : 8))
.accessibilityHidden(true)
Text("见物").font(prominent ? .largeTitle.weight(.bold) : .headline)
}
.accessibilityElement(children: .combine)
.accessibilityAddTraits(prominent ? .isHeader : [])
}
}
extension Color {
static func entryBackground(for scheme: ColorScheme) -> Color {
scheme == .dark ? Color(uiColor: .systemBackground) : Color(red: 0.976, green: 0.969, blue: 0.951)
}
}
struct WelcomeView: View {
let account: AtlasAccount
@Environment(\.colorScheme) private var colorScheme
var body: some View {
ScrollView {
VStack(alignment: .leading, spacing: 18) {
VStack(spacing: 9) {
EntryBrand(prominent: true)
Text("于寻常处,见生活。")
.font(.system(.title3, design: .serif).weight(.medium))
.foregroundStyle(.primary.opacity(0.78))
.multilineTextAlignment(.center)
}
.frame(maxWidth: .infinity)
scene
featureExamples
}
.frame(maxWidth: 460, alignment: .leading)
.padding(.horizontal, 24)
.padding(.top, 21)
.padding(.bottom, 24)
.frame(maxWidth: .infinity, alignment: .top)
}
.safeAreaInset(edge: .bottom, spacing: 0) {
signInLink
.frame(maxWidth: 460)
.padding(.horizontal, 24)
.padding(.vertical, 12)
.frame(maxWidth: .infinity)
.background(Color.entryBackground(for: colorScheme))
}
.background(Color.entryBackground(for: colorScheme).ignoresSafeArea())
.toolbar(.hidden, for: .navigationBar)
}
private var featureExamples: some View {
VStack(spacing: 9) {
feature("AI 智能录入", symbol: "waveform",
example: "语音输入:“数据线放在书房抽屉”", detail: "说一句,见物帮你记下。")
feature("智能找物", symbol: "magnifyingglass",
example: "备用钥匙放哪了?", detail: "玄关 / 鞋柜 / 上层抽屉")
feature("社区", symbol: "bubble.left.and.bubble.right",
example: "这个硬盘盒好用吗?", detail: "公开分享使用感受,也可以评论和打分。")
}
}
private func feature(_ title: String, symbol: String, example: String, detail: String) -> some View {
HStack(alignment: .top, spacing: 12) {
Image(systemName: symbol)
.font(.subheadline.weight(.semibold))
.foregroundStyle(Color.atlasBlue)
.frame(width: 35, height: 35)
.background(Color.atlasBlue.opacity(0.10), in: .rect(cornerRadius: 10))
.accessibilityHidden(true)
VStack(alignment: .leading, spacing: 3) {
Text(title).font(.caption.weight(.semibold)).foregroundStyle(.secondary)
Text(example).font(.subheadline.weight(.semibold))
Text(detail).font(.footnote).foregroundStyle(.secondary)
}
}
.padding(11)
.frame(maxWidth: .infinity, alignment: .leading)
.background(Color(uiColor: .secondarySystemGroupedBackground), in: .rect(cornerRadius: 15))
.accessibilityElement(children: .combine)
}
private var signInLink: some View {
NavigationLink {
SignInView(account: account)
} label: {
HStack(spacing: 9) {
Text("进入我的空间")
Image(systemName: "arrow.right").accessibilityHidden(true)
}
.font(.body.weight(.semibold))
.frame(maxWidth: .infinity, minHeight: 29)
}
.buttonStyle(.borderedProminent)
.buttonBorderShape(.roundedRectangle(radius: 15))
.controlSize(.large)
}
private var scene: some View {
Color.clear
.aspectRatio(1.72, contentMode: .fit)
.overlay {
GeometryReader { frame in
Image("WelcomeTray")
.resizable()
.scaledToFill()
.frame(width: frame.size.width, height: frame.size.height, alignment: .bottom)
}
}
.clipShape(.rect(cornerRadius: 21))
.accessibilityHidden(true)
}
}