Some fixes for macOS
This commit is contained in:
@@ -20,7 +20,6 @@ class ReliefButton: UIButton
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
init() {
|
||||
super.init(frame: .zero)
|
||||
|
||||
@@ -105,8 +104,14 @@ class ReliefButton: UIButton
|
||||
}
|
||||
|
||||
override func imageRect(forContentRect contentRect: CGRect) -> CGRect {
|
||||
let inset = CGFloat(7.0)
|
||||
return contentRect.insetBy(dx: inset, dy: inset)
|
||||
let ratio = CGFloat(0.45)
|
||||
return CGRect(
|
||||
origin: .zero,
|
||||
size: CGSize(
|
||||
width: ratio * contentRect.width,
|
||||
height: ratio * contentRect.width
|
||||
)
|
||||
).centered(inRect: contentRect)
|
||||
}
|
||||
|
||||
override func sizeThatFits(_ size: CGSize) -> CGSize {
|
||||
|
||||
@@ -18,18 +18,16 @@ class ScriptPolicyControl: UIControl
|
||||
didSet { setNeedsLayout() }
|
||||
}
|
||||
|
||||
private class PolicyButton: UIButton {
|
||||
override func imageRect(forContentRect contentRect: CGRect) -> CGRect {
|
||||
contentRect.insetBy(dx: 8.0, dy: 8.0)
|
||||
}
|
||||
}
|
||||
|
||||
private let allowButton = PolicyButton(frame: .zero)
|
||||
private let denyButton = PolicyButton(frame: .zero)
|
||||
private let allowButton = ReliefButton()
|
||||
private let denyButton = ReliefButton()
|
||||
private let segmentContainer = SegmentedReliefButton(children: [])
|
||||
|
||||
convenience init() {
|
||||
self.init(frame: .zero)
|
||||
|
||||
segmentContainer.children = [ allowButton, denyButton ]
|
||||
addSubview(segmentContainer)
|
||||
|
||||
allowButton.addAction(UIAction(handler: { [unowned self] _ in
|
||||
self.policyStatus = .allowed
|
||||
self.sendActions(for: .valueChanged)
|
||||
@@ -52,8 +50,7 @@ class ScriptPolicyControl: UIControl
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
|
||||
allowButton.frame = CGRect(origin: .zero, size: CGSize(width: bounds.width / 2, height: bounds.height))
|
||||
denyButton.frame = CGRect(origin: CGPoint(x: allowButton.frame.maxX, y: 0), size: allowButton.frame.size)
|
||||
segmentContainer.frame = bounds
|
||||
|
||||
if policyStatus == .allowed {
|
||||
allowButton.tintColor = .blue
|
||||
|
||||
@@ -34,7 +34,13 @@ class ScriptPolicyControlListCell: UICollectionViewListCell
|
||||
|
||||
override func layoutSubviews() {
|
||||
let policyControlWidth = CGFloat(80.0)
|
||||
policyControl.frame = CGRect(x: bounds.maxX - policyControlWidth - layoutMargins.right, y: 0, width: policyControlWidth, height: bounds.height)
|
||||
policyControl.frame = CGRect(
|
||||
x: bounds.maxX - policyControlWidth - layoutMargins.right,
|
||||
y: 0,
|
||||
width: policyControlWidth,
|
||||
height: bounds.height * 0.75
|
||||
)
|
||||
policyControl.frame = policyControl.frame.centeredY(inRect: bounds)
|
||||
bringSubviewToFront(policyControl)
|
||||
|
||||
super.layoutSubviews()
|
||||
@@ -68,7 +74,8 @@ class SwitchListCell: UICollectionViewListCell
|
||||
super.layoutSubviews()
|
||||
|
||||
let switchWidth: CGFloat = switchView.sizeThatFits(bounds.size).width
|
||||
switchView.frame = CGRect(x: bounds.maxX - switchWidth - layoutMargins.right, y: 0, width: switchWidth, height: bounds.height)
|
||||
switchView.frame = CGRect(x: bounds.maxX - switchWidth - layoutMargins.right, y: 0,
|
||||
width: switchWidth, height: bounds.height * 0.85)
|
||||
switchView.frame = switchView.frame.centeredY(inRect: bounds)
|
||||
contentView.frame = CGRect(origin: contentView.frame.origin, size: CGSize(width: switchView.frame.minX, height: contentView.frame.height))
|
||||
}
|
||||
@@ -88,6 +95,19 @@ class ScriptPolicyViewController: UIViewController, UICollectionViewDelegate
|
||||
case origins
|
||||
}
|
||||
|
||||
override var traitCollection: UITraitCollection {
|
||||
get {
|
||||
let actualTraits = super.traitCollection
|
||||
if actualTraits.userInterfaceIdiom == .mac {
|
||||
// Override traits to be iPad like on mac. We dont want small list cells here.
|
||||
let desiredTraits = UITraitCollection(userInterfaceIdiom: .pad)
|
||||
return UITraitCollection(traitsFrom: [ actualTraits, desiredTraits ])
|
||||
}
|
||||
|
||||
return actualTraits
|
||||
}
|
||||
}
|
||||
|
||||
private static let enableScriptsForTabItem: String = "enableScriptsForTab"
|
||||
|
||||
convenience init(policyManager: ResourcePolicyManager, hostOrigin: String, loadedScripts: Set<String>, scriptsAllowedForTab: Bool) {
|
||||
@@ -98,13 +118,11 @@ class ScriptPolicyViewController: UIViewController, UICollectionViewDelegate
|
||||
let listLayout = UICollectionViewCompositionalLayout.list(using: listConfig)
|
||||
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: listLayout)
|
||||
|
||||
// Allowed scripts go to the top
|
||||
let allowedScripts = loadedScripts.filter { policyManager.allowedOriginsForScriptResources().contains($0) }
|
||||
|
||||
// Make sure host origin goes first in the list.
|
||||
let otherOriginScripts = loadedScripts.subtracting([ hostOrigin ]).subtracting(allowedScripts)
|
||||
let otherOriginScripts = loadedScripts.subtracting([ hostOrigin ])
|
||||
let allowedScripts = otherOriginScripts.filter { policyManager.allowedOriginsForScriptResources().contains($0) }
|
||||
|
||||
let originItems = [ hostOrigin ] + allowedScripts + otherOriginScripts
|
||||
let originItems = [ hostOrigin ] + allowedScripts + otherOriginScripts.subtracting(allowedScripts)
|
||||
|
||||
let switchCellRegistry = UICollectionView.CellRegistration<SwitchListCell, String> { [unowned self] (listCell, indexPath, item) in
|
||||
var config = listCell.defaultContentConfiguration()
|
||||
|
||||
@@ -66,6 +66,11 @@
|
||||
// Inject bundle
|
||||
_WKProcessPoolConfiguration *poolConfiguration = [[_WKProcessPoolConfiguration alloc] init];
|
||||
NSURL *bundleURL = [[[NSBundle mainBundle] builtInPlugInsURL] URLByAppendingPathComponent:@"SBrowserProcessBundle.bundle"];
|
||||
|
||||
// Make sure it exists. Bail if otherwise.
|
||||
NSBundle *pluginBundle = [NSBundle bundleWithURL:bundleURL];
|
||||
NSAssert(pluginBundle != nil, @"Attix process bundle not found at %@", bundleURL.path);
|
||||
|
||||
[poolConfiguration setInjectedBundleURL:bundleURL];
|
||||
|
||||
// Set up process pool
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 52;
|
||||
objectVersion = 50;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
@@ -26,7 +26,7 @@
|
||||
1ADFF47924C7DFF8006DC7AE /* BrowserView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ADFF47824C7DFF8006DC7AE /* BrowserView.swift */; };
|
||||
1ADFF48424C8C12F006DC7AE /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1ADFF48324C8C12F006DC7AE /* Foundation.framework */; };
|
||||
1ADFF48D24C8C176006DC7AE /* SBRProcessBundleBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 1ADFF48C24C8C176006DC7AE /* SBRProcessBundleBridge.m */; };
|
||||
1ADFF4A724C8C271006DC7AE /* SBrowserProcessBundle.bundle in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 1ADFF48124C8C12F006DC7AE /* SBrowserProcessBundle.bundle */; platformFilter = ios; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
1ADFF4A724C8C271006DC7AE /* SBrowserProcessBundle.bundle in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 1ADFF48124C8C12F006DC7AE /* SBrowserProcessBundle.bundle */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
1ADFF4AA24C8D477006DC7AE /* SBRProcessPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 1ADFF4A924C8D477006DC7AE /* SBRProcessPlugin.m */; };
|
||||
1ADFF4AE24C8ED32006DC7AE /* ResourcePolicyManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ADFF4AD24C8ED32006DC7AE /* ResourcePolicyManager.swift */; };
|
||||
1ADFF4C024CA6964006DC7AE /* URLBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ADFF4BF24CA6964006DC7AE /* URLBar.swift */; };
|
||||
@@ -418,7 +418,6 @@
|
||||
/* Begin PBXTargetDependency section */
|
||||
1ADFF48F24C8C230006DC7AE /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
platformFilter = ios;
|
||||
target = 1ADFF48024C8C12F006DC7AE /* SBrowserProcessBundle */;
|
||||
targetProxy = 1ADFF48E24C8C230006DC7AE /* PBXContainerItemProxy */;
|
||||
};
|
||||
@@ -577,6 +576,7 @@
|
||||
PRODUCT_NAME = "rossler\\\\attix";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SUPPORTS_MACCATALYST = YES;
|
||||
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "App/Supporting Files/SBrowser-Bridging-Header.h";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
@@ -607,6 +607,7 @@
|
||||
PRODUCT_NAME = "rossler\\\\attix";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SUPPORTS_MACCATALYST = YES;
|
||||
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "App/Supporting Files/SBrowser-Bridging-Header.h";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2,6";
|
||||
@@ -622,8 +623,9 @@
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = iphoneos.internal;
|
||||
STRIP_INSTALLED_PRODUCT = NO;
|
||||
SUPPORTS_MACCATALYST = NO;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
SUPPORTS_MACCATALYST = YES;
|
||||
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
|
||||
TARGETED_DEVICE_FAMILY = "1,2,6";
|
||||
WRAPPER_EXTENSION = bundle;
|
||||
};
|
||||
name = Debug;
|
||||
@@ -636,8 +638,9 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.buzzert.SBrowserProcessBundle;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = iphoneos.internal;
|
||||
SUPPORTS_MACCATALYST = NO;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
SUPPORTS_MACCATALYST = YES;
|
||||
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
|
||||
TARGETED_DEVICE_FAMILY = "1,2,6";
|
||||
WRAPPER_EXTENSION = bundle;
|
||||
};
|
||||
name = Release;
|
||||
|
||||
Reference in New Issue
Block a user