-
Notifications
You must be signed in to change notification settings - Fork 8
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
cee5d41
commit 350d1c4
Showing
29 changed files
with
741 additions
and
89 deletions.
There are no files selected for viewing
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
6 changes: 6 additions & 0 deletions
6
...les/YandexMobileAdsExample/YandexMobileAdsExample/Common/NavigationScreenDataSource.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,6 @@ | ||
import Foundation | ||
|
||
protocol NavigationScreenDataSource { | ||
var destinationViewController: UIViewController { get } | ||
var title: String { get } | ||
} |
21 changes: 21 additions & 0 deletions
21
.../YandexMobileAdsExample/YandexMobileAdsExample/Common/NavigationTableViewController.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,21 @@ | ||
import Foundation | ||
|
||
class NavigationTableViewController<T: NavigationScreenDataSource>: UITableViewController where T: CaseIterable { | ||
private var dataSource = Array(T.allCases) | ||
|
||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
dataSource.count | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
let cell = UITableViewCell() | ||
let cellModel = dataSource[indexPath.row] | ||
cell.textLabel?.text = cellModel.title | ||
return cell | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | ||
let cellModel = dataSource[indexPath.row] | ||
navigationController?.pushViewController(cellModel.destinationViewController, animated: true) | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
Examples/YandexMobileAdsExample/YandexMobileAdsExample/Common/String+Extensions.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,10 @@ | ||
import Foundation | ||
|
||
extension String { | ||
func camelCaseToWords() -> String { | ||
map { ($0.isUppercase ? " " : "") + String($0) } | ||
.joined(separator: "") | ||
.trimmingCharacters(in: .whitespaces) | ||
.localizedCapitalized | ||
} | ||
} |
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
Oops, something went wrong.