mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-20 05:16:02 +00:00
UI Improvements
This commit is contained in:
1 parent
98da599302
commit
90e3e23905
31 files changed
+458
-277
No files matched your search
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="23504" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="23727" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="23504"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="23727"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
|
||||
@@ -147,13 +147,13 @@ class ShareViewController: NSViewController, ShareExtensionDelegate {
|
||||
|
||||
private func openQrCodeView() {
|
||||
if qrCodeSheetView == nil {
|
||||
let contentView = QrCodeView {
|
||||
let contentView = SmallSheetView(type: .sendToDeviceQrCode) {
|
||||
self.closeQrCodeView()
|
||||
}
|
||||
|
||||
let hostingView = NSHostingView(rootView: contentView)
|
||||
|
||||
let panel = NSPanel(contentRect: NSRect(x: 0, y: 0, width: qrCodeViewSize.width, height: qrCodeViewSize.height),
|
||||
let panel = NSPanel(contentRect: NSRect(x: 0, y: 0, width: smallSheetViewSize.width, height: smallSheetViewSize.height),
|
||||
styleMask: [.titled, .closable, .utilityWindow],
|
||||
backing: .buffered,
|
||||
defer: false)
|
||||
|
||||
@@ -7,11 +7,12 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
let qrCodeViewSize = CGSize(width: 530.0, height: 270.0)
|
||||
let smallSheetViewSize = CGSize(width: 530.0, height: 270.0)
|
||||
|
||||
struct QrCodeView: View {
|
||||
struct SmallSheetView: View {
|
||||
@State private var qrCode: String = ""
|
||||
var advertisesApp = false
|
||||
|
||||
let type: SheetViewType
|
||||
let closeView: () -> Void
|
||||
|
||||
@Environment(\.colorScheme) var colorScheme
|
||||
@@ -23,7 +24,22 @@ struct QrCodeView: View {
|
||||
|
||||
HStack {
|
||||
|
||||
if !advertisesApp {
|
||||
HStack(spacing: 5) {
|
||||
|
||||
let imageSize: CGFloat = type == .sendToDeviceQrCode ? 25 : 20
|
||||
|
||||
Image(.quickDropIcon)
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(width: imageSize, height: imageSize)
|
||||
|
||||
if type != .sendToDeviceQrCode {
|
||||
Text("QuickDrop")
|
||||
}
|
||||
}
|
||||
.padding(.leading, 18)
|
||||
|
||||
if type == .sendToDeviceQrCode {
|
||||
Spacer()
|
||||
|
||||
HStack {
|
||||
@@ -45,18 +61,7 @@ struct QrCodeView: View {
|
||||
connectWithApp.toggle()
|
||||
}
|
||||
}
|
||||
.animation(.smooth, value:connectWithApp)
|
||||
}
|
||||
else {
|
||||
HStack(spacing: 5) {
|
||||
Image(.quickDropIcon)
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(width: 20, height: 20)
|
||||
|
||||
Text("QuickDrop")
|
||||
}
|
||||
.padding(.leading, 18)
|
||||
.animation(.smooth, value: connectWithApp)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
@@ -73,26 +78,39 @@ struct QrCodeView: View {
|
||||
.padding(.trailing, 15)
|
||||
.padding(.leading, 10)
|
||||
.padding(.top, 15)
|
||||
.padding(.bottom, advertisesApp ? -10 : 0)
|
||||
.padding(.bottom, type == .sendToDeviceQrCode ? 0 : -10)
|
||||
|
||||
Spacer()
|
||||
|
||||
HStack {
|
||||
Spacer()
|
||||
|
||||
Image(connectWithApp ? .qrApp : .QR)
|
||||
getImage()
|
||||
.resizable()
|
||||
.aspectRatio(1, contentMode: .fit)
|
||||
.frame(height: 160)
|
||||
|
||||
Spacer()
|
||||
|
||||
|
||||
Text(getDescription().localized())
|
||||
.padding(.top, 5)
|
||||
.padding(.horizontal)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.multilineTextAlignment(.center)
|
||||
VStack {
|
||||
Text(getDescription().localized())
|
||||
.padding(.top, 5)
|
||||
.padding(.horizontal)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.multilineTextAlignment(.center)
|
||||
|
||||
if type == .downloadCableConnectionApp {
|
||||
Button {
|
||||
if let url = URL(string: "https://apps.apple.com/de/app/idroid-phone-file-manager/id6746444380") {
|
||||
NSWorkspace.shared.open(url)
|
||||
}
|
||||
} label: {
|
||||
Text("DownloadCableConnectionApp")
|
||||
}
|
||||
.keyboardShortcut(.defaultAction)
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
|
||||
Spacer()
|
||||
}
|
||||
@@ -102,19 +120,39 @@ struct QrCodeView: View {
|
||||
Spacer()
|
||||
|
||||
}
|
||||
.frame(width: qrCodeViewSize.width, height: qrCodeViewSize.height)
|
||||
.frame(width: smallSheetViewSize.width, height: smallSheetViewSize.height)
|
||||
}
|
||||
|
||||
func getDescription() -> String {
|
||||
|
||||
if advertisesApp {
|
||||
switch type {
|
||||
case .sendToDeviceQrCode:
|
||||
return connectWithApp ? "QrCodeInstructionsApp" : "QrCodeInstructions"
|
||||
case .downloadAndroidApp:
|
||||
return "QuickDropAndroidAppAdvertisement"
|
||||
case .downloadCableConnectionApp:
|
||||
return "DownloadCableConnectionAppDescription"
|
||||
}
|
||||
}
|
||||
|
||||
func getImage() -> Image {
|
||||
switch type {
|
||||
case .sendToDeviceQrCode:
|
||||
return connectWithApp ? Image(.qrApp) : Image(.QR)
|
||||
case .downloadAndroidApp:
|
||||
return Image(.qrApp)
|
||||
case .downloadCableConnectionApp:
|
||||
return Image(.iDroid)
|
||||
}
|
||||
|
||||
return connectWithApp ? "QrCodeInstructionsApp" : "QrCodeInstructions"
|
||||
}
|
||||
}
|
||||
|
||||
enum SheetViewType {
|
||||
case sendToDeviceQrCode
|
||||
case downloadAndroidApp
|
||||
case downloadCableConnectionApp
|
||||
}
|
||||
|
||||
#Preview {
|
||||
QrCodeView(closeView: {})
|
||||
SmallSheetView(type: .downloadCableConnectionApp, closeView: {})
|
||||
}
|
||||
Reference in new issue
Block a user