Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

feat(ios): show first-login note sync progress like Android

tianma-ifa32272019f28
diff --git a/apps/ios/EdgeEver/App/AppEnvironment.swift b/apps/ios/EdgeEver/App/AppEnvironment.swift
index df6d9350..2140ea21 100644
--- a/apps/ios/EdgeEver/App/AppEnvironment.swift
+++ b/apps/ios/EdgeEver/App/AppEnvironment.swift
@@ -60,6 +60,13 @@ final class AppEnvironment {
func bootstrap() async {
await session.bootstrap()
if session.isSignedIn {
+ // Surface first-sync progress before TipTap warm / network so the workspace
+ // never flashes an empty-notebook state on cold start.
+ if let scope = session.dataScope,
+ !((try? mirror.isInitialized(scope: scope)) ?? false)
+ {
+ bootstrapProgress = BootstrapProgress(loadedCount: 0, totalCount: 0)
+ }
// Warm TipTap process + EditorBundle off the critical path of the first note open.
await MainActor.run { TipTapWarmPool.warmIfNeeded() }
await runSyncCycle()
@@ -73,17 +80,36 @@ final class AppEnvironment {
isSyncing = true
lastSyncError = nil
defer { isSyncing = false }
+
+ // Android parity: only surface bootstrap progress UI on the first mirror fill
+ // (cursor/identity missing). Incremental sync stays quiet.
+ let isInitialSync = !((try? mirror.isInitialized(scope: scope)) ?? false)
+ if isInitialSync {
+ bootstrapProgress = BootstrapProgress(loadedCount: 0, totalCount: 0)
+ }
+
do {
_ = try await outboxFlusher.flush(scope: scope, force: force)
- _ = try await syncEngine.sync(scope: scope) { [weak self] progress in
- Task { @MainActor in
- self?.bootstrapProgress = progress
+
+ let progressHandler: (@Sendable (BootstrapProgress) -> Void)?
+ if isInitialSync {
+ progressHandler = { [weak self] progress in
+ DispatchQueue.main.async {
+ self?.bootstrapProgress = progress
+ }
}
+ } else {
+ progressHandler = nil
}
+
+ _ = try await syncEngine.sync(scope: scope, onBootstrapProgress: progressHandler)
lastOutboxResult = try await outboxFlusher.flush(scope: scope, force: force)
bootstrapProgress = nil
} catch {
lastSyncError = error.localizedDescription
+ if isInitialSync {
+ bootstrapProgress = nil
+ }
}
}
}
diff --git a/apps/ios/EdgeEver/DesignSystem/Theme.swift b/apps/ios/EdgeEver/DesignSystem/Theme.swift
index 53e268a0..b0907756 100644
--- a/apps/ios/EdgeEver/DesignSystem/Theme.swift
+++ b/apps/ios/EdgeEver/DesignSystem/Theme.swift
@@ -28,6 +28,16 @@ enum AppTheme {
static let accentText = Color(hex: 0x065F46)
static let danger = Color(hex: 0xDC2626)
+ // First-sync progress / error (Android memoSync* + memoListLoading* / memoListError*)
+ static let syncProgressTrack = Color(hex: 0xD1FAE5)
+ static let syncProgressFill = Color(hex: 0x059669)
+ static let syncErrorBackground = Color(hex: 0xFFFBEB)
+ static let syncErrorBorder = Color(hex: 0xFCD34D)
+ static let syncErrorTitle = Color(hex: 0x451A03)
+ static let syncErrorBody = Color(hex: 0x92400E)
+ static let syncErrorRetryFill = Color(hex: 0xFEF3C7)
+ static let emptyDashBorder = Color(hex: 0xCBD5E1)
+
// Tag chip
static let tagBackground = Color(hex: 0xF1F5F9)
@@ -41,6 +51,9 @@ enum AppTheme {
static let tagFont = Font.system(size: 12, weight: .medium)
static let searchFont = Font.system(size: 14)
static let bottomNavFont = Font.system(size: 11, weight: .bold)
+
+ /// Android `fontWeight: "800"`.
+ static let heavy = Font.Weight.heavy
}
extension Color {
diff --git a/apps/ios/EdgeEver/Features/Workspace/NotesListView.swift b/apps/ios/EdgeEver/Features/Workspace/NotesListView.swift
index 7438a881..a676ed71 100644
--- a/apps/ios/EdgeEver/Features/Workspace/NotesListView.swift
+++ b/apps/ios/EdgeEver/Features/Workspace/NotesListView.swift
@@ -13,9 +13,49 @@ struct NotesListView: View {
/// First-paint cascade: cards insert with Pow boing (cleared after entrance finishes).
@State private var listEntranceCascade = false
+ /// First-login / first-mirror bootstrap (Android `initialSyncProgress`).
+ private var hasBootstrapProgress: Bool {
+ env.bootstrapProgress != nil
+ }
+
+ private var bootstrapLoaded: Int {
+ env.bootstrapProgress?.loadedCount ?? 0
+ }
+
+ private var bootstrapTotal: Int {
+ env.bootstrapProgress?.totalCount ?? 0
+ }
+
+ private var bootstrapPercent: Double {
+ guard bootstrapTotal > 0 else { return 0 }
+ return min(1, Double(bootstrapLoaded) / Double(bootstrapTotal))
+ }
+
+ private var bootstrapTitle: String {
+ env.preferences.t("正在同步笔记", en: "Syncing notes")
+ }
+
+ private var bootstrapDescription: String {
+ if bootstrapTotal > 0 {
+ return env.preferences.t(
+ "已加载 \(bootstrapLoaded) / \(bootstrapTotal) 条笔记",
+ en: "Loaded \(bootstrapLoaded) of \(bootstrapTotal) notes"
+ )
+ }
+ return env.preferences.t("正在准备首次同步…", en: "Preparing first sync…")
+ }
+
var body: some View {
Group {
- if store.notebooks.isEmpty && store.memos.isEmpty && !store.isLoadingList {
+ // Android MemoList: full loading card while first mirror is empty.
+ if hasBootstrapProgress && store.memos.isEmpty {
+ bootstrapLoadingCard
+ .transition(Motion.softFade)
+ } else if store.memos.isEmpty && env.lastSyncError != nil && !store.isLoadingList {
+ // Failed first sync with no cached notes — don't pretend the account is empty.
+ initialSyncErrorCard
+ .transition(Motion.softFade)
+ } else if store.notebooks.isEmpty && store.memos.isEmpty && !store.isLoadingList {
emptyCard(
title: env.preferences.t("暂无笔记本", en: "No notebooks"),
description: env.preferences.t(
@@ -31,10 +71,19 @@ struct NotesListView: View {
} else {
ScrollViewReader { proxy in
ScrollView {
+ // Android FlatList `list`: paddingTop 12, paddingHorizontal 12, paddingBottom 18
LazyVStack(spacing: 0) {
+ if hasBootstrapProgress {
+ bootstrapProgressBanner
+ // memoSyncBanner marginBottom: 10
+ .padding(.bottom, 10)
+ } else if env.lastSyncError != nil, !store.memos.isEmpty {
+ syncPausedBanner
+ .padding(.bottom, 10)
+ }
+
ForEach(Array(store.memos.enumerated()), id: \.element.id) { index, memo in
memoCard(for: memo)
- .padding(.horizontal, 12)
.padding(.bottom, env.preferences.listDensity.cardBottomMargin)
.id(memo.id)
// First open: elastic boing cascade. Later reshuffles: quiet opacity.
@@ -57,11 +106,13 @@ struct NotesListView: View {
.padding(.vertical, 18)
}
}
+ .padding(.horizontal, 12)
.padding(.top, 12)
- .padding(.bottom, 8)
+ .padding(.bottom, 18)
.animation(Motion.listContent, value: store.memos.map(\.id))
.animation(Motion.listContent, value: store.filter)
.animation(Motion.listContent, value: store.searchText)
+ .animation(Motion.search, value: hasBootstrapProgress)
}
.contentMargins(.bottom, 0, for: .scrollContent)
.background(AppTheme.background)
@@ -90,6 +141,7 @@ struct NotesListView: View {
}
}
.animation(Motion.listContent, value: store.memos.isEmpty)
+ .animation(Motion.search, value: hasBootstrapProgress)
.onChange(of: store.memos.count) { _, count in
scheduleListEntranceIfNeeded(hasMemos: count > 0)
}
@@ -109,6 +161,213 @@ struct NotesListView: View {
}
}
.animation(Motion.search, value: store.listError)
+ .accessibilityElement(children: .contain)
+ }
+
+ // MARK: - First-sync progress (pixel tokens from Android workspace-styles.ts)
+
+ /// Android `memoListStateWrap` + `memoListLoadingCard`.
+ private var bootstrapLoadingCard: some View {
+ VStack(spacing: 0) {
+ VStack(spacing: 0) {
+ ProgressView()
+ .controlSize(.large)
+ .tint(AppTheme.syncProgressFill)
+
+ Text(bootstrapTitle)
+ .font(.system(size: 16, weight: AppTheme.heavy))
+ .foregroundStyle(AppTheme.title)
+ .multilineTextAlignment(.center)
+ .padding(.top, 14)
+
+ Text(bootstrapDescription)
+ .font(.system(size: 13))
+ .foregroundStyle(AppTheme.secondary)
+ .lineSpacing(4) // ~lineHeight 20 on 13pt
+ .multilineTextAlignment(.center)
+ .padding(.top, 7)
+ .frame(maxWidth: 300)
+
+ if bootstrapTotal > 0 {
+ // Android `memoSyncProgressTrack` marginTop: 10
+ bootstrapProgressTrack(percent: bootstrapPercent)
+ .padding(.top, 10)
+ }
+ }
+ .frame(maxWidth: .infinity)
+ .padding(.horizontal, 16)
+ .padding(.vertical, 34)
+ .background(Color.white)
+ .overlay(
+ RoundedRectangle(cornerRadius: 8)
+ .stroke(style: StrokeStyle(lineWidth: 1, dash: [5, 4]))
+ .foregroundStyle(AppTheme.accentBorder)
+ )
+ .clipShape(RoundedRectangle(cornerRadius: 8))
+ // memoListStateWrap: paddingHorizontal 12, paddingTop 16
+ .padding(.horizontal, 12)
+ .padding(.top, 16)
+ .accessibilityElement(children: .combine)
+ .accessibilityLabel("\(bootstrapTitle). \(bootstrapDescription)")
+
+ Spacer(minLength: 0)
+ }
+ .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
+ .background(AppTheme.background)
+ }
+
+ /// Android `memoSyncBanner` (+ track always visible while bootstrap is active).
+ private var bootstrapProgressBanner: some View {
+ HStack(alignment: .center, spacing: 12) {
+ ProgressView()
+ .controlSize(.small)
+ .tint(AppTheme.syncProgressFill)
+
+ VStack(alignment: .leading, spacing: 0) {
+ Text(bootstrapTitle)
+ .font(.system(size: 13, weight: AppTheme.heavy))
+ .foregroundStyle(AppTheme.accentText)
+
+ Text(bootstrapDescription)
+ .font(.system(size: 12))
+ .foregroundStyle(AppTheme.accentStrong)
+ .padding(.top, 2)
+
+ bootstrapProgressTrack(percent: bootstrapPercent)
+ .padding(.top, 10)
+ }
+ .frame(maxWidth: .infinity, alignment: .leading)
+ }
+ .padding(.horizontal, 14)
+ .padding(.vertical, 12)
+ .background(AppTheme.accentSoft)
+ .overlay(
+ RoundedRectangle(cornerRadius: 8)
+ .stroke(AppTheme.accentBorder, lineWidth: 1)
+ )
+ .clipShape(RoundedRectangle(cornerRadius: 8))
+ .accessibilityElement(children: .combine)
+ .accessibilityLabel("\(bootstrapTitle). \(bootstrapDescription)")
+ }
+
+ /// Android `memoSyncProgressTrack` / `memoSyncProgressFill`.
+ private func bootstrapProgressTrack(percent: Double) -> some View {
+ GeometryReader { geo in
+ ZStack(alignment: .leading) {
+ Capsule()
+ .fill(AppTheme.syncProgressTrack)
+ Capsule()
+ .fill(AppTheme.syncProgressFill)
+ .frame(width: max(0, geo.size.width * percent))
+ .animation(.easeOut(duration: 0.2), value: percent)
+ }
+ }
+ .frame(height: 4)
+ .frame(maxWidth: .infinity)
+ .clipShape(Capsule())
+ }
+
+ /// Android `memoListErrorCard` + retry.
+ private var initialSyncErrorCard: some View {
+ VStack(spacing: 0) {
+ VStack(spacing: 0) {
+ Text(env.preferences.t("暂时没有拉到笔记", en: "Could not load notes"))
+ .font(.system(size: 14, weight: AppTheme.heavy))
+ .foregroundStyle(AppTheme.syncErrorTitle)
+ .multilineTextAlignment(.center)
+
+ Text(env.preferences.t(
+ "网络或 PWA 后台恢复可能短暂中断了同步。这里不会把它当作空笔记本。",
+ en: "A network hiccup may have interrupted sync. This is not treated as an empty notebook."
+ ))
+ .font(.system(size: 12))
+ .foregroundStyle(AppTheme.syncErrorBody)
+ .lineSpacing(4) // ~lineHeight 20
+ .multilineTextAlignment(.center)
+ .padding(.top, 8)
+ .frame(maxWidth: 300)
+
+ Button {
+ Task { await env.runSyncCycle(force: true) }
+ } label: {
+ HStack(spacing: 7) {
+ Image(systemName: "arrow.clockwise")
+ .font(.system(size: 15, weight: .semibold))
+ Text(env.preferences.t("重试", en: "Retry"))
+ .font(.system(size: 13, weight: AppTheme.heavy))
+ }
+ .foregroundStyle(AppTheme.syncErrorBody)
+ .padding(.horizontal, 12)
+ .frame(minHeight: 36)
+ .background(AppTheme.syncErrorRetryFill)
+ .clipShape(RoundedRectangle(cornerRadius: 8))
+ }
+ .buttonStyle(.plain)
+ .padding(.top, 16)
+ .accessibilityLabel(env.preferences.t("重试加载", en: "Retry loading"))
+ }
+ .frame(maxWidth: .infinity)
+ .padding(.horizontal, 16)
+ .padding(.vertical, 34)
+ .background(AppTheme.syncErrorBackground)
+ .overlay(
+ RoundedRectangle(cornerRadius: 8)
+ .stroke(style: StrokeStyle(lineWidth: 1, dash: [5, 4]))
+ .foregroundStyle(AppTheme.syncErrorBorder)
+ )
+ .clipShape(RoundedRectangle(cornerRadius: 8))
+ .padding(.horizontal, 12)
+ .padding(.top, 16)
+
+ Spacer(minLength: 0)
+ }
+ .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
+ .background(AppTheme.background)
+ }
+
+ /// Android `memoSyncErrorBanner` (no technical error string in the banner body).
+ private var syncPausedBanner: some View {
+ HStack(alignment: .center, spacing: 10) {
+ VStack(alignment: .leading, spacing: 0) {
+ Text(env.preferences.t("同步已暂停", en: "Sync paused"))
+ .font(.system(size: 13, weight: AppTheme.heavy))
+ .foregroundStyle(AppTheme.syncErrorTitle)
+
+ Text(env.preferences.t(
+ "已加载的笔记仍可使用,请检查网络后重试。",
+ en: "Loaded notes remain available. Check your connection and retry."
+ ))
+ .font(.system(size: 12))
+ .foregroundStyle(AppTheme.syncErrorBody)
+ .lineSpacing(3) // ~lineHeight 18
+ .fixedSize(horizontal: false, vertical: true)
+ .padding(.top, 2)
+ }
+ .frame(maxWidth: .infinity, alignment: .leading)
+
+ Button {
+ Task { await env.runSyncCycle(force: true) }
+ } label: {
+ HStack(spacing: 5) {
+ Image(systemName: "arrow.clockwise")
+ .font(.system(size: 13, weight: .semibold))
+ Text(env.preferences.t("重试", en: "Retry"))
+ .font(.system(size: 13, weight: AppTheme.heavy))
+ }
+ .foregroundStyle(AppTheme.syncErrorBody)
+ .padding(.horizontal, 4)
+ .padding(.vertical, 8)
+ }
+ .buttonStyle(.plain)
+ }
+ .padding(.horizontal, 14)
+ .padding(.vertical, 12)
+ .background(AppTheme.syncErrorBackground)
+ .overlay(
+ RoundedRectangle(cornerRadius: 8)
+ .stroke(AppTheme.syncErrorBorder, lineWidth: 1)
+ )
+ .clipShape(RoundedRectangle(cornerRadius: 8))
}
private func scheduleListEntranceIfNeeded(hasMemos: Bool) {
@@ -151,10 +410,11 @@ struct NotesListView: View {
)
}
+ /// Android `memoListEmptyCard` + `emptyTitle` / `mutedText`.
private func emptyCard(title: String, description: String, showCreate: Bool) -> some View {
VStack(spacing: 10) {
Text(title)
- .font(.system(size: 16, weight: .heavy))
+ .font(.system(size: 16, weight: AppTheme.heavy))
.foregroundStyle(AppTheme.meta)
Text(description)
.font(.system(size: 13))
@@ -171,8 +431,10 @@ struct NotesListView: View {
.overlay(
RoundedRectangle(cornerRadius: 8)
.stroke(style: StrokeStyle(lineWidth: 1, dash: [5, 4]))
- .foregroundStyle(Color(hex: 0xCBD5E1))
+ .foregroundStyle(AppTheme.emptyDashBorder)
)
+ .clipShape(RoundedRectangle(cornerRadius: 8))
+ // memoListEmptyCard: marginHorizontal 12, marginTop 12
.padding(.horizontal, 12)
.padding(.top, 12)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
diff --git a/apps/ios/EdgeEver/Features/Workspace/WorkspaceView.swift b/apps/ios/EdgeEver/Features/Workspace/WorkspaceView.swift
index 1ec6c8ac..0a2e6485 100644
--- a/apps/ios/EdgeEver/Features/Workspace/WorkspaceView.swift
+++ b/apps/ios/EdgeEver/Features/Workspace/WorkspaceView.swift
@@ -148,6 +148,14 @@ struct WorkspaceView: View {
syncPulse += 1
}
}
+ // Android invalidates the memo list on each bootstrap batch so the UI
+ // can show progressive counts / partial notes during first login.
+ .onChange(of: env.bootstrapProgress?.loadedCount) { _, _ in
+ store.reload(env: env)
+ }
+ .onChange(of: env.bootstrapProgress?.totalCount) { _, _ in
+ store.reload(env: env)
+ }
.refreshable {
await env.runSyncCycle(force: true)
store.reload(env: env)
@@ -536,43 +544,28 @@ struct WorkspaceView: View {
.accessibilityIdentifier("selectionBar")
}
+ /// Quiet indicator for incremental sync only.
+ /// First-login progress + sync-error banners live in `NotesListView` (Android MemoList parity).
private var syncBanner: some View {
Group {
- if env.isSyncing {
- VStack(alignment: .leading, spacing: 4) {
- ProgressView(value: progressValue)
+ if env.isSyncing && env.bootstrapProgress == nil {
+ HStack(spacing: 8) {
+ ProgressView()
+ .controlSize(.small)
.tint(AppTheme.accent)
- if let p = env.bootstrapProgress, p.totalCount > 0 {
- Text(env.preferences.t("已加载 \(p.loadedCount) / \(p.totalCount) 条笔记", en: "Loaded \(p.loadedCount) / \(p.totalCount) notes"))
- .font(.caption2)
- .foregroundStyle(AppTheme.secondary)
- } else {
- Text(env.preferences.t("正在同步笔记", en: "Syncing notes"))
- .font(.caption2)
- .foregroundStyle(AppTheme.secondary)
- }
+ Text(env.preferences.t("正在同步笔记", en: "Syncing notes"))
+ .font(.caption2)
+ .foregroundStyle(AppTheme.secondary)
+ Spacer(minLength: 0)
}
.padding(.horizontal, 12)
.padding(.vertical, 6)
.background(Color.white)
.transition(.move(edge: .top).combined(with: .opacity))
}
- if let err = env.lastSyncError {
- Text(err)
- .font(.caption)
- .foregroundStyle(AppTheme.danger)
- .padding(.horizontal, 12)
- .edgeEverErrorShake(on: err)
- .transition(Motion.softFade)
- }
}
.animation(Motion.search, value: env.isSyncing)
- .animation(Motion.search, value: env.lastSyncError)
- }
-
- private var progressValue: Double {
- guard let p = env.bootstrapProgress, p.totalCount > 0 else { return 0 }
- return Double(p.loadedCount) / Double(p.totalCount)
+ .animation(Motion.search, value: env.bootstrapProgress != nil)
}
private func consumeShare() {