Skip to content

Commit

Permalink
Merge pull request #5 from ogaoga/toolbar-on-keyboard
Browse files Browse the repository at this point in the history
for 1.3
  • Loading branch information
ogaoga authored Mar 11, 2021
2 parents 165299c + 9c878de commit c1b4274
Show file tree
Hide file tree
Showing 12 changed files with 288 additions and 54 deletions.
20 changes: 16 additions & 4 deletions UITabBrowser.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
A95E516325DBE45B00BD36EC /* Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = A95E516225DBE45B00BD36EC /* Settings.swift */; };
A96A1EC125D4C69900750224 /* BookmarkViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A96A1EC025D4C69900750224 /* BookmarkViewController.swift */; };
A96F3A8625E12B520048E2EE /* FaviconLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = A96F3A8525E12B520048E2EE /* FaviconLoader.swift */; };
A973006725F66E9000C85C73 /* KeyboardBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A973006625F66E9000C85C73 /* KeyboardBarViewController.swift */; };
A9782FA72598D79700654354 /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9782FA62598D79700654354 /* MainViewController.swift */; };
A9782FB2259B4CE300654354 /* Browsers.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9782FB1259B4CE300654354 /* Browsers.swift */; };
A97F983125DEB83E007D978C /* CollectionType.swift in Sources */ = {isa = PBXBuildFile; fileRef = A97F983025DEB83E007D978C /* CollectionType.swift */; };
Expand Down Expand Up @@ -94,6 +95,7 @@
A963570925B85CC000B752A1 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
A96A1EC025D4C69900750224 /* BookmarkViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkViewController.swift; sourceTree = "<group>"; };
A96F3A8525E12B520048E2EE /* FaviconLoader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FaviconLoader.swift; sourceTree = "<group>"; };
A973006625F66E9000C85C73 /* KeyboardBarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyboardBarViewController.swift; sourceTree = "<group>"; };
A9782FA62598D79700654354 /* MainViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = "<group>"; };
A9782FB1259B4CE300654354 /* Browsers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Browsers.swift; sourceTree = "<group>"; };
A97F983025DEB83E007D978C /* CollectionType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionType.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -238,6 +240,14 @@
path = Utility;
sourceTree = "<group>";
};
A973006525F66E5C00C85C73 /* KeyboardBar */ = {
isa = PBXGroup;
children = (
A973006625F66E9000C85C73 /* KeyboardBarViewController.swift */,
);
path = KeyboardBar;
sourceTree = "<group>";
};
A98406252598C908006B6F49 = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -270,6 +280,7 @@
A99DC44D25CD731D0095FAD7 /* SearchBar */,
A996F64325D046CB005D3F7A /* SearchResults */,
A96A1EBF25D4C65D00750224 /* Bookmark */,
A973006525F66E5C00C85C73 /* KeyboardBar */,
A9D643F225DAA7D10017D79D /* Settings */,
A91E73A425E7F73C00418F1E /* Onboarding */,
A91E73B225E802DE00418F1E /* Common */,
Expand Down Expand Up @@ -532,6 +543,7 @@
A9A12D9925BAECAA008843FF /* Tab.swift in Sources */,
A91F143325E93D6C00651645 /* Onboarding1ViewController.swift in Sources */,
A97F983125DEB83E007D978C /* CollectionType.swift in Sources */,
A973006725F66E9000C85C73 /* KeyboardBarViewController.swift in Sources */,
A98406652598CF1E006B6F49 /* WebViewController.swift in Sources */,
A99DC45125CD731D0095FAD7 /* SearchBar.swift in Sources */,
A9E4171B25CEC6290030C82A /* Items.swift in Sources */,
Expand Down Expand Up @@ -771,14 +783,14 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 12;
CURRENT_PROJECT_VERSION = 13;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = UITabBrowser/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.2;
MARKETING_VERSION = 1.3;
PRODUCT_BUNDLE_IDENTIFIER = com.example.UITabBrowser;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -792,14 +804,14 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 12;
CURRENT_PROJECT_VERSION = 13;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = UITabBrowser/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.2;
MARKETING_VERSION = 1.3;
PRODUCT_BUNDLE_IDENTIFIER = com.example.UITabBrowser;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down
2 changes: 2 additions & 0 deletions UITabBrowser/Browsers/BrowsersViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ class BrowsersViewModel: NSObject, ObservableObject {
.map { browsers in
return browsers.firstIndex { $0.selected } ?? 0
}
.removeDuplicates()
.sink(receiveValue: { [weak self] in self?.selectedIndex = $0 })
.store(in: &cancellables)

// Selected View Controller
browsers.$selectedViewController
.removeDuplicates()
.sink { [weak self] in self?.selectedViewController = $0 }
.store(in: &cancellables)
}
Expand Down
13 changes: 13 additions & 0 deletions UITabBrowser/Extension/String+URL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,17 @@ extension String {
var isSecureURL: Bool {
return self.lowercased().starts(with: "https://")
}

var isURL: Bool {
return self.validURL() != nil
}

func searchURL(searchURLPrefix: String) -> URL {
let lowercasedText = self.lowercased()
if let url = lowercasedText.validURL() {
return url
} else {
return URL(string: "\(searchURLPrefix)\(self.urlEncode())")!
}
}
}
29 changes: 29 additions & 0 deletions UITabBrowser/KeyboardBar/KeyboardBarViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// KeyboardBarViewController.swift
// UITabBrowser
//
// Created by ogaoga on 2021/03/08.
//

import UIKit

class KeyboardBarViewController: UIViewController {

@IBAction func cancelTextInput(_ sender: Any) {
UIApplication.shared.sendAction(
#selector(UIResponder.resignFirstResponder),
to: nil,
from: nil,
for: nil
)
}

@IBAction func pasteText(_ sender: Any) {
UIApplication.shared.sendAction(
#selector(UIResponder.paste(_:)),
to: nil,
from: nil,
for: nil
)
}
}
56 changes: 56 additions & 0 deletions UITabBrowser/Main/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@
<rect key="frame" x="0.0" y="88" width="414" height="677"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
<containerView hidden="YES" opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="G3a-JU-5F6">
<rect key="frame" x="0.0" y="852" width="414" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="rfX-11-hV5"/>
</constraints>
<connections>
<segue destination="aPh-T8-q7c" kind="embed" id="VRH-pP-Ce9"/>
</connections>
</containerView>
<progressView opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="tqC-PF-kKX">
<rect key="frame" x="0.0" y="88" width="414" height="4"/>
<constraints>
Expand All @@ -41,14 +50,17 @@
<constraints>
<constraint firstItem="tqC-PF-kKX" firstAttribute="top" secondItem="9Nk-zX-e1v" secondAttribute="top" id="0PT-Np-CuP"/>
<constraint firstItem="iv1-gw-Bie" firstAttribute="top" secondItem="9Nk-zX-e1v" secondAttribute="top" id="Dz5-uD-PD0"/>
<constraint firstItem="G3a-JU-5F6" firstAttribute="trailing" secondItem="9Nk-zX-e1v" secondAttribute="trailing" id="EpO-k5-xsN"/>
<constraint firstItem="iv1-gw-Bie" firstAttribute="leading" secondItem="9Nk-zX-e1v" secondAttribute="leading" id="FFZ-f8-nJX"/>
<constraint firstItem="dAi-qC-wpl" firstAttribute="leading" secondItem="9Nk-zX-e1v" secondAttribute="leading" id="LOw-hE-WvY"/>
<constraint firstItem="9Nk-zX-e1v" firstAttribute="trailing" secondItem="iv1-gw-Bie" secondAttribute="trailing" id="NCe-xa-LZD"/>
<constraint firstItem="9Nk-zX-e1v" firstAttribute="bottom" secondItem="dAi-qC-wpl" secondAttribute="bottom" id="Nhi-sq-ovV"/>
<constraint firstItem="dAi-qC-wpl" firstAttribute="trailing" secondItem="9Nk-zX-e1v" secondAttribute="trailing" id="WE8-bU-TaQ"/>
<constraint firstItem="dAi-qC-wpl" firstAttribute="top" secondItem="iv1-gw-Bie" secondAttribute="bottom" id="fND-wV-ANB"/>
<constraint firstItem="G3a-JU-5F6" firstAttribute="leading" secondItem="9Nk-zX-e1v" secondAttribute="leading" id="gwX-7x-shX"/>
<constraint firstItem="tqC-PF-kKX" firstAttribute="leading" secondItem="9Nk-zX-e1v" secondAttribute="leading" id="jWs-9k-Vbo"/>
<constraint firstItem="9Nk-zX-e1v" firstAttribute="trailing" secondItem="tqC-PF-kKX" secondAttribute="trailing" id="oFr-RS-BBO"/>
<constraint firstAttribute="bottom" secondItem="G3a-JU-5F6" secondAttribute="bottom" id="rV8-ky-VGE"/>
</constraints>
</view>
<toolbarItems>
Expand Down Expand Up @@ -88,6 +100,8 @@
<outlet property="backButton" destination="px7-SX-IwR" id="A73-Ym-hvh"/>
<outlet property="closeButton" destination="FJK-cG-cbw" id="9Sc-1p-z9C"/>
<outlet property="forwardButton" destination="rPH-E0-u2E" id="2xd-il-ZPc"/>
<outlet property="keyboardBar" destination="G3a-JU-5F6" id="A5J-RQ-sKT"/>
<outlet property="keyboardBarOffset" destination="rV8-ky-VGE" id="wgb-h2-XPB"/>
<outlet property="pageView" destination="iv1-gw-Bie" id="5bC-MO-kdf"/>
<outlet property="progressBar" destination="tqC-PF-kKX" id="Ycc-jV-02V"/>
<outlet property="searchButton" destination="kCR-Wc-YOS" id="8LP-H8-65f"/>
Expand Down Expand Up @@ -158,10 +172,52 @@
</objects>
<point key="canvasLocation" x="652" y="-29"/>
</scene>
<!--Keyboard Bar View Controller-->
<scene sceneID="rz9-bE-8yM">
<objects>
<viewController id="aPh-T8-q7c" customClass="KeyboardBarViewController" customModule="UITabBrowser" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="CQf-H3-sO7">
<rect key="frame" x="0.0" y="0.0" width="414" height="44"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="0T3-qB-cuu">
<rect key="frame" x="0.0" y="0.0" width="414" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="odf-m0-6xl"/>
</constraints>
<items>
<barButtonItem title="Paste" image="doc.on.clipboard" catalog="system" id="3Fc-8L-bBc">
<connections>
<action selector="pasteText:" destination="aPh-T8-q7c" id="Izb-Jg-m8y"/>
</connections>
</barButtonItem>
<barButtonItem style="plain" systemItem="flexibleSpace" id="hAo-T1-4Pc"/>
<barButtonItem systemItem="cancel" id="hdg-jP-FZo">
<connections>
<action selector="cancelTextInput:" destination="aPh-T8-q7c" id="4wE-Bg-Qbr"/>
</connections>
</barButtonItem>
</items>
</toolbar>
</subviews>
<viewLayoutGuide key="safeArea" id="0j1-Ex-8v0"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="0T3-qB-cuu" firstAttribute="centerY" secondItem="CQf-H3-sO7" secondAttribute="centerY" id="EZc-vA-Xgs"/>
<constraint firstItem="0T3-qB-cuu" firstAttribute="leading" secondItem="CQf-H3-sO7" secondAttribute="leading" id="H45-tQ-ECr"/>
<constraint firstAttribute="trailing" secondItem="0T3-qB-cuu" secondAttribute="trailing" id="o5d-AR-tbV"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="eQS-C6-Uft" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-49" y="532"/>
</scene>
</scenes>
<resources>
<image name="chevron.backward" catalog="system" width="96" height="128"/>
<image name="chevron.right" catalog="system" width="96" height="128"/>
<image name="doc.on.clipboard" catalog="system" width="116" height="128"/>
<image name="magnifyingglass" catalog="system" width="128" height="115"/>
<image name="xmark.square" catalog="system" width="128" height="114"/>
<systemColor name="systemBackgroundColor">
Expand Down
Loading

0 comments on commit c1b4274

Please sign in to comment.