Skip to content

Commit b78a13c

Browse files
author
Эван Крошкин
committed
ADDED SegmentControl
1 parent f50d6cd commit b78a13c

File tree

12 files changed

+269
-17
lines changed

12 files changed

+269
-17
lines changed

.swiftlint.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
included:
2+
- Source
3+
- Tests
4+
- /Users/ivantsvetkov/Desktop/Task4
5+
excluded:
6+
- Pods
7+
- Tests/SwiftLintFrameworkTests/Resources
8+
analyzer_rules:
9+
- unused_declaration
10+
- unused_import
11+
line_length: 200
12+
object_literal:
13+
color_literal: false
14+
image_literal: false
15+
opt_in_rules:
16+
- anyobject_protocol
17+
- array_init
18+
- attributes
19+
- closure_end_indentation
20+
- closure_spacing
21+
- collection_alignment
22+
- contains_over_filter_count
23+
- contains_over_filter_is_empty
24+
- contains_over_first_not_nil
25+
- contains_over_range_nil_comparison
26+
- discouraged_none_name
27+
- discouraged_object_literal
28+
- empty_collection_literal
29+
- empty_count
30+
- empty_string
31+
- empty_xctest_method
32+
- enum_case_associated_values_count
33+
- explicit_init
34+
- extension_access_modifier
35+
- fallthrough
36+
- fatal_error_message
37+
- file_header
38+
- file_name
39+
- first_where
40+
- flatmap_over_map_reduce
41+
- identical_operands
42+
- joined_default_parameter
43+
- last_where
44+
- legacy_multiple
45+
- legacy_random
46+
- literal_expression_end_indentation
47+
- lower_acl_than_parent
48+
- modifier_order
49+
- nimble_operator
50+
- nslocalizedstring_key
51+
- number_separator
52+
- object_literal
53+
- operator_usage_whitespace
54+
- overridden_super_call
55+
- override_in_extension
56+
- pattern_matching_keywords
57+
- prefer_self_in_static_references
58+
- prefer_self_type_over_type_of_self
59+
- private_action
60+
- private_outlet
61+
- prohibited_interface_builder
62+
- prohibited_super_call
63+
- quick_discouraged_call
64+
- quick_discouraged_focused_test
65+
- quick_discouraged_pending_test
66+
- reduce_into
67+
- redundant_nil_coalescing
68+
- redundant_type_annotation
69+
- single_test_class
70+
- sorted_first_last
71+
- sorted_imports
72+
- static_operator
73+
- strong_iboutlet
74+
- test_case_accessibility
75+
- toggle_bool
76+
- unavailable_function
77+
- unneeded_parentheses_in_closure_argument
78+
- unowned_variable_capture
79+
- untyped_error_in_catch
80+
- vertical_parameter_alignment_on_call
81+
- xct_specific_matcher
82+
- yoda_condition
83+
identifier_name:
84+
excluded:
85+
- id
86+
number_separator:
87+
minimum_length: 5
88+
file_name:
89+
excluded:
90+
- main.swift
91+
- LinuxMain.swift
92+
- TestHelpers.swift
93+
- shim.swift
94+
- AutomaticRuleTests.generated.swift
95+

Pods/Pods.xcodeproj/project.pbxproj

Lines changed: 7 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Pods/SnapKit/Source/LayoutConstraintItem.swift

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Task4.xcodeproj/project.pbxproj

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,34 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
BC5F4AA827CBBD5400E82425 /* MapViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC5F4AA727CBBD5400E82425 /* MapViewController.swift */; };
11+
BC5F4AAA27CBBD8200E82425 /* ClientAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC5F4AA927CBBD8200E82425 /* ClientAPI.swift */; };
12+
BC5F4AAC27CBC72F00E82425 /* ListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC5F4AAB27CBC72F00E82425 /* ListViewController.swift */; };
13+
BC5F4AAE27CBCE1200E82425 /* UIViewController + Ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC5F4AAD27CBCE1200E82425 /* UIViewController + Ext.swift */; };
1014
BC69EBB827C4FD07006D85DD /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC69EBB727C4FD07006D85DD /* AppDelegate.swift */; };
1115
BC69EBBA27C4FD07006D85DD /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC69EBB927C4FD07006D85DD /* SceneDelegate.swift */; };
1216
BC69EBBC27C4FD07006D85DD /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC69EBBB27C4FD07006D85DD /* MainViewController.swift */; };
1317
BC69EBC127C4FD09006D85DD /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BC69EBC027C4FD09006D85DD /* Assets.xcassets */; };
1418
BC69EBC427C4FD09006D85DD /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BC69EBC227C4FD09006D85DD /* LaunchScreen.storyboard */; };
19+
BC8E922127CACA41006B1B3C /* .swiftlint.yml in Resources */ = {isa = PBXBuildFile; fileRef = BC8E922027CACA41006B1B3C /* .swiftlint.yml */; };
1520
E18108920768AA2DDA77B8FD /* Pods_Task4.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 65E19019E5D0DB8FB342C934 /* Pods_Task4.framework */; };
1621
/* End PBXBuildFile section */
1722

1823
/* Begin PBXFileReference section */
1924
65E19019E5D0DB8FB342C934 /* Pods_Task4.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Task4.framework; sourceTree = BUILT_PRODUCTS_DIR; };
2025
9CA093AA9384F4B4514F05B6 /* Pods-Task4.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Task4.debug.xcconfig"; path = "Target Support Files/Pods-Task4/Pods-Task4.debug.xcconfig"; sourceTree = "<group>"; };
26+
BC5F4AA727CBBD5400E82425 /* MapViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapViewController.swift; sourceTree = "<group>"; };
27+
BC5F4AA927CBBD8200E82425 /* ClientAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientAPI.swift; sourceTree = "<group>"; };
28+
BC5F4AAB27CBC72F00E82425 /* ListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListViewController.swift; sourceTree = "<group>"; };
29+
BC5F4AAD27CBCE1200E82425 /* UIViewController + Ext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController + Ext.swift"; sourceTree = "<group>"; };
2130
BC69EBB427C4FD07006D85DD /* Task4.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Task4.app; sourceTree = BUILT_PRODUCTS_DIR; };
2231
BC69EBB727C4FD07006D85DD /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
2332
BC69EBB927C4FD07006D85DD /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
2433
BC69EBBB27C4FD07006D85DD /* MainViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = "<group>"; };
2534
BC69EBC027C4FD09006D85DD /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
2635
BC69EBC327C4FD09006D85DD /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
2736
BC69EBC527C4FD09006D85DD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
37+
BC8E922027CACA41006B1B3C /* .swiftlint.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = .swiftlint.yml; sourceTree = "<group>"; };
2838
D16CC7566D75C8D69C33F212 /* Pods-Task4.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Task4.release.xcconfig"; path = "Target Support Files/Pods-Task4/Pods-Task4.release.xcconfig"; sourceTree = "<group>"; };
2939
/* End PBXFileReference section */
3040

@@ -46,7 +56,6 @@
4656
9CA093AA9384F4B4514F05B6 /* Pods-Task4.debug.xcconfig */,
4757
D16CC7566D75C8D69C33F212 /* Pods-Task4.release.xcconfig */,
4858
);
49-
name = Pods;
5059
path = Pods;
5160
sourceTree = "<group>";
5261
};
@@ -61,6 +70,7 @@
6170
BC69EBAB27C4FD06006D85DD = {
6271
isa = PBXGroup;
6372
children = (
73+
BC8E922027CACA41006B1B3C /* .swiftlint.yml */,
6474
BC69EBB627C4FD07006D85DD /* Task4 */,
6575
BC69EBB527C4FD07006D85DD /* Products */,
6676
458A7B5C9688074B2F4AB2A8 /* Pods */,
@@ -82,6 +92,10 @@
8292
BC69EBB727C4FD07006D85DD /* AppDelegate.swift */,
8393
BC69EBB927C4FD07006D85DD /* SceneDelegate.swift */,
8494
BC69EBBB27C4FD07006D85DD /* MainViewController.swift */,
95+
BC5F4AA727CBBD5400E82425 /* MapViewController.swift */,
96+
BC5F4AAB27CBC72F00E82425 /* ListViewController.swift */,
97+
BC5F4AAD27CBCE1200E82425 /* UIViewController + Ext.swift */,
98+
BC5F4AA927CBBD8200E82425 /* ClientAPI.swift */,
8599
BC69EBC027C4FD09006D85DD /* Assets.xcassets */,
86100
BC69EBC227C4FD09006D85DD /* LaunchScreen.storyboard */,
87101
BC69EBC527C4FD09006D85DD /* Info.plist */,
@@ -150,6 +164,7 @@
150164
isa = PBXResourcesBuildPhase;
151165
buildActionMask = 2147483647;
152166
files = (
167+
BC8E922127CACA41006B1B3C /* .swiftlint.yml in Resources */,
153168
BC69EBC427C4FD09006D85DD /* LaunchScreen.storyboard in Resources */,
154169
BC69EBC127C4FD09006D85DD /* Assets.xcassets in Resources */,
155170
);
@@ -223,7 +238,11 @@
223238
files = (
224239
BC69EBBC27C4FD07006D85DD /* MainViewController.swift in Sources */,
225240
BC69EBB827C4FD07006D85DD /* AppDelegate.swift in Sources */,
241+
BC5F4AAE27CBCE1200E82425 /* UIViewController + Ext.swift in Sources */,
242+
BC5F4AAC27CBC72F00E82425 /* ListViewController.swift in Sources */,
226243
BC69EBBA27C4FD07006D85DD /* SceneDelegate.swift in Sources */,
244+
BC5F4AAA27CBBD8200E82425 /* ClientAPI.swift in Sources */,
245+
BC5F4AA827CBBD5400E82425 /* MapViewController.swift in Sources */,
227246
);
228247
runOnlyForDeploymentPostprocessing = 0;
229248
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

Task4/AppDelegate.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ import UIKit
1010
@main
1111
class AppDelegate: UIResponder, UIApplicationDelegate {
1212
}
13-

Task4/ClientAPI.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//
2+
// ClientAPI.swift
3+
// Task4
4+
//
5+
// Created by Эван Крошкин on 27.02.22.
6+
//
7+
8+
import Foundation

Task4/ListViewController.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// ListViewController.swift
3+
// Task4
4+
//
5+
// Created by Эван Крошкин on 27.02.22.
6+
//
7+
8+
import UIKit
9+
import SnapKit
10+
11+
class ListViewController: UIViewController {
12+
13+
override func viewDidLoad() {
14+
super.viewDidLoad()
15+
view.backgroundColor = .blue
16+
}
17+
}

Task4/MainViewController.swift

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,75 @@
66
//
77

88
import UIKit
9+
import SnapKit
910

1011
class MainViewController: UIViewController {
11-
12+
private lazy var segmentedControl: UISegmentedControl = {
13+
let segmentedControl = UISegmentedControl()
14+
segmentedControl.backgroundColor = .lightGray
15+
segmentedControl.insertSegment(withTitle: "Map", at: 0, animated: true)
16+
segmentedControl.insertSegment(withTitle: "List", at: 1, animated: true)
17+
segmentedControl.selectedSegmentIndex = 2
18+
return segmentedControl
19+
}()
20+
21+
private lazy var contentView: UIView = {
22+
let view = UIView()
23+
return view
24+
}()
25+
26+
private lazy var mapViewController: MapViewController = {
27+
var viewController = MapViewController()
28+
self.set(view: contentView, viewController)
29+
return viewController
30+
}()
31+
32+
private lazy var listViewController: ListViewController = {
33+
var viewController = ListViewController()
34+
self.set(view: contentView, viewController)
35+
return viewController
36+
}()
37+
1238
override func viewDidLoad() {
1339
super.viewDidLoad()
40+
segmentedControl.addTarget(self,
41+
action: #selector(segmentAction(_:)),
42+
for: .valueChanged)
43+
setupVCs()
44+
}
45+
46+
private func setupVCs() {
47+
view.addSubview(segmentedControl)
48+
view.addSubview(contentView)
49+
view.backgroundColor = .gray
50+
setDefaultSegment()
51+
segmentedControl.snp.makeConstraints { make in
52+
make.top.equalTo(view.safeAreaLayoutGuide.snp.top)
53+
make.leading.equalToSuperview()
54+
make.trailing.equalToSuperview()
55+
}
56+
contentView.snp.makeConstraints { make in
57+
make.top.equalTo(segmentedControl.snp.bottom)
58+
make.leading.equalToSuperview()
59+
make.trailing.equalToSuperview()
60+
make.bottom.equalToSuperview()
61+
}
62+
}
63+
64+
private func setDefaultSegment() {
65+
self.changeVCs(view: contentView, mapViewController, listViewController)
66+
navigationController?.navigationBar.topItem?.title = "MAP ATMs"
67+
}
68+
69+
@objc func segmentAction(_ segmentedControl: UISegmentedControl) {
70+
switch (segmentedControl.selectedSegmentIndex) {
71+
case 0:
72+
setDefaultSegment()
73+
case 1:
74+
self.changeVCs(view: contentView, listViewController, mapViewController)
75+
navigationController?.navigationBar.topItem?.title = "LIST ATMs"
76+
default:
77+
break
78+
}
1479
}
15-
16-
1780
}
18-

Task4/MapViewController.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// MapViewController.swift
3+
// Task4
4+
//
5+
// Created by Эван Крошкин on 27.02.22.
6+
//
7+
8+
import UIKit
9+
import SnapKit
10+
11+
class MapViewController: UIViewController {
12+
13+
override func viewDidLoad() {
14+
super.viewDidLoad()
15+
view.backgroundColor = .yellow
16+
}
17+
}

0 commit comments

Comments
 (0)