Skip to content

Commit

Permalink
[TabBar] Fix tab bar color issue in Xcode style.
Browse files Browse the repository at this point in the history
  • Loading branch information
lilingxi01 committed Apr 30, 2022
1 parent 55641a7 commit 5c7d8d1
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
6 changes: 5 additions & 1 deletion CodeEdit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
D7E201BD27EA00E200CB86D0 /* FindNavigatorResultFileItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7E201BC27EA00E200CB86D0 /* FindNavigatorResultFileItem.swift */; };
D7F72DEB27EA3574000C3064 /* Search in Frameworks */ = {isa = PBXBuildFile; productRef = D7F72DEA27EA3574000C3064 /* Search */; };
DE513F52281B672D002260B9 /* TabBarAccessory.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE513F51281B672D002260B9 /* TabBarAccessory.swift */; };
DE513F54281DE5D0002260B9 /* TabBarXcode.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE513F53281DE5D0002260B9 /* TabBarXcode.swift */; };
DE6405A62817734700881FDF /* TabBarNative.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE6405A52817734700881FDF /* TabBarNative.swift */; };
DE6F77872813625500D00A76 /* TabBarDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE6F77862813625500D00A76 /* TabBarDivider.swift */; };
FD6A3D3D2817C13B008BCF11 /* Package.resolved in Resources */ = {isa = PBXBuildFile; fileRef = FD6A3D3C2817C13B008BCF11 /* Package.resolved */; };
Expand Down Expand Up @@ -184,9 +185,10 @@
D7E201B327E9989900CB86D0 /* FindNavigatorResultList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FindNavigatorResultList.swift; sourceTree = "<group>"; };
D7E201BC27EA00E200CB86D0 /* FindNavigatorResultFileItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FindNavigatorResultFileItem.swift; sourceTree = "<group>"; };
DE513F51281B672D002260B9 /* TabBarAccessory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarAccessory.swift; sourceTree = "<group>"; };
DE513F53281DE5D0002260B9 /* TabBarXcode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarXcode.swift; sourceTree = "<group>"; };
DE6405A52817734700881FDF /* TabBarNative.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarNative.swift; sourceTree = "<group>"; };
DE6F77862813625500D00A76 /* TabBarDivider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarDivider.swift; sourceTree = "<group>"; };
FD6A3D3C2817C13B008BCF11 /* Package.resolved */ = {isa = PBXFileReference; lastKnownFileType = file; path = Package.resolved; sourceTree = SOURCE_ROOT; };
FD6A3D3C2817C13B008BCF11 /* Package.resolved */ = {isa = PBXFileReference; lastKnownFileType = text; path = Package.resolved; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -365,6 +367,7 @@
DE6F77862813625500D00A76 /* TabBarDivider.swift */,
DE6405A52817734700881FDF /* TabBarNative.swift */,
DE513F51281B672D002260B9 /* TabBarAccessory.swift */,
DE513F53281DE5D0002260B9 /* TabBarXcode.swift */,
);
path = TabBar;
sourceTree = "<group>";
Expand Down Expand Up @@ -724,6 +727,7 @@
2072FA13280D74ED00C7F8D4 /* HistoryInspectorModel.swift in Sources */,
DE513F52281B672D002260B9 /* TabBarAccessory.swift in Sources */,
2813F93927ECC4C300E305E4 /* NavigatorSidebar.swift in Sources */,
DE513F54281DE5D0002260B9 /* TabBarXcode.swift in Sources */,
20EBB50D280C383700F3A5DA /* LanguageType.swift in Sources */,
2813F93827ECC4AA00E305E4 /* FindNavigatorResultList.swift in Sources */,
0483E35027FDB17700354AC0 /* ExtensionNavigator.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion CodeEdit/TabBar/TabBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ struct TabBar: View {
}
.background {
if prefs.preferences.general.tabBarStyle == .xcode {
Color(nsColor: .controlBackgroundColor)
TabBarXcodeBackground()
}
}
.background {
Expand Down
2 changes: 1 addition & 1 deletion CodeEdit/TabBar/TabBarDivider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct TabBarBottomDivider: View {
.foregroundColor(
prefs.preferences.general.tabBarStyle == .xcode
? Color(nsColor: .separatorColor)
.opacity(colorScheme == .dark ? 0.40 : 0.45)
.opacity(colorScheme == .dark ? 0.80 : 0.50)
: Color(nsColor: .black)
.opacity(colorScheme == .dark ? 0.65 : 0.13)

Expand Down
2 changes: 1 addition & 1 deletion CodeEdit/TabBar/TabBarItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ struct TabBarItem: View {
.background(
// This layer of background is to hide dividers of other tab bar items
// because the original background above is translucent (by opacity).
Color(nsColor: .controlBackgroundColor)
TabBarXcodeBackground()
)
.animation(.easeInOut(duration: 0.08), value: isHovering)
} else {
Expand Down
24 changes: 24 additions & 0 deletions CodeEdit/TabBar/TabBarXcode.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// TabBarXcode.swift
// CodeEdit
//
// Created by Lingxi Li on 4/30/22.
//

import SwiftUI
import CodeEditUI

/// This is the Xcode style background material for tab bar and breadcrumbs.
struct TabBarXcodeBackground: View {
@Environment(\.colorScheme)
private var colorScheme

var body: some View {
EffectView(
colorScheme == .dark
? NSVisualEffectView.Material.windowBackground
: NSVisualEffectView.Material.contentBackground,
blendingMode: NSVisualEffectView.BlendingMode.withinWindow
)
}
}

0 comments on commit 5c7d8d1

Please sign in to comment.