Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions iosApp/iosApp/UI/Navigation/FlareDestinationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct FlareDestinationView: View {
let destination: FlareDestination
let router: FlareRouter

@Environment(FlareAppState.self) private var appState
@Environment(FlareMenuState.self) private var menuState
@Environment(\.appSettings) private var appSettings
@Environment(FlareTheme.self) private var theme

Expand All @@ -24,17 +24,15 @@ struct FlareDestinationView: View {
case let .profile(accountType, userKey):
ProfileTabScreenUikit(
accountType: accountType,
userKey: userKey,
toProfileMedia: { _ in }
userKey: userKey
)
.environment(router)

case let .profileWithNameAndHost(accountType, userName, host):
ProfileWithUserNameScreen(
accountType: accountType,
userName: userName,
host: host,
toProfileMedia: { _ in }
host: host
)
.environment(router)

Expand Down Expand Up @@ -125,31 +123,31 @@ struct FlareDestinationView: View {
case let .download(accountType):
DownloadManagerScreen(accountType: accountType)
.environment(router)
.environment(appState)
.environment(menuState)

case let .instanceScreen(host, _):
InstanceScreen(host: host)
.environment(router)
.environment(appState)
.environment(menuState)

case let .podcastSheet(accountType, podcastId):
PodcastSheetView(accountType: accountType, podcastId: podcastId)
.environment(router)
.environment(appState)
.environment(menuState)
.environment(\.appSettings, appSettings)

case let .spaces(accountType):
SpaceScreen(accountType: accountType)
.environment(router)
.environment(appState)
.environment(menuState)

default:
Text("page not found for destination: \(String(describing: destination))")
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
}
.environment(router)
.environment(appState)
.environment(menuState)
.background(theme.primaryBackgroundColor)
.foregroundColor(theme.labelColor)
}
Expand Down
12 changes: 6 additions & 6 deletions iosApp/iosApp/UI/Navigation/FlareRootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import shared
import SwiftUI

struct FlareRootView: View {
@State var appState = FlareAppState()
@State var menuState = FlareMenuState()
@StateObject private var router = FlareRouter.shared
@StateObject private var composeManager = ComposeManager.shared
@StateObject private var timelineState = TimelineExtState()
Expand Down Expand Up @@ -34,7 +34,7 @@ struct FlareRootView: View {
HomeTabViewContentV2(accountType: accountType)
.environment(theme)
.applyTheme(theme)
.environment(appState)
.environment(menuState)
.environment(router)
.environmentObject(timelineState)
.sheet(isPresented: $router.isSheetPresented) {
Expand All @@ -44,7 +44,7 @@ struct FlareRootView: View {
router: router
).environment(theme)
.applyTheme(theme)
.environment(appState)
.environment(menuState)
}
}
.fullScreenCover(isPresented: $router.isFullScreenPresented) {
Expand All @@ -56,7 +56,7 @@ struct FlareRootView: View {
.environment(theme)
.applyTheme(theme)
.environment(\.appSettings, appSettings)
.environment(appState)
.environment(menuState)
}
}
.alert(isPresented: $router.isDialogPresented) {
Expand All @@ -78,7 +78,7 @@ struct FlareRootView: View {
.environment(theme)
.applyTheme(theme)
.environment(router)
.environment(appState)
.environment(menuState)
.environment(\.appSettings, appSettings)
}
}
Expand All @@ -92,7 +92,7 @@ struct FlareRootView: View {
.navigationViewStyle(StackNavigationViewStyle())
.onAppear {
setupInitialState()
router.appState = appState
router.menuState = menuState
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
)
Expand Down
6 changes: 3 additions & 3 deletions iosApp/iosApp/UI/Navigation/FlareRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import UIKit
class FlareRouter: ObservableObject {
public static let shared = FlareRouter()

public var appState: FlareAppState
public var menuState: FlareMenuState

private var cancellables = Set<AnyCancellable>()

Expand Down Expand Up @@ -110,8 +110,8 @@ class FlareRouter: ObservableObject {
log: .default, type: .debug, String(describing: tab))
}

init(appState: FlareAppState = FlareAppState()) {
self.appState = appState
init(menuState: FlareMenuState = FlareMenuState()) {
self.menuState = menuState
os_log("[FlareRouter] Initialized router: %{public}@", log: .default, type: .debug, String(describing: ObjectIdentifier(self)))
}

Expand Down
8 changes: 1 addition & 7 deletions iosApp/iosApp/UI/Page/Compose/Text/FlareMarkdownStyle.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import MarkdownUI
import SwiftUI

// 扩展的是 MarkdownUI.Theme
extension MarkdownUI.Theme {
static func flareMarkdownStyle(using style: FlareTextStyle.Style, fontScale: Double) -> MarkdownUI.Theme {
// 获取基础字体大小
let baseFontSize = style.font.pointSize
// 应用用户的字体缩放设置

let scaledFontSize = baseFontSize * fontScale

return MarkdownUI.Theme()
Expand All @@ -23,21 +21,17 @@ extension MarkdownUI.Theme {
// UnderlineStyle(.single)
}
.strong {
// 粗体文本
FontWeight(.semibold)
ForegroundColor(Color(style.textColor))
}
.emphasis {
// 斜体文本
FontStyle(.italic)
ForegroundColor(Color(style.textColor))
}
.code {
// 行内代码
FontFamilyVariant(.monospaced)
FontSize(scaledFontSize * 0.9)
ForegroundColor(Color(style.textColor))
// BackgroundColor(Color.gray.opacity(0.1))
}
}
}
17 changes: 7 additions & 10 deletions iosApp/iosApp/UI/Page/Compose/Text/FlareText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import SwiftUI
import TwitterText

public enum FlareTextType {
case body
case caption
case flareTextTypeBody
case flareTextTypeCaption
}

public struct FlareText: View, Equatable {
Expand All @@ -20,10 +20,7 @@ public struct FlareText: View, Equatable {
public static func == (lhs: FlareText, rhs: FlareText) -> Bool {
lhs.text == rhs.text &&
lhs.markdownText == rhs.markdownText &&
lhs.textType == rhs.textType &&
lhs.isRTL == rhs.isRTL
// 注意:linkHandler是函数类型,无法比较,但通常不影响渲染
// Environment变量由SwiftUI自动处理
lhs.textType == rhs.textType
}

public init(
Expand All @@ -46,10 +43,10 @@ public struct FlareText: View, Equatable {

public var body: some View {
let currentStyle: FlareTextStyle.Style = switch textType {
case .body:
theme.bodyTextStyle
case .caption:
theme.captionTextStyle
case .flareTextTypeBody:
theme.flareTextBodyTextStyle
case .flareTextTypeCaption:
theme.flareTextCaptionTextStyle
}

switch appSettings.appearanceSettings.renderEngine {
Expand Down
27 changes: 0 additions & 27 deletions iosApp/iosApp/UI/Page/Compose/Text/FlareTextStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,33 +37,6 @@ public enum FlareTextStyle {
lhs.cashtagColor == rhs.cashtagColor
}

// public static let `default` = Style(
// font: .systemFont(ofSize: 16),
// textColor: UIColor.black, // .Text.primary,
// linkColor: UIColor.black,
// mentionColor: UIColor.black,
// hashtagColor: UIColor.black,
// cashtagColor: UIColor.black
// )

// public static let timeline = Style(
// font: .systemFont(ofSize: 16),
// textColor: UIColor.black,
// linkColor: UIColor.black,
// mentionColor: UIColor.black,
// hashtagColor: UIColor.black,
// cashtagColor: UIColor.black
// )

// public static let quote = Style(
// font: .systemFont(ofSize: 15),
// textColor: UIColor.black,
// linkColor: UIColor.black.withAlphaComponent(0.8),
// mentionColor: UIColor.black.withAlphaComponent(0.8),
// hashtagColor: UIColor.black.withAlphaComponent(0.8),
// cashtagColor: UIColor.black.withAlphaComponent(0.8)
// )

public init(
font: UIFont = .systemFont(ofSize: 16),
textColor: UIColor = UIColor.black,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import SwiftUI

struct LinkPreviewV2: View {
let card: Card // 使用Swift Card类型
let card: Card
var body: some View {
Link(destination: URL(string: card.url)!) {
HStack {
if let media = card.media {
// 使用V2版本的MediaItemComponent
MediaItemComponentV2(media: media)
.frame(width: 64, height: 64)
}
VStack(alignment: .leading) {
Text(card.title ?? "") // 处理可选值
Text(card.title ?? "")
.lineLimit(1)
if let desc = card.description, !desc.isEmpty { // 确保description不为空
if let desc = card.description, !desc.isEmpty {
Text(desc)
.font(.caption)
.foregroundStyle(.gray)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// import Foundation
import SwiftUI

struct PodcastPreviewV2: View {
let card: Card // 使用Swift Card类型
let card: Card

private var podcastId: String {
URL(string: card.url)?.lastPathComponent ?? ""
Expand Down
Loading