mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-20 13:26:03 +00:00
Postpone permission prompt after introduction
This commit is contained in:
1 parent
22e86bc4f5
commit
cecffa1aaa
2 files changed
+100
-95
No files matched your search
@@ -10,7 +10,7 @@ import LUI
|
|||||||
|
|
||||||
struct ContentView: View {
|
struct ContentView: View {
|
||||||
|
|
||||||
@Environment(\.scenePhase) var scenePhase
|
@ObservedObject var luiSettings = LUISettings.sharedInstance
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
AppRootView(isPlus: .constant(true), phoneView: {
|
AppRootView(isPlus: .constant(true), phoneView: {
|
||||||
@@ -25,21 +25,6 @@ struct ContentView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.onChange(of: scenePhase) { newValue in
|
|
||||||
if newValue == .active {
|
|
||||||
#if !EXTENSION
|
|
||||||
NearbyConnectionManager.shared.becomeVisible()
|
|
||||||
#endif
|
|
||||||
NearbyConnectionManager.shared.startDeviceDiscovery()
|
|
||||||
}
|
|
||||||
|
|
||||||
if newValue == .background {
|
|
||||||
#if !EXTENSION
|
|
||||||
NearbyConnectionManager.shared.becomeInvisible()
|
|
||||||
#endif
|
|
||||||
NearbyConnectionManager.shared.stopDeviceDiscovery()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,107 +36,127 @@ struct DeviceListView: View {
|
|||||||
@StateObject var receiveModel = ReceiveModel()
|
@StateObject var receiveModel = ReceiveModel()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@Environment(\.scenePhase) var scenePhase
|
||||||
@ObservedObject var nearbyConnectionManager = NearbyConnectionManager.shared
|
@ObservedObject var nearbyConnectionManager = NearbyConnectionManager.shared
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
|
||||||
NavigationSubView(header: "QuickDrop ", navigationBarLayout: isShareExtension() ? .SmallOnlyAlways : .Default) {
|
NavigationSubView(header: "QuickDrop ", navigationBarLayout: isShareExtension() ? .SmallOnlyAlways : .Default) {
|
||||||
|
VStack {
|
||||||
|
|
||||||
VStack(alignment: .leading, spacing: 8) {
|
|
||||||
|
|
||||||
let attachments = nearbyConnectionManager.attachments
|
VStack(alignment: .leading, spacing: 8) {
|
||||||
|
|
||||||
FooterView(text: attachments == nil ? "YouAreVisibleAs".localized() : "YouAreSending".localized())
|
|
||||||
|
|
||||||
HStack {
|
|
||||||
|
|
||||||
if let image = attachments?.previewImage {
|
let attachments = nearbyConnectionManager.attachments
|
||||||
image
|
|
||||||
.resizable()
|
FooterView(text: attachments == nil ? "YouAreVisibleAs".localized() : "YouAreSending".localized())
|
||||||
.scaledToFill()
|
|
||||||
.frame(width: 10, height: 10)
|
|
||||||
}
|
|
||||||
|
|
||||||
LUIText(attachments?.shortDescription ?? NearbyConnectionManager.shared.deviceInfo.name ?? "Unknown".localized(), isBold: true)
|
|
||||||
.lineLimit(1)
|
|
||||||
}
|
|
||||||
.padding(.horizontal, 16)
|
|
||||||
.padding(.vertical, 6)
|
|
||||||
.background(Color.defaultForegroundColor)
|
|
||||||
.cornerRadius(24)
|
|
||||||
.padding(.horizontal)
|
|
||||||
}
|
|
||||||
.padding(.top, 8)
|
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
|
||||||
|
|
||||||
if !nearbyConnectionManager.hasLocalNetworkAccess {
|
|
||||||
CardView(backgroundColor: .red, title: "NoNetworkAccess", titleSymbol: "network.slash") {
|
|
||||||
HStack {
|
HStack {
|
||||||
|
|
||||||
|
if let image = attachments?.previewImage {
|
||||||
|
image
|
||||||
|
.resizable()
|
||||||
|
.scaledToFill()
|
||||||
|
.frame(width: 10, height: 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
LUIText(attachments?.shortDescription ?? NearbyConnectionManager.shared.deviceInfo.name ?? "Unknown".localized(), isBold: true)
|
||||||
|
.lineLimit(1)
|
||||||
|
}
|
||||||
|
.padding(.horizontal, 16)
|
||||||
|
.padding(.vertical, 6)
|
||||||
|
.background(Color.defaultForegroundColor)
|
||||||
|
.cornerRadius(24)
|
||||||
|
.padding(.horizontal)
|
||||||
|
}
|
||||||
|
.padding(.top, 8)
|
||||||
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
|
||||||
|
if !nearbyConnectionManager.hasLocalNetworkAccess {
|
||||||
|
CardView(backgroundColor: .red, title: "NoNetworkAccess", titleSymbol: "network.slash") {
|
||||||
CardSubView(symbol: "exclamationmark.triangle.fill", text: "NoLocalNetworkAccessDescription")
|
CardSubView(symbol: "exclamationmark.triangle.fill", text: "NoLocalNetworkAccessDescription")
|
||||||
|
}
|
||||||
|
.padding(.bottom, 10)
|
||||||
|
.onTapGesture {
|
||||||
|
openAppSettings()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding(.bottom, 10)
|
|
||||||
.onTapGesture {
|
|
||||||
openAppSettings()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if sendModel.foundDevices.isEmpty {
|
|
||||||
|
|
||||||
CustomSection(header: "NoDevicesFound") {
|
if sendModel.foundDevices.isEmpty {
|
||||||
|
|
||||||
HStack(spacing: 12) {
|
CustomSection(header: "NoDevicesFound") {
|
||||||
Image(systemName: "square.and.arrow.down")
|
|
||||||
.font(.system(size: 30))
|
|
||||||
.foregroundColor(.gray)
|
|
||||||
.padding(.leading, -10)
|
|
||||||
|
|
||||||
Text("DownloadQuickDropOnPlayStore")
|
HStack(spacing: 12) {
|
||||||
|
Image(systemName: "square.and.arrow.down")
|
||||||
|
.font(.system(size: 30))
|
||||||
|
.foregroundColor(.gray)
|
||||||
|
.padding(.leading, -10)
|
||||||
|
|
||||||
|
Text("DownloadQuickDropOnPlayStore")
|
||||||
|
}
|
||||||
|
.padding(.vertical)
|
||||||
}
|
}
|
||||||
.padding(.vertical)
|
|
||||||
}
|
} else {
|
||||||
|
|
||||||
} else {
|
CustomSection(header: "AvailableDevices") {
|
||||||
|
ForEach(sendModel.foundDevices) { device in
|
||||||
CustomSection(header: "AvailableDevices") {
|
|
||||||
ForEach(sendModel.foundDevices) { device in
|
let isSelected = sendModel.selectedDevice == device
|
||||||
|
|
||||||
let isSelected = sendModel.selectedDevice == device
|
ZStack {
|
||||||
|
if let attachments = NearbyConnectionManager.shared.attachments {
|
||||||
ZStack {
|
LUIButton {
|
||||||
if let attachments = NearbyConnectionManager.shared.attachments {
|
lightVibration()
|
||||||
LUIButton {
|
sendModel.urls = attachments.urls
|
||||||
lightVibration()
|
sendModel.textToSend = attachments.textToSend
|
||||||
sendModel.urls = attachments.urls
|
sendModel.selectDevice(device: device)
|
||||||
sendModel.textToSend = attachments.textToSend
|
} label: {
|
||||||
sendModel.selectDevice(device: device)
|
DeviceButtonLabel(device: device, isSelected: isSelected, progress: sendModel.progressState, progressValue: sendModel.progressValue)
|
||||||
} label: {
|
}
|
||||||
DeviceButtonLabel(device: device, isSelected: isSelected, progress: sendModel.progressState, progressValue: sendModel.progressValue)
|
}
|
||||||
|
else {
|
||||||
|
DeviceFilePickerButton(device: device, isSelected: isSelected, progressState: sendModel.progressState, progressValue: sendModel.progressValue, sendModel: sendModel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
.animation(.easeInOut, value: sendModel.progressValue)
|
||||||
DeviceFilePickerButton(device: device, isSelected: isSelected, progressState: sendModel.progressState, progressValue: sendModel.progressValue, sendModel: sendModel)
|
.animation(.easeInOut, value: isSelected)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.animation(.easeInOut, value: sendModel.progressValue)
|
|
||||||
.animation(.easeInOut, value: isSelected)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if nearbyConnectionManager.hasLocalNetworkAccess {
|
||||||
|
HStack(spacing: 8) {
|
||||||
|
Text("SearchingForDevices")
|
||||||
|
.font(.system(size: 14))
|
||||||
|
.foregroundColor(Color.primary.opacity(0.6))
|
||||||
|
|
||||||
|
ProgressView()
|
||||||
|
.frame(width: 12, height: 12)
|
||||||
|
}
|
||||||
|
.padding(.vertical, 16)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.frame(maxWidth: 700)
|
||||||
|
}
|
||||||
|
.onChange(of: scenePhase) { newValue in
|
||||||
|
|
||||||
|
if newValue == .active {
|
||||||
|
|
||||||
|
log("App became active")
|
||||||
|
#if !EXTENSION
|
||||||
|
NearbyConnectionManager.shared.becomeVisible()
|
||||||
|
#endif
|
||||||
|
NearbyConnectionManager.shared.startDeviceDiscovery()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if newValue == .background {
|
||||||
if nearbyConnectionManager.hasLocalNetworkAccess {
|
|
||||||
HStack(spacing: 8) {
|
log("App went to background")
|
||||||
Text("SearchingForDevices")
|
#if !EXTENSION
|
||||||
.font(.system(size: 14))
|
NearbyConnectionManager.shared.becomeInvisible()
|
||||||
.foregroundColor(Color.primary.opacity(0.6))
|
#endif
|
||||||
|
NearbyConnectionManager.shared.stopDeviceDiscovery()
|
||||||
ProgressView()
|
|
||||||
.frame(width: 12, height: 12)
|
|
||||||
}
|
|
||||||
.padding(.vertical, 16)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.animation(.smooth, value: nearbyConnectionManager.hasLocalNetworkAccess)
|
.animation(.smooth, value: nearbyConnectionManager.hasLocalNetworkAccess)
|
||||||
|
|||||||
@@ -7,4 +7,4 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
NSLocalNetworkUsageDescription = "Der Zugriff auf das lokale Netzwerk ist erforderlich, um Geräte zu erkennen und Dateien über Ihr Wi-Fi-Netzwerk zu übertragen.";
|
NSLocalNetworkUsageDescription = "Der Zugriff auf das lokale Netzwerk ist erforderlich, um Geräte zu erkennen und Dateien über WLAN zu übertragen.";
|
||||||
Reference in new issue
Block a user