SwiftHub
SwiftHub copied to clipboard
Discussion
Hello to all, and welcome to SwiftHub! Write here all your questions, suggestions or feature requests.
Hello, I would like to translate the app in Italian, could you tell me which file to select and then translate?
Hey @N3Z-aka-SUPERMAN , I added an Italian language file to the project, you can find it here SwiftHub/Resources/Localizable.strings Thanks for your contribution :)
It is always a pleasure, however you could implement the ability to clone / download projects directly on iOS? How does Working Copy so to speak ...
Working Copy is one of my favorite apps and I will definitely implement similar functionality. In the version 2 it will be the main feature.
One feature request - to be able to rearrange tabs. 90% of the use on mobile for me is checking events/notifications, I would hardly ever search and look at trending repositories on mobile. As such it would be most useful if the Events tab was first so it would be the first view to appear when the app is launched.
Hi @lukakerr Thanks for suggestion, i updated tabs order, please check out))
Wow that was a very quick turnaround! Thanks, it looks good. I will await the next App Store release :)
Hi @khoren93 im using Moya ObjectMapper but i have issues with my api like this https://github.com/bmoliveira/Moya-ObjectMapper/issues/65 do you have any solution ?
Hi @illidandh This is from my commercial project :) Required pods Moya/RxSwift, Moya-ObjectMapper/RxSwift
Create Response.swift model
// Response.swift
import ObjectMapper
struct ObjectResponse<T: Mappable>: Mappable {
var result: T?
var error: Int?
var message: String?
init?(map: Map) {}
mutating func mapping(map: Map) {
result <- map["data"]
error <- map["error"]
message <- map["message"]
}
}
struct ArrayResponse<T: Mappable>: Mappable {
var result: [T]?
var error: Int?
var message: String?
init?(map: Map) {}
init() {}
mutating func mapping(map: Map) {
result <- map["data"]
error <- map["error"]
message <- map["message"]
}
}
Create your Api class
class Api {
static let shared = Api()
var provider = Networking.newDefaultNetworking()
func user(id: Int) -> Observable<User> {
return requestObject(.user(id: id), type: User.self)
}
func users(keyword: String) -> Observable<[User]> {
return requestArray(.users(keyword: keyword), type: User.self)
}
}
extension Api {
private func requestObject<T: Mappable>(_ target: TriipAPI, type: T.Type) -> Observable<T> {
return provider.request(target)
.mapObject(ObjectResponse<T>.self)
.observeOn(MainScheduler.instance)
.flatMapLatest({ (response) -> Observable<T> in
if let item = response.result {
return Observable.just(item)
}
return Observable.error(RxError.unknown)
})
}
private func requestArray<T: Mappable>(_ target: TriipAPI, type: T.Type) -> Observable<[T]> {
return provider.request(target)
.mapObject(ArrayResponse<T>.self)
.observeOn(MainScheduler.instance)
.flatMapLatest({ (response) -> Observable<[T]> in
if let items = response.result {
return Observable.just(items)
}
return Observable.error(RxError.unknown)
})
}
}
Hi @khoren93 That lines code in bindViewModel function, it makes view show pull to refresh animation when view will appear. I see you fixed on lastest version, but i cant find out . How can you do it ? Thanks so much.
let refresh = Observable.of(Observable.just(()), headerRefreshTrigger).merge() let input = HomeViewModel.Input(headerRefresh: refresh, footerRefresh: footerRefreshTrigger, selection: tableView.rx.modelSelected(HomeCellViewModel.self).asDriver())
Hi @illidandh I temporary disabled header refresh animation in viewWillAppear, because KafkaRefresh library sometimes triggered refresh event multiple times. I commented this line refreshControl.beginRefreshing() in file https://github.com/khoren93/SwiftHub/blob/master/SwiftHub/Extensions/RxSwift/KafkaRefresh%2BRx.swift
Hello @khoren93
I have a question about navigator
at RepositoriesViewController
When select Repository Cell, it will create RepositoryDetailViewController
and iject RepositoryDetailViewModel
. After that, show RepositoryDetailViewController
Here's the question. I expected that when RepositoryDetailViewController
was released from memory, RepositoryDetailViewModel
would also be released. But, RepositoryDetailViewModel
is not released, until a new repositorySelected
event occurs. Is it intended?
ViewModel is not released?
Hello @khoren93 I have a question about
navigator
at RepositoriesViewControllerWhen select Repository Cell, it will create
RepositoryDetailViewController
and ijectRepositoryDetailViewModel
. After that, showRepositoryDetailViewController
Here's the question. I expected that when
RepositoryDetailViewController
was released from memory,RepositoryDetailViewModel
would also be released. But,RepositoryDetailViewModel
is not released, until a newrepositorySelected
event occurs. Is it intended?
Hi, I have the same problem. How did you deal with it?
@khoren93 I am trying to enable default iOS back swipe gesture? using Hero transition. were able to achieve this with your case?
https://github.com/HeroTransitions/Hero/issues/243
Hi @alouanemed I enabled default iOS back swipe gesture. Please check out :) Thanks!
@khoren93 I've checked your last commits,It seems that It won't work as you enabled one-time swipe for FLEX/HERO.
@alouanemed It seems that the back gesture has a higher priority and Flex gesture doesn't work when the back gesture is triggered.
Aha, Can you elaborate about this?
Is there a TestFlight beta for this so that we can test out features or not?
Hi @Minion3665 , I do not use TestFlight, all the latest features are available on the Master branch :)
Hi! I noticed that the API Keys are published under the Config.swift file! Are these the keys of deployment as well? Because if so, you could run into issues with ill intentioned people. This also happens with the Firebase API Key in the GoogleServices-Info.plist.
I think your project is very good, I want to learn your project, but I don't know how to start, because I am not very familiar with rx.swift. Also I would like to have a project structure document.
in SwiftHub/Application/Navigator.swift
// MARK: - segues list, all app scenes
enum Scene {
case tabs(viewModel: HomeTabBarViewModel)
case search(viewModel: SearchViewModel)
case languages(viewModel: LanguagesViewModel)
case users(viewModel: UsersViewModel)
case userDetails(viewModel: UserViewModel)
case repositories(viewModel: RepositoriesViewModel)
case repositoryDetails(viewModel: RepositoryViewModel)
case contents(viewModel: ContentsViewModel)
case source(viewModel: SourceViewModel)
case commits(viewModel: CommitsViewModel)
case branches(viewModel: BranchesViewModel)
case releases(viewModel: ReleasesViewModel)
case pullRequests(viewModel: PullRequestsViewModel)
case pullRequestDetails(viewModel: PullRequestViewModel)
case events(viewModel: EventsViewModel)
case notifications(viewModel: NotificationsViewModel)
case issues(viewModel: IssuesViewModel)
case issueDetails(viewModel: IssueViewModel)
case linesCount(viewModel: LinesCountViewModel)
case theme(viewModel: ThemeViewModel)
case language(viewModel: LanguageViewModel)
case acknowledgements
case contacts(viewModel: ContactsViewModel)
case whatsNew(block: WhatsNewBlock)
case safari(URL)
case safariController(URL)
case webController(URL)
}
You define all of the scenes, and most of them has a initial Func with a ViewModel
, What's the purport or effect for that?
I don't understand the relationship between these two files, can you guide me?
Hi @wang22290 , The Api file is a protocol that describes all requests, and the RestApi and GraphApi files are the implementation of all these requests.
I think this example will be helpful
// File Api.swift
protocol SwiftHubAPI {
func repository(fullname: String, qualifiedName: String) -> Single<Repository>
}
// File RestApi.swift
class RestApi: SwiftHubAPI {
func repository(fullname: String, qualifiedName: String) -> Single<Repository> {
// implementation for Rest api
}
}
// File GraphApi.swift
class GraphApi: SwiftHubAPI {
func repository(fullname: String, qualifiedName: String) -> Single<Repository> {
// implementation for Graph api
}
}