Skip to content
This repository was archived by the owner on Feb 16, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
50e1a1a
- delete storyboard
Mol0ko Aug 30, 2019
048483a
Merge pull request #1 from HandsAppTeam/develop
Aug 30, 2019
902d365
Update readme.md
Aug 30, 2019
04a56c1
Create LICENSE
Aug 30, 2019
45dd5e7
Merge pull request #2 from HandsAppTeam/add-license-1
Aug 30, 2019
2a26cbd
Update readme.md
Aug 30, 2019
4865415
add groups structure
Mol0ko Sep 2, 2019
1705229
Update readme.md
Sep 2, 2019
e0a1a9a
Delete choosing_project_template.png
Sep 2, 2019
3773007
add AppCenter to podfile
Mol0ko Sep 4, 2019
505a8ac
add app center configuration
Mol0ko Sep 4, 2019
545d737
Merge pull request #3 from HandsAppTeam/develop
Sep 4, 2019
dd63c11
add AppCenter custom script
Mol0ko Sep 4, 2019
d5ae639
Merge branch 'develop'
Mol0ko Sep 4, 2019
504d0f9
change generamba templates source
Mol0ko Sep 10, 2019
5e15cff
Merge branch 'develop'
Mol0ko Sep 10, 2019
14f6d9f
update line_length rule warning
Mol0ko Sep 11, 2019
790fd14
disable swift format trailing commas
Mol0ko Oct 22, 2019
ab1b0e5
add app center crashes service
Mol0ko Oct 22, 2019
f0e8e20
IT-91:
Mol0ko Oct 22, 2019
4e7aff8
add empty swift file template
Mol0ko Nov 5, 2019
7eb43f7
add .swiftformat file
Mol0ko Nov 6, 2019
9003214
rename Module to Screen
Mol0ko Dec 19, 2019
4015e6c
add unit test target
Mol0ko Dec 19, 2019
0e98de4
Update readme.md
Dec 23, 2019
3fb7e3b
update podfile
Mol0ko Dec 23, 2019
9a9a049
- update AppDelegate with HandsAppUI and Theme
Mol0ko Dec 23, 2019
9879471
- update AppDelegate with setupWindow()
Mol0ko Dec 23, 2019
9983a7f
Merge branch 'develop'
Mol0ko Dec 23, 2019
42acb42
Update readme.md
Dec 24, 2019
6ec9829
- update install templates files
Mol0ko Dec 24, 2019
07abca4
- add assets catalog
Mol0ko Dec 24, 2019
ad7fb50
- add screenshots to gitignore
Mol0ko Dec 25, 2019
146ac24
Update readme.md
Dec 26, 2019
b203aa6
add and configure network app template
Mol0ko Feb 6, 2020
db9068c
add updated podfile and .strings
Mol0ko Feb 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Empty Swift File.xctemplate/TemplateIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Empty Swift File.xctemplate/TemplateIcon@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions Empty Swift File.xctemplate/TemplateInfo.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Kind</key>
<string>Xcode.IDEFoundation.TextSubstitutionFileTemplateKind</string>
<key>Description</key>
<string>Empty Swift file template</string>
<key>SortOrder</key>
<string>30</string>
<key>AllowedTypes</key>
<array>
<string>public.swift-source</string>
</array>
<key>DefaultCompletionName</key>
<string>NewScreen</string>
<key>MainTemplateFile</key>
<string>___FILEBASENAME___</string>
<key>Options</key>
<array>
<dict>
<key>Default</key>
<string></string>
<key>Identifier</key>
<string>fileName</string>
<key>Name</key>
<string>File name</string>
<key>Required</key>
<string>YES</string>
<key>Type</key>
<string>text</string>
</dict>
<dict>
<key>Default</key>
<string>___VARIABLE_fileName___</string>
<key>Identifier</key>
<string>productName</string>
<key>Type</key>
<string>static</string>
</dict>
</array>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

5 changes: 5 additions & 0 deletions HandsApp Network iOS App.xctemplate/AppDefaults.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
enum AppDefaults {
#warning("Replace by your server URL")
static let serverBaseUrl = "https://handsapp.ru"
static let serverApiBaseUrl = serverBaseUrl + "/api/"
}
17 changes: 17 additions & 0 deletions HandsApp Network iOS App.xctemplate/AuthPlugin.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Moya

// MARK: - AuthPlugin

class AuthPlugin: PluginType {
private let keychain = Keychain()

func prepare(_ request: URLRequest, target _: TargetType) -> URLRequest {
let jwtToken: String = keychain.get(KeychainKeys.jwtToken) ?? ""
var request = request
request.addValue(
"JWT \(jwtToken)",
forHTTPHeaderField: "Authorization"
)
return request
}
}
10 changes: 10 additions & 0 deletions HandsApp Network iOS App.xctemplate/ErrorHandler.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Foundation

class ErrorHandler {
var messagesView: UserMessagesView?

func handle(error: Error) {
let message = error.localizedDescription
messagesView?.showErrorAlert(withMessage: message)
}
}
26 changes: 26 additions & 0 deletions HandsApp Network iOS App.xctemplate/ErrorHandlingPlugin.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Moya
import Result

class ErrorHandlingPlugin: PluginType {
private let reachabilityManager = ReachabilityManager(host: AppDefaults.serverApiBaseUrl)
weak var errorHandler: ErrorHandler?

func didReceive(_ result: Result<Response, MoyaError>, target _: TargetType) {
guard case let .failure(moyaError) = result,
let errorHandler = errorHandler else { return }

if case let .underlying(error, _) = moyaError,
(error as NSError).code == NSURLErrorCancelled {
return
}

var error: Error = moyaError
if let reachabilityManager = reachabilityManager,
!reachabilityManager.isReachable {
error = NetworkReachabilityError()
} else if let statusCode = moyaError.response?.statusCode {
error = HTTPNetworkError(statusCode: statusCode)
}
errorHandler.handle(error: error)
}
}
26 changes: 26 additions & 0 deletions HandsApp Network iOS App.xctemplate/HTTPNetworkError.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Foundation

struct HTTPNetworkError: Error {
let statusCode: Int
}

extension HTTPNetworkError: LocalizedError {
var errorDescription: String? {
return localizedDescription
}

var localizedDescription: String {
switch statusCode {
case 401:
return R.string.localizable.network_error_no_registration()
case 403:
return R.string.localizable.network_error_forbidden()
case 404:
return R.string.localizable.network_error_not_found()
case 500, 502:
return R.string.localizable.network_error_internal_server_error()
default:
return R.string.localizable.network_error_default()
}
}
}
8 changes: 8 additions & 0 deletions HandsApp Network iOS App.xctemplate/Keychain.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import KeychainSwift

class Keychain: KeychainSwift {
override init() {
let prefix = Bundle.main.bundleIdentifier ?? "ru.handsapp" + "_keychain_"
super.init(keyPrefix: prefix)
}
}
3 changes: 3 additions & 0 deletions HandsApp Network iOS App.xctemplate/KeychainKeys.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
enum KeychainKeys {
static let jwtToken = "jwtToken"
}
12 changes: 12 additions & 0 deletions HandsApp Network iOS App.xctemplate/Localizable.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"error_text" = "Ошибка";
"ok" = "Ок";

// MARK: - Errors
"network_error_forbidden" = "Извините, у вас недостаточно прав для выполнения данной операции ⛔";
"network_error_not_found" = "Ресурс не найден 🤷";
"network_error_internal_server_error" = "Внутренняя ошибка сервера. Попробуйте повторить запрос через несколько минут 💤";
"network_error_default" = "Упс! Что-то пошло не так";
"network_error_no_registration" = "Ошибка авторизации";
"check_connection_and_try_again" = "Нет соединения с интернетом";
"user_is_blocked" = "Пользователь заблокирован";
"contact_support" = "Обратитесь в поддержку";
11 changes: 11 additions & 0 deletions HandsApp Network iOS App.xctemplate/NetworkReachabilityError.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Foundation

struct NetworkReachabilityError: Error, LocalizedError {
var errorDescription: String? {
return localizedDescription
}

var localizedDescription: String {
return String()
}
}
28 changes: 28 additions & 0 deletions HandsApp Network iOS App.xctemplate/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use_frameworks!
inhibit_all_warnings!

platform :ios, '11.0'

def appcenter
pod 'AppCenter'
pod 'AppCenter/Distribute'
pod 'AppCenter/Crashes'
end

target '___PACKAGENAME___' do
# Code Tools
pod 'R.swift'
pod 'SwiftFormat/CLI'
pod 'SwiftLint'

# SDKs
appcenter

# UI
pod 'HandsAppUI'

# Networking
pod 'SDWebImage'
pod 'Moya'
pod 'KeychainSwift'
end
3 changes: 3 additions & 0 deletions HandsApp Network iOS App.xctemplate/ReachabilityManager.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Alamofire

class ReachabilityManager: NetworkReachabilityManager {}
51 changes: 51 additions & 0 deletions HandsApp Network iOS App.xctemplate/ServerApi.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import Moya

enum ServerApi {
#warning("This is sample implementation of api endpoint. Remove it if needed")
case auth(firToken: String)
}

// MARK: - Moya setup

extension ServerApi: TargetType {
var baseURL: URL {
guard let url = URL(string: AppDefaults.serverApiBaseUrl) else {
fatalError("Failed to provide server api base url")
}
return url
}

var path: String {
switch self {
case .auth:
return "auth/firebase"
}
}

var method: Method {
switch self {
case .auth:
return .post
}
}

var sampleData: Data {
return Data()
}

var validationType: ValidationType {
return .successCodes
}

var task: Task {
switch self {
case let .auth(firToken):
let parameters = ["access_token": firToken]
return .requestParameters(parameters: parameters, encoding: JSONEncoding.default)
}
}

var headers: [String: String]? {
return nil
}
}
Loading