-
Notifications
You must be signed in to change notification settings - Fork 426
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
56cc912
commit 4760be6
Showing
9 changed files
with
271 additions
and
29 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
...Go/SyncAssets.xcassets/Arrow-Circle-Right-12.imageset/Arrow-Circle-Right-12.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions
15
DuckDuckGo/SyncAssets.xcassets/Arrow-Circle-Right-12.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "Arrow-Circle-Right-12.svg", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"preserves-vector-representation" : true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
152 changes: 152 additions & 0 deletions
152
LocalPackages/SyncUI/Sources/SyncUI/Views/Internal/CameraView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
// | ||
// CameraView.swift | ||
// DuckDuckGo | ||
// | ||
// Copyright © 2023 DuckDuckGo. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import SwiftUI | ||
|
||
public struct CameraView: View { | ||
|
||
@ObservedObject var model: ScanOrPasteCodeViewModel | ||
|
||
public var body: some View { | ||
GeometryReader { g in | ||
ZStack(alignment: .top) { | ||
fullscreenCameraBackground() | ||
|
||
VStack(spacing: 0) { | ||
Rectangle() // Also acts as the blur for the camera | ||
.fill(.black) | ||
.frame(height: g.safeAreaInsets.top) | ||
|
||
ZStack { | ||
// Background in case fullscreen camera view doesn't work | ||
if !model.showCamera { | ||
Rectangle().fill(Color.black) | ||
} | ||
|
||
Group { | ||
cameraPermissionDenied() | ||
cameraUnavailable() | ||
} | ||
.padding(.horizontal, 0) | ||
|
||
VStack { | ||
Spacer() | ||
Text(UserText.cameraPointCameraIndication) | ||
.padding(.vertical, 8) | ||
.padding(.horizontal, 20) | ||
.background( | ||
RoundedRectangle(cornerRadius: 56) | ||
.fill(.clear) | ||
.background(BlurView(style: .light)) | ||
.cornerRadius(20) | ||
) | ||
.daxCaption() | ||
} | ||
.padding(.bottom, 20) | ||
} | ||
} | ||
.ignoresSafeArea() | ||
} | ||
} | ||
} | ||
|
||
@ViewBuilder | ||
func fullscreenCameraBackground() -> some View { | ||
Group { | ||
if model.showCamera { | ||
QRCodeScannerView { | ||
return await model.codeScanned($0) | ||
} onCameraUnavailable: { | ||
model.cameraUnavailable() | ||
} | ||
} else { | ||
Rectangle() | ||
.fill(.black) | ||
} | ||
} | ||
.ignoresSafeArea() | ||
} | ||
|
||
@ViewBuilder | ||
func cameraPermissionDenied() -> some View { | ||
if model.videoPermission == .denied { | ||
VStack(spacing: 0) { | ||
|
||
Image("SyncCameraPermission") | ||
.padding(.top, 40) | ||
.padding(.bottom, 20) | ||
|
||
Text(UserText.cameraPermissionRequired) | ||
.daxTitle3() | ||
.lineSpacing(1.05) | ||
.padding(.bottom, 8) | ||
|
||
Text(UserText.cameraPermissionInstructions) | ||
.lineLimit(nil) | ||
.multilineTextAlignment(.center) | ||
.daxBodyRegular() | ||
.lineSpacing(1.1) | ||
|
||
Spacer() | ||
|
||
Button { | ||
model.gotoSettings() | ||
} label: { | ||
HStack { | ||
Image("SyncGotoButton") | ||
Text(UserText.cameraGoToSettingsButton) | ||
} | ||
} | ||
.buttonStyle(SyncLabelButtonStyle()) | ||
.padding(.bottom, 40) | ||
} | ||
.padding(.horizontal, 40) | ||
} | ||
} | ||
|
||
@ViewBuilder | ||
func cameraUnavailable() -> some View { | ||
if model.videoPermission == .authorised && !model.showCamera { | ||
VStack(spacing: 0) { | ||
|
||
Image("SyncCameraUnavailable") | ||
.padding(.top, 40) | ||
.padding(.bottom, 20) | ||
|
||
Text(UserText.cameraIsUnavailableTitle) | ||
.daxTitle3() | ||
.lineSpacing(1.05) | ||
|
||
} | ||
.padding(.horizontal, 40) | ||
} | ||
} | ||
|
||
struct BlurView: UIViewRepresentable { | ||
var style: UIBlurEffect.Style | ||
|
||
func makeUIView(context: Context) -> UIVisualEffectView { | ||
return UIVisualEffectView(effect: UIBlurEffect(style: style)) | ||
} | ||
|
||
func updateUIView(_ uiView: UIVisualEffectView, context: Context) { | ||
uiView.effect = UIBlurEffect(style: style) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
LocalPackages/SyncUI/Sources/SyncUI/Views/ScanOrEnterCodeToRecoverSyncedData.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// | ||
// ScanOrEnterCodeToRecoverSyncedData.swift | ||
// DuckDuckGo | ||
// | ||
// Copyright © 2023 DuckDuckGo. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import SwiftUI | ||
import DuckUI | ||
|
||
public struct ScanOrEnterCodeToRecoverSyncedData: View { | ||
|
||
@ObservedObject var model: ScanOrPasteCodeViewModel | ||
|
||
public init(model: ScanOrPasteCodeViewModel) { | ||
self.model = model | ||
} | ||
|
||
public var body: some View { | ||
VStack(spacing: 10) { | ||
VStack(spacing: 10) { | ||
Text(UserText.scanCodeToRecoverSyncedDataExplanation) | ||
.daxFootnoteRegular() | ||
.multilineTextAlignment(.center) | ||
.padding(.horizontal, 20) | ||
.padding(.top, 10) | ||
.padding(.bottom, 20) | ||
CameraView(model: model) | ||
.aspectRatio(1.0, contentMode: .fill) | ||
} | ||
.navigationTitle(UserText.scanCodeToRecoverSyncedDataTitle) | ||
.toolbar { | ||
ToolbarItem(placement: .navigationBarLeading) { | ||
Button(UserText.cancelButton, action: model.cancel) | ||
.foregroundColor(Color.white) | ||
} | ||
} | ||
ZStack { | ||
Rectangle().fill(Color.black) | ||
VStack(alignment: .center) { | ||
HStack(spacing: 4) { | ||
Text(UserText.scanCodeToRecoverSyncedDataFooter) | ||
.daxBodyRegular() | ||
.foregroundColor(Color(designSystemColor: .textSecondary)) | ||
HStack(alignment: .center) { | ||
NavigationLink(UserText.scanCodeToRecoverSyncedDataEnterCodeLink, destination: { | ||
PasteCodeView(model: model) | ||
}) | ||
.foregroundColor(Color(designSystemColor: .accent)) | ||
Image("Arrow-Circle-Right-12") | ||
} | ||
} | ||
.padding(20) | ||
Spacer() | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters