Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discussion #7

Open
khoren93 opened this issue Dec 25, 2018 · 26 comments
Open

Discussion #7

khoren93 opened this issue Dec 25, 2018 · 26 comments

Comments

@khoren93
Copy link
Owner

khoren93 commented Dec 25, 2018

Hello to all, and welcome to SwiftHub!
Write here all your questions, suggestions or feature requests.

@hollow-frenk
Copy link

Hello, I would like to translate the app in Italian, could you tell me which file to select and then translate?

@khoren93
Copy link
Owner Author

khoren93 commented Jan 3, 2019

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 :)

@hollow-frenk
Copy link

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 ...

@khoren93
Copy link
Owner Author

khoren93 commented Jan 3, 2019

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.

@lukakerr
Copy link

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.

@khoren93
Copy link
Owner Author

Hi @lukakerr
Thanks for suggestion, i updated tabs order, please check out))

@lukakerr
Copy link

Wow that was a very quick turnaround! Thanks, it looks good. I will await the next App Store release :)

@illidandh
Copy link

Hi @khoren93
im using Moya ObjectMapper but i have issues with my api like this
bmoliveira/Moya-ObjectMapper#65
do you have any solution ?

@khoren93
Copy link
Owner Author

khoren93 commented Feb 27, 2019

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)
            })
    }
}

@illidandh
Copy link

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())

@khoren93
Copy link
Owner Author

khoren93 commented May 3, 2019

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

@dev-yong
Copy link

dev-yong commented May 4, 2019

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?

@SunShineLOL
Copy link

ViewModel is not released?

@SunShineLOL
Copy link

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?

Hi, I have the same problem. How did you deal with it?

@alouanemed
Copy link

@khoren93 I am trying to enable default iOS back swipe gesture? using Hero transition. were able to achieve this with your case?

HeroTransitions/Hero#243

@khoren93
Copy link
Owner Author

khoren93 commented Jul 6, 2019

Hi @alouanemed
I enabled default iOS back swipe gesture. Please check out :)
Thanks!

@alouanemed
Copy link

alouanemed commented Jul 6, 2019

@khoren93
I've checked your last commits,It seems that It won't work as you enabled one-time swipe for FLEX/HERO.

@khoren93
Copy link
Owner Author

khoren93 commented Jul 6, 2019

@alouanemed
It seems that the back gesture has a higher priority and Flex gesture doesn't work when the back gesture is triggered.

@alouanemed
Copy link

Aha, Can you elaborate about this?

@Minion3665
Copy link

Is there a TestFlight beta for this so that we can test out features or not?

@khoren93
Copy link
Owner Author

khoren93 commented Aug 3, 2019

Hi @Minion3665 ,
I do not use TestFlight, all the latest features are available on the Master branch :)

@jhlake
Copy link

jhlake commented Nov 24, 2019

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.

@rgmyyw
Copy link

rgmyyw commented Nov 25, 2019

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.

@ShenYj
Copy link

ShenYj commented Aug 17, 2021

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?

@wang22290
Copy link

image
I don't understand the relationship between these two files, can you guide me?

@khoren93
Copy link
Owner Author

khoren93 commented Mar 14, 2022

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
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests