Skip to content

Commit

Permalink
fix: lint & add fallback get select text
Browse files Browse the repository at this point in the history
  • Loading branch information
rhinoc committed Feb 12, 2024
1 parent 486e6c6 commit 22ae330
Show file tree
Hide file tree
Showing 43 changed files with 611 additions and 510 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ xcuserdata
version.txt
appcast_tmp.txt

# *.xcodeproj
# *.xcodeproj
.cosine
33 changes: 33 additions & 0 deletions liltr.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
objects = {

/* Begin PBXBuildFile section */
2B0437D22B79D5D800792E8B /* AppleScript.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B0437D12B79D5D800792E8B /* AppleScript.swift */; };
2B0437D42B79E2F000792E8B /* Pasteboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B0437D32B79E2F000792E8B /* Pasteboard.swift */; };
2B0437D62B79E34900792E8B /* SelectedText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B0437D52B79E34900792E8B /* SelectedText.swift */; };
2B59A3902B75B92F005DB8B1 /* liltrApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B59A38F2B75B92F005DB8B1 /* liltrApp.swift */; };
2B59A3972B75B930005DB8B1 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2B59A3962B75B930005DB8B1 /* Preview Assets.xcassets */; };
2B59A3A02B75B9C7005DB8B1 /* KeyboardShortcuts in Frameworks */ = {isa = PBXBuildFile; productRef = 2B59A39F2B75B9C7005DB8B1 /* KeyboardShortcuts */; };
Expand Down Expand Up @@ -56,6 +59,9 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
2B0437D12B79D5D800792E8B /* AppleScript.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppleScript.swift; sourceTree = "<group>"; };
2B0437D32B79E2F000792E8B /* Pasteboard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Pasteboard.swift; sourceTree = "<group>"; };
2B0437D52B79E34900792E8B /* SelectedText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectedText.swift; sourceTree = "<group>"; };
2B59A38C2B75B92F005DB8B1 /* liltr.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = liltr.app; sourceTree = BUILT_PRODUCTS_DIR; };
2B59A38F2B75B92F005DB8B1 /* liltrApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = liltrApp.swift; sourceTree = "<group>"; };
2B59A3962B75B930005DB8B1 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -239,8 +245,11 @@
2B7CF3062B75BCB400BFA0BA /* Common */ = {
isa = PBXGroup;
children = (
2B0437D12B79D5D800792E8B /* AppleScript.swift */,
2B7CF3072B75BCB400BFA0BA /* Common.swift */,
2B7CF3082B75BCB400BFA0BA /* Debouncer.swift */,
2B0437D32B79E2F000792E8B /* Pasteboard.swift */,
2B0437D52B79E34900792E8B /* SelectedText.swift */,
);
path = Common;
sourceTree = "<group>";
Expand Down Expand Up @@ -326,6 +335,7 @@
2B59A3882B75B92F005DB8B1 /* Sources */,
2B59A3892B75B92F005DB8B1 /* Frameworks */,
2B59A38A2B75B92F005DB8B1 /* Resources */,
2B0437D72B79F3CA00792E8B /* ShellScript */,
);
buildRules = (
);
Expand Down Expand Up @@ -391,6 +401,26 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
2B0437D72B79F3CA00792E8B /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\n";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
2B59A3882B75B92F005DB8B1 /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand All @@ -403,11 +433,13 @@
2B7CF3262B75BCB400BFA0BA /* Debouncer.swift in Sources */,
2B7CF32B2B75BCB400BFA0BA /* TextHandler.swift in Sources */,
2B59A3A22B75BA07005DB8B1 /* userDefaults.swift in Sources */,
2B0437D62B79E34900792E8B /* SelectedText.swift in Sources */,
2B7CF38E2B75C00400BFA0BA /* TranslateFieldView.swift in Sources */,
2B7CF31C2B75BCB400BFA0BA /* NiuTrans.swift in Sources */,
2B7CF31F2B75BCB400BFA0BA /* ProviderManager.swift in Sources */,
2B7CF31A2B75BCB400BFA0BA /* BigHugeThesaurus.swift in Sources */,
2B7CF3242B75BCB400BFA0BA /* extensions.swift in Sources */,
2B0437D42B79E2F000792E8B /* Pasteboard.swift in Sources */,
2B7CF3282B75BCB400BFA0BA /* views.swift in Sources */,
2B7CF3772B75BFE400BFA0BA /* ToolbarItem.swift in Sources */,
2B7CF31B2B75BCB400BFA0BA /* Baidu.swift in Sources */,
Expand All @@ -419,6 +451,7 @@
2B7CF3902B75C00400BFA0BA /* MidBarView.swift in Sources */,
2B7CF3202B75BCB400BFA0BA /* Volcengine.swift in Sources */,
2B7CF37B2B75BFE400BFA0BA /* LanguagePicker.swift in Sources */,
2B0437D22B79D5D800792E8B /* AppleScript.swift in Sources */,
2B7CF3832B75BFF000BFA0BA /* Hotkeys.swift in Sources */,
2B7CF3702B75BF2300BFA0BA /* TTTDictionary.m in Sources */,
2B7CF3162B75BCB400BFA0BA /* Encoder.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion liltr/Components/LanguagePicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import SwiftUI

struct LanguagePicker: View {
@Binding var languageCode: String

var withLabel: Bool

var body: some View {
Expand Down
17 changes: 8 additions & 9 deletions liltr/Components/TabItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ struct TabItem: View {
private let label: String
private let icon: String
private let active: Bool

private let itemWidth = 81
private let itemHeight = 50
private let sizeHolder: SizeHolder

@State private var hovering: Bool = false

init(label: String, icon: String, active: Bool, sizeBase: Float? = nil) {
self.label = label
self.icon = icon
self.active = active
self.sizeHolder = SizeHolder(base: sizeBase)
}

var body: some View {
VStack {
Image(systemName: icon)
Expand All @@ -37,22 +37,21 @@ struct TabItem: View {
self.hovering = hovering
})
}
private func getBackgroundColor()-> Color {

private func getBackgroundColor() -> Color {
let colorActive = Color.secondary.opacity(0.18)
let colorHover = Color.secondary.opacity(0.1)
let colorDefault = Color.clear
if (self.active) {
if self.active {
return colorActive
} else if (self.hovering) {
} else if self.hovering {
return colorHover
} else {
return colorDefault
}
}
}


#Preview {
HStack {
TabItem(label: "General", icon: "gear", active: false)
Expand Down
4 changes: 2 additions & 2 deletions liltr/Components/ToolbarItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import SwiftUI
struct ToolbarItem: View {
var systemName: String
var action: () -> Void

@State var hovering: Bool = false

var body: some View {
Button(action: action, label: {
Image(systemName: systemName)
Expand Down
12 changes: 6 additions & 6 deletions liltr/Components/TopTabView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class TabPane: Identifiable {
public let label: String
public let icon: String
public let view: AnyView

init(label: String, icon: String, view: AnyView) {
self.label = label
self.icon = icon
Expand All @@ -14,16 +14,16 @@ class TabPane: Identifiable {

public struct TopTabView: View {
private let tabPanes: [TabPane]

private let sizeHolder = SizeHolder()

@State private var activeTabLabel: String

init(tabPanes: [TabPane], defaultActiveTabLabel: String? = nil) {
self.tabPanes = tabPanes
self.activeTabLabel = defaultActiveTabLabel ?? tabPanes.first!.label
}

public var tabBar: some View {
HStack(spacing: CGFloat(sizeHolder.outerGapSize)) {
Spacer()
Expand All @@ -36,7 +36,7 @@ public struct TopTabView: View {
Spacer()
}
}

public var body: some View {
ZStack(alignment: .top) {
Color.clear
Expand Down
2 changes: 2 additions & 0 deletions liltr/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LSUIElement</key>
<true/>
<key>APP_NAME</key>
<string>liltr</string>
<key>AliAK</key>
Expand Down
25 changes: 13 additions & 12 deletions liltr/Settings/AboutView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@ struct AboutView: View {
@ObservedObject private var _checkForUpdatesViewModel: CheckForUpdatesViewModel
private let _gapSize: CGFloat = 8
private let _updater: SPUUpdater

init(updater: SPUUpdater) {
self._updater = updater
self._checkForUpdatesViewModel = CheckForUpdatesViewModel(updater: updater)
}

var body: some View {
VStack(alignment: .center) {
Spacer()
.frame(height: _gapSize * 2)

HStack(alignment: .center) {
Image(nsImage: NSImage(named: "AppIcon")!)
.resizable()
.frame(width: /*@START_MENU_TOKEN@*/100/*@END_MENU_TOKEN@*/, height: 100)

VStack(alignment: .leading, spacing: 2) {
Text("\(APP_NAME)")
.font(.system(size: 18))
.fontWeight(/*@START_MENU_TOKEN@*/.bold/*@END_MENU_TOKEN@*/)
.foregroundStyle(.primary)

VStack(alignment: .leading) {
Text("Version \(Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String)")
.foregroundStyle(.primary)
Expand All @@ -49,30 +49,31 @@ struct AboutView: View {
}
.frame(height: 80)
}

Divider()
.padding(EdgeInsets(top: _gapSize, leading: 0, bottom: _gapSize, trailing: 0))

HStack {
Button(action: /*@START_MENU_TOKEN@*/{}/*@END_MENU_TOKEN@*/, label: {
Text("Acknowledgements")
})

Spacer()

Button(action: /*@START_MENU_TOKEN@*/{}/*@END_MENU_TOKEN@*/, label: {
Text("Visit Website")
})

Button(action: {
try! _updater.start()
_updater.checkForUpdates();
_updater.checkForUpdates()
}, label: {
Text("Check Updates...")
})
}
.padding(EdgeInsets(top: 0, leading: _gapSize, bottom: 0, trailing: _gapSize))

.opacity(/*@START_MENU_TOKEN@*/0.8/*@END_MENU_TOKEN@*/)

}
.frame(width: 450, height: 140)
}
Expand Down
Loading

0 comments on commit 22ae330

Please sign in to comment.