Skip to content

feat: Add comprehensive dark mode support #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

graycreate
Copy link
Member

Summary

  • Implemented comprehensive dark mode support with adaptive color system
  • Added 15 new semantic color assets for light/dark mode compatibility
  • Updated key views and components to use adaptive colors

Changes

  • Created semantic color assets in Assets.xcassets for all UI elements
  • Enhanced Color.swift with new adaptive color definitions
  • Added appearance settings with system/light/dark mode options
  • Updated critical views to use adaptive colors:
    • Login page
    • User profile views
    • Tag detail page
    • Section items and tab bar
    • Toast notifications
    • Rich text webviews

Test plan

  • Test app in light mode
  • Test app in dark mode
  • Test automatic mode switching based on system preference
  • Verify all views display correctly in both modes
  • Check color contrast and readability

🤖 Generated with Claude Code

graycreate and others added 2 commits July 12, 2025 19:50
Updated UserDetailPage, TagDetailPage, and Webview to use adaptive colors:
- Replaced hardcoded .white with Color.primaryText/itemBackground
- Replaced .black with Color.primaryText
- Replaced .gray with Color.secondaryText
- Updated CSS colors in Webview for proper dark mode support
- Adjusted overlay opacity for better visibility in both themes

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Remove UIUserInterfaceStyle restriction from Info.plist to allow system theme
- Create adaptive color system with light/dark variants for all UI elements
- Add 15 new color sets with proper dark mode support
- Implement appearance settings with light/dark/system options
- Update main app to apply user's color scheme preference
- Add appearance toggle in settings page with Chinese localization
- Update key views to use adaptive colors instead of hardcoded values
- Fix navigation bar appearance to adapt to dark mode
- Add @retroactive attribute to fix UINavigationController extension warning
- Make color properties public to fix accessibility issues

This enables full dark mode support throughout the app, automatically
adapting to system preferences or user's manual selection.

🤖 Generated with Claude Code

Co-Authored-By: Claude <[email protected]>
@Copilot Copilot AI review requested due to automatic review settings July 12, 2025 12:34
Copy link

Code Coverage Report ❌

Current coverage: 0%

Copilot

This comment was marked as outdated.

- Replace primaryText overlay with dynamic(light: .black, dark: .white) to maintain proper darkening effect in light mode and lightening in dark mode
- Fixes build issues by moving SettingActions into SettingState temporarily
- Restores original overlay opacity values (0.3/0.1)
@github-actions github-actions bot added size/XL and removed size/XL labels Jul 12, 2025
@graycreate graycreate requested a review from Copilot July 12, 2025 12:50
Copy link

Code Coverage Report ❌

Current coverage: 0%

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements comprehensive dark mode support by introducing adaptive color assets, updating UI components to use semantic color references, and adding appearance settings to persist and apply the user’s theme preference.

  • Added 15 new semantic color asset sets and updated Color.swift with dynamic color utilities
  • Replaced hard-coded colors across views/widgets with adaptive Color references
  • Introduced Appearance settings UI, state, actions, and reducer to save/load the preferred theme

Reviewed Changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
website Updated submodule commit
V2er/View/Widget/Toast.swift Use Color.itemBackground and Color.primaryText for blur/shadow
V2er/View/Widget/TabBar.swift Replace static white with Color.itemBackground
V2er/View/Widget/SectionItemView.swift Update chevron tint and background to semantic colors
V2er/View/Widget/RichTextView/Webview.swift Update inline CSS colors to semantic hex values
V2er/View/ViewExtension.swift Added @retroactive attribute on UINavigationController
V2er/View/Tag/TagDetailPage.swift Apply Color.primaryText and dynamic overlay for banner blur
V2er/View/Settings/AppearanceSettingView.swift New theme selection UI using adaptive colors
V2er/View/Me/UserDetailPage.swift Updated navbar, badges, tabs to use semantic colors
V2er/View/Me/MePage.swift Replace login prompt and list item colors with adaptive references
V2er/View/Login/LoginPage.swift Update separators and button text/background to theme assets
V2er/State/DataFlow/State/SettingState.swift Define AppearanceMode, load/save from UserDefaults
V2er/State/DataFlow/Reducers/SettingReducer.swift Implement ChangeAppearanceAction handling in reducer
V2er/Info.plist Removed forced UIUserInterfaceStyle
V2er/General/V2erApp.swift Apply .preferredColorScheme and dynamic nav bar appearance
V2er/General/Color.swift Define new semantic/dynamic colors and legacy aliases
V2er/Assets.xcassets Added multiple color asset sets for light/dark mode
Comments suppressed due to low confidence (2)

V2er/State/DataFlow/Reducers/SettingReducer.swift:11

  • The new reducer logic for ChangeAppearanceAction lacks automated tests. Adding unit tests for this reducer will ensure future changes don’t break theme persistence behavior.
func settingStateReducer(_ state: SettingState, _ action: Action) -> (SettingState, Action?) {

V2er/View/ViewExtension.swift:104

  • The @retroactive attribute is not a valid Swift attribute for protocol conformance and will cause a compile error. Replace or remove it (e.g., use extension UINavigationController: UIGestureRecognizerDelegate).
extension UINavigationController: @retroactive UIGestureRecognizerDelegate {

}
}

// Temporary: Define actions here until SettingActions.swift is properly added to project
Copy link
Preview

Copilot AI Jul 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defining SettingActions in this file is noted as temporary. Consider moving the ChangeAppearanceAction and related action definitions into a dedicated SettingActions.swift for clearer boundaries and easier future maintenance.

Copilot uses AI. Check for mistakes.

var body: some View {
formView
.navBar("外观设置")
.onAppear {
selectedAppearance = store.appState.settingState.appearance
}
Copy link
Preview

Copilot AI Jul 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The local selectedAppearance state is only initialized on appear. If the store’s appearance changes externally, the UI won’t update. Consider adding .onChange(of: store.appState.settingState.appearance) to keep the selection in sync.

Suggested change
}
}
.onChange(of: store.appState.settingState.appearance) { newAppearance in
selectedAppearance = newAppearance
}

Copilot uses AI. Check for mistakes.

public static let bodyText = Color("BodyText")
public static let tintColor = Color("TintColor")
public static let bgColor = Color("BackgroundColor")
public static let itemBg = Color("ItemBackground")
Copy link
Preview

Copilot AI Jul 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The legacy alias itemBg duplicates itemBackground. After migrating all usages, consider removing redundant aliases to avoid confusion.

Suggested change
public static let itemBg = Color("ItemBackground")

Copilot uses AI. Check for mistakes.

The @retroactive attribute is only available in Swift 6, but the CI uses an older version of Swift. Removing this attribute to fix the build failure.
@github-actions github-actions bot added size/XL and removed size/XL labels Jul 12, 2025
Copy link

Code Coverage Report ❌

Current coverage: 25.06%

- Change NodeView text from hardcoded black to primaryText color
- Add secondaryText color to comment count labels for better visibility
- Add Appearance Settings option to Settings page menu
@github-actions github-actions bot added size/XL and removed size/XL labels Jul 12, 2025
Copy link

Code Coverage Report ❌

Current coverage: 25.06%

- Use dynamic colors for NodeView text (#666666 light, #CCCCCC dark)
- Ensure proper contrast between text and background in both modes
@github-actions github-actions bot added size/XL and removed size/XL labels Jul 12, 2025
Copy link

Code Coverage Report ❌

Current coverage: 18.57%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant