ارفع راسك فوق انته سوري حر ... :green_heart::green_heart:

Skip to content
Snippets Groups Projects
Commit 3ba68ad0 authored by Mustafa Merza's avatar Mustafa Merza
Browse files

- Changed tab bar shape and style in main screen.

- Added localized titles to tab bar.
parent a750683e
Branches
No related tags found
No related merge requests found
...@@ -14,14 +14,37 @@ class AppTabBarController: UITabBarController, UITabBarControllerDelegate, Walkt ...@@ -14,14 +14,37 @@ class AppTabBarController: UITabBarController, UITabBarControllerDelegate, Walkt
return controller as! AppTabBarController return controller as! AppTabBarController
} }
private var observation: NSKeyValueObservation?
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
super.init(coder: coder) super.init(coder: coder)
} }
deinit {
observation = nil
}
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
window = UIWindow(frame: UIScreen.main.bounds) window = UIWindow(frame: UIScreen.main.bounds)
self.delegate = self self.delegate = self
observation = observe(\.tabBar.semanticContentAttribute) { value, change in
self.reloadLocalization()
}
setupUI()
}
private func setupUI() {
tabBar.items?[0].title = .studio.localized
tabBar.items?[2].title = .fileManager.localized
}
private func reloadLocalization() {
tabBar.items?[0].title = .studio.localized
tabBar.items?[2].title = .fileManager.localized
} }
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
...@@ -78,6 +101,12 @@ class AppTabBar: UITabBar { ...@@ -78,6 +101,12 @@ class AppTabBar: UITabBar {
private var middleButton = UIButton() private var middleButton = UIButton()
private var shapeLayer: CALayer? private var shapeLayer: CALayer?
override func sizeThatFits(_ size: CGSize) -> CGSize {
var sizeThatFits = super.sizeThatFits(size)
sizeThatFits.height = 94
return sizeThatFits
}
private func addShape() { private func addShape() {
let shapeLayer = CAShapeLayer() let shapeLayer = CAShapeLayer()
shapeLayer.path = createPath() shapeLayer.path = createPath()
...@@ -118,17 +147,18 @@ class AppTabBar: UITabBar { ...@@ -118,17 +147,18 @@ class AppTabBar: UITabBar {
override func layoutSubviews() { override func layoutSubviews() {
super.layoutSubviews() super.layoutSubviews()
middleButton.center = CGPoint(x: UIScreen.main.bounds.width / 2, y: 10) middleButton.center = CGPoint(x: UIScreen.main.bounds.width / 2, y: 0)
} }
@objc private func setupMiddleButton() { @objc private func setupMiddleButton() {
middleButton.setImage(.addDocIcon, for: UIControl.State.normal) let image: UIImage? = .scanButton
middleButton.setImage(image, for: UIControl.State.normal)
middleButton.contentVerticalAlignment = .fill middleButton.contentVerticalAlignment = .fill
middleButton.contentHorizontalAlignment = .fill middleButton.contentHorizontalAlignment = .fill
middleButton.imageEdgeInsets = .zero middleButton.imageEdgeInsets = .zero
middleButton.frame.size = CGSize(width: 100, height: 100) middleButton.frame.size = CGSize(width: 75, height: 75)
middleButton.layer.masksToBounds = true middleButton.layer.masksToBounds = true
middleButton.layer.cornerRadius = 50 middleButton.layer.cornerRadius = middleButton.frame.size.height / 2
middleButton.center = CGPoint(x: UIScreen.main.bounds.width / 2, y: 0) middleButton.center = CGPoint(x: UIScreen.main.bounds.width / 2, y: 0)
middleButton.addTarget(self, action: #selector(buttonPressed), for: .touchUpInside) middleButton.addTarget(self, action: #selector(buttonPressed), for: .touchUpInside)
...@@ -152,23 +182,47 @@ class AppTabBar: UITabBar { ...@@ -152,23 +182,47 @@ class AppTabBar: UITabBar {
} }
private func createPath() -> CGPath { private func createPath() -> CGPath {
let height: CGFloat = 120
let path = UIBezierPath() let path = UIBezierPath()
let centerWidth = self.frame.width / 2
path.move(to: CGPoint(x: 0, y: 0)) // start top left let buttonSize: CGFloat = middleButton.frame.width
path.addLine(to: CGPoint(x: (centerWidth - height * 0.5), y: 0)) // the beginning of the trough
let frameWidth: CGFloat = self.frame.width
let frameHeight: CGFloat = self.frame.height
let centerWidth = frameWidth / 2
let centerHeight = 0.5 * frameHeight
let startPoint = CGPoint(x: 0, y: centerHeight)
path.move(to: startPoint)
path.addArc(withCenter: CGPoint(x: centerHeight, y: centerHeight),
radius: centerHeight,
startAngle: .pi,
endAngle: -.pi/2,
clockwise: true)
path.addLine(to: CGPoint(x: centerWidth - (buttonSize / 2 + 10), y: 0))
path.addArc(withCenter: CGPoint(x: centerWidth, y: 0), path.addArc(withCenter: CGPoint(x: centerWidth, y: 0),
radius: height * 0.5, radius: buttonSize / 2 + 10,
startAngle: CGFloat.pi, startAngle: CGFloat.pi,
endAngle: 0, endAngle: 0,
clockwise: false) clockwise: false)
path.addLine(to: CGPoint(x: (centerWidth + height * 0.5), y: 0)) path.addLine(to: CGPoint(x: centerWidth + (buttonSize / 2 + 10), y: 0))
path.addLine(to: CGPoint(x: self.frame.width, y: 0))
path.addLine(to: CGPoint(x: self.frame.width, y: self.frame.height)) path.addArc(withCenter: CGPoint(x: frameWidth - centerHeight, y: centerHeight),
path.addLine(to: CGPoint(x: 0, y: self.frame.height)) radius: centerHeight,
startAngle: -.pi/2,
endAngle: 0,
clockwise: true)
path.addLine(to: CGPoint(x: frameWidth, y: frameHeight))
path.addLine(to: CGPoint(x: 0, y: frameHeight))
path.close() path.close()
return path.cgPath return path.cgPath
......
...@@ -100,4 +100,6 @@ extension String { ...@@ -100,4 +100,6 @@ extension String {
static let passports = "passports" static let passports = "passports"
static let contracts = "contracts" static let contracts = "contracts"
static let identifiers = "identifiers" static let identifiers = "identifiers"
static let studio = "studio"
} }
...@@ -12,6 +12,7 @@ import UIKit ...@@ -12,6 +12,7 @@ import UIKit
extension UIImage { extension UIImage {
static let addDocIcon = UIImage(resource: .addDocIcon) static let addDocIcon = UIImage(resource: .addDocIcon)
static let scanButton = UIImage(resource: .scanButton)
static let preview = UIImage(resource: .preview) static let preview = UIImage(resource: .preview)
static let tabbarIPad = UIImage(resource: .tabbarIpad) static let tabbarIPad = UIImage(resource: .tabbarIpad)
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22155" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="NRZ-n7-XkU"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="NRZ-n7-XkU">
<device id="retina6_1" orientation="portrait" appearance="light"/> <device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies> <dependencies>
<deployment identifier="iOS"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22131"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22685"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/> <capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/> <capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
<tabBarController storyboardIdentifier="AppTabBarController" automaticallyAdjustsScrollViewInsets="NO" id="NRZ-n7-XkU" customClass="AppTabBarController" customModule="MiniScanner" customModuleProvider="target" sceneMemberID="viewController"> <tabBarController storyboardIdentifier="AppTabBarController" automaticallyAdjustsScrollViewInsets="NO" id="NRZ-n7-XkU" customClass="AppTabBarController" customModule="MiniScanner" customModuleProvider="target" sceneMemberID="viewController">
<toolbarItems/> <toolbarItems/>
<navigationItem key="navigationItem" id="4z0-Nb-W9s"/> <navigationItem key="navigationItem" id="4z0-Nb-W9s"/>
<tabBar key="tabBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" itemPositioning="fill" id="UOw-xw-62P" customClass="AppTabBar" customModule="MiniScanner" customModuleProvider="target"> <tabBar key="tabBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" itemPositioning="centered" id="UOw-xw-62P" customClass="AppTabBar" customModule="MiniScanner" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="1000" height="1000"/> <rect key="frame" x="0.0" y="0.0" width="1000" height="1000"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
......
...@@ -1016,6 +1016,23 @@ ...@@ -1016,6 +1016,23 @@
} }
} }
}, },
"studio" : {
"extractionState" : "manual",
"localizations" : {
"ar" : {
"stringUnit" : {
"state" : "translated",
"value" : "الاستديو"
}
},
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Studio"
}
}
}
},
"telegram" : { "telegram" : {
"extractionState" : "manual", "extractionState" : "manual",
"localizations" : { "localizations" : {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment