Skip to content

Commit

Permalink
perf(UI): add Confetti effets to about views (#535)
Browse files Browse the repository at this point in the history
* perf: set up env for vortex

* perf(UI): implement easter egg

* fix: package error

* fix: about view layout

* fix: resolve warning

* perf(UI): adjust logo position

* perf(UI): dynamic calculation for confetti location

* perf(UI): location of tap gesture

* fix: Image logo annotation

* perf: unify xcstring in about view

* perf: disable user to reize setting window

* perf: wait for frame animation to finish to remove resizable styleMask

* perf(UI): adjust AdvancedTab frame height

---------

Co-authored-by: Tisfeng <[email protected]>
  • Loading branch information
Jerry23011 and tisfeng committed May 14, 2024
1 parent 1c25ff3 commit 17f346d
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 82 deletions.
33 changes: 25 additions & 8 deletions Easydict.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@
A0B65CA0F31AC8ECFB8347CC /* Pods_EasydictTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 378E73A7EA8FC8FB9C975A63 /* Pods_EasydictTests.framework */; };
B87AC7E36367075BA5D13234 /* Pods_Easydict.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6372B33DFF803C7096A82250 /* Pods_Easydict.framework */; };
C415C0AD2B450D4800A9D231 /* GeminiService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C415C0AC2B450D4800A9D231 /* GeminiService.swift */; };
C4BFDD7A2BE61F550094026B /* Vortex in Frameworks */ = {isa = PBXBuildFile; productRef = C4BFDD792BE61F550094026B /* Vortex */; };
C490BF722BE910B70021E40A /* AdvancedTabItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C490BF712BE910B70021E40A /* AdvancedTabItemView.swift */; };
C4DD01E92B12B3C80025EE8E /* TencentService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4DD01E82B12B3C80025EE8E /* TencentService.swift */; };
C4DD01EB2B12BA250025EE8E /* TencentResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4DD01EA2B12BA250025EE8E /* TencentResponse.swift */; };
Expand Down Expand Up @@ -897,6 +898,7 @@
files = (
0AC8A84F2B6DFDD4006DA5CC /* SettingsAccess in Frameworks */,
03022F192B3591AE00B63209 /* GoogleGenerativeAI in Frameworks */,
C4BFDD7A2BE61F550094026B /* Vortex in Frameworks */,
2721E4D02AFE920700A059AC /* Alamofire in Frameworks */,
03022F1F2B36CF3100B63209 /* SwiftShell in Frameworks */,
038030952B4106800009230C /* CocoaLumberjack in Frameworks */,
Expand Down Expand Up @@ -2650,6 +2652,7 @@
03022F182B3591AE00B63209 /* GoogleGenerativeAI */,
0AC8A84E2B6DFDD4006DA5CC /* SettingsAccess */,
03779F192BB25797008D3C42 /* OpenAI */,
C4BFDD792BE61F550094026B /* Vortex */,
);
productName = Bob;
productReference = C99EEB182385796700FEE666 /* Easydict-debug.app */;
Expand Down Expand Up @@ -2713,6 +2716,7 @@
03022F172B3591AE00B63209 /* XCRemoteSwiftPackageReference "generative-ai-swift" */,
0AC8A84D2B6DFDD4006DA5CC /* XCRemoteSwiftPackageReference "SettingsAccess" */,
03779F182BB25797008D3C42 /* XCRemoteSwiftPackageReference "OpenAI" */,
C4BFDD782BE61F550094026B /* XCRemoteSwiftPackageReference "Vortex" */,
);
productRefGroup = C99EEB192385796700FEE666 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -3317,7 +3321,7 @@
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_PREFIX_HEADER = "$(SRCROOT)/Easydict/App/PrefixHeader.pch";
GENERATE_INFOPLIST_FILE = YES;
MACOSX_DEPLOYMENT_TARGET = 11.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.izual.EasydictTests;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -3342,7 +3346,7 @@
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_PREFIX_HEADER = "$(SRCROOT)/Easydict/App/PrefixHeader.pch";
GENERATE_INFOPLIST_FILE = YES;
MACOSX_DEPLOYMENT_TARGET = 11.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.izual.EasydictTests;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -3370,7 +3374,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 2.7.2;
PRODUCT_BUNDLE_IDENTIFIER = "com.izual.EasydictHelper-debug";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -3396,7 +3400,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 2.7.2;
PRODUCT_BUNDLE_IDENTIFIER = com.izual.EasydictHelper;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -3461,7 +3465,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MACOSX_DEPLOYMENT_TARGET = 11.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -3521,7 +3525,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MACOSX_DEPLOYMENT_TARGET = 11.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
Expand Down Expand Up @@ -3557,7 +3561,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 2.7.2;
PRODUCT_BUNDLE_IDENTIFIER = "com.izual.Easydict-debug";
PRODUCT_MODULE_NAME = Easydict;
Expand Down Expand Up @@ -3597,7 +3601,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 2.7.2;
PRODUCT_BUNDLE_IDENTIFIER = com.izual.Easydict;
PRODUCT_MODULE_NAME = Easydict;
Expand Down Expand Up @@ -3788,6 +3792,14 @@
minimumVersion = 4.2.0;
};
};
C4BFDD782BE61F550094026B /* XCRemoteSwiftPackageReference "Vortex" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/twostraws/Vortex";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.0.1;
};
};
EA3B81FA2B52555C004C0E8B /* XCRemoteSwiftPackageReference "Defaults" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/sindresorhus/Defaults.git";
Expand Down Expand Up @@ -3894,6 +3906,11 @@
package = 967712E82B5B913600105E0F /* XCRemoteSwiftPackageReference "KeyHolder" */;
productName = KeyHolder;
};
C4BFDD792BE61F550094026B /* Vortex */ = {
isa = XCSwiftPackageProductDependency;
package = C4BFDD782BE61F550094026B /* XCRemoteSwiftPackageReference "Vortex" */;
productName = Vortex;
};
EA3B81FB2B52555C004C0E8B /* Defaults */ = {
isa = XCSwiftPackageProductDependency;
package = EA3B81FA2B52555C004C0E8B /* XCRemoteSwiftPackageReference "Defaults" */;
Expand Down
11 changes: 10 additions & 1 deletion Easydict.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "a995ca1e217de6a305cfafa6275749b61cb5fb17e18c35671935a1737e5aa34b",
"originHash" : "3fbe4aaa777ce32c89a8c0750e2e78cb417a4bf7e5ece00eb7338b15ca5d7f65",
"pins" : [
{
"identity" : "abseil-cpp-binary",
Expand Down Expand Up @@ -298,6 +298,15 @@
"version" : "5.1.0"
}
},
{
"identity" : "vortex",
"kind" : "remoteSourceControl",
"location" : "https://github.com/twostraws/Vortex",
"state" : {
"revision" : "bb48b128d3c13c68c68e83833c622eec9f6c701f",
"version" : "1.0.1"
}
},
{
"identity" : "ziparchive",
"kind" : "remoteSourceControl",
Expand Down
64 changes: 32 additions & 32 deletions Easydict/App/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -829,22 +829,6 @@
}
}
},
"contributor_link" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Contributors"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "贡献者"
}
}
}
},
"copy_text" : {
"localizations" : {
"en" : {
Expand Down Expand Up @@ -1452,22 +1436,6 @@
}
}
},
"github_link" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "GitHub"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "GitHub"
}
}
}
},
"GitHub:" : {
"localizations" : {
"zh-Hans" : {
Expand Down Expand Up @@ -3283,6 +3251,38 @@
}
}
},
"setting.about.contributor_link" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Contributors"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "贡献者"
}
}
}
},
"setting.about.github_link" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "GitHub"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "GitHub"
}
}
}
},
"setting.disabled.import_app_error.message" : {
"extractionState" : "manual",
"localizations" : {
Expand Down
7 changes: 6 additions & 1 deletion Easydict/Swift/View/SettingView/SettingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct SettingView: View {
case .disabled:
500
case .advanced:
400
280
case .privacy:
320
case .about:
Expand All @@ -94,6 +94,11 @@ struct SettingView: View {
let newRect = NSRect(origin: CGPoint(x: originalFrame.origin.x, y: newY), size: newSize)

window.setFrame(newRect, display: true, animate: true)

// Disable user to resize window, wait for the animation to finish.
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
window.styleMask.remove(.resizable)
}
}

// MARK: Private
Expand Down
110 changes: 71 additions & 39 deletions Easydict/Swift/View/SettingView/Tabs/TabView/AboutTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import SwiftUI
import Vortex

// MARK: - SettingsAboutTab

Expand All @@ -27,50 +28,81 @@ struct AboutTab: View {
// MARK: Internal

var body: some View {
HStack(alignment: .center, spacing: 30) {
Image(.logo)
.resizable()
.frame(width: 100, height: 100)
.padding()
.shadow(color: .gray, radius: 1, x: 0, y: 0.8)

VStack(alignment: .leading) {
VStack(alignment: .leading) {
Text(appName)
.font(.system(size: 35, weight: .medium))
.padding(.top, 25)
.padding(.bottom, 3)

Text("current_version \(version)")
.font(.system(size: 13))
.foregroundColor(.gray)

Text(copyrightInfo)
.font(.system(size: 11))
.foregroundColor(.gray)
.padding(.top, 25)
.padding(.bottom, 20)
}

HStack(spacing: 15) {
Button {
NSWorkspace.shared.open(URL(string: "https://github.com/tisfeng/Easydict")!)
} label: {
Label("github_link", systemImage: "star.fill")
.frame(width: 120, height: 20)
VortexViewReader { proxy in
GeometryReader { geometry in
ZStack {
VortexView(.confetti) {
Rectangle()
.fill(.white)
.frame(width: 16, height: 16)
.tag("square")

Circle()
.fill(.white)
.frame(width: 16)
.tag("circle")
}

Button {
NSWorkspace.shared
.open(URL(string: "https://github.com/tisfeng/Easydict/graphs/contributors")!)
} label: {
Label("contributor_link", systemImage: "person.3.sequence.fill")
.frame(width: 120, height: 20)
.frame(height: 220)

HStack(alignment: .center, spacing: 30) {
Image(.logo)
.resizable()
.renderingMode(.original)
.frame(width: 100, height: 100)
.shadow(color: .gray, radius: 1, x: 0, y: 0.8)
.padding(.bottom, 2)
.padding(.leading, 16)
.padding(.trailing, 16)
.onTapGesture { location in
proxy.move(
to:
CGPoint(
x: location.x + ((geometry.size.width / 2) - 222),
y: location.y + 60
)
)
proxy.burst()
}
VStack(alignment: .leading) {
VStack(alignment: .leading) {
Text(appName)
.font(.system(size: 35, weight: .medium))
.padding(.bottom, 3)

Text("current_version \(version)")
.font(.system(size: 13))
.foregroundColor(.gray)
.padding(.bottom, 29)

Text(copyrightInfo)
.font(.system(size: 11))
.foregroundColor(.gray)
.padding(.bottom, 20)
}

HStack(spacing: 15) {
Button {
NSWorkspace.shared.open(URL(string: "https://github.com/tisfeng/Easydict")!)
} label: {
Label("setting.about.github_link", systemImage: "star.fill")
.frame(width: 120, height: 20)
}

Button {
NSWorkspace.shared
.open(URL(string: "https://github.com/tisfeng/Easydict/graphs/contributors")!)
} label: {
Label("setting.about.contributor_link", systemImage: "person.3.sequence.fill")
.frame(width: 120, height: 20)
}
}
.padding(.bottom, 10)
}
}
.frame(maxWidth: .infinity)
}
}
}
.frame(maxWidth: .infinity)
}

// MARK: Private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ + (NSString *)getDeviceModel {

/// Get device UUID, 4F07896A-1580-5270-A0E8-D7FA9DFA6868
+ (NSString *)getDeviceUUID {
io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice"));
io_service_t platformExpert = IOServiceGetMatchingService(kIOMainPortDefault, IOServiceMatching("IOPlatformExpertDevice"));
CFStringRef uuidString = (CFStringRef)IORegistryEntryCreateCFProperty(platformExpert, CFSTR("IOPlatformUUID"), kCFAllocatorDefault, 0);
NSString *uuid = (__bridge NSString *)(uuidString);
IOObjectRelease(platformExpert);
Expand Down

0 comments on commit 17f346d

Please sign in to comment.