SwiftHub icon indicating copy to clipboard operation
SwiftHub copied to clipboard

Discussion

Open khoren93 opened this issue 5 years ago • 26 comments

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

khoren93 avatar Dec 25 '18 13:12 khoren93

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

hollow-frenk avatar Jan 02 '19 20:01 hollow-frenk

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

khoren93 avatar Jan 03 '19 11:01 khoren93

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

hollow-frenk avatar Jan 03 '19 16:01 hollow-frenk

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.

khoren93 avatar Jan 03 '19 16:01 khoren93

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.

lukakerr avatar Feb 23 '19 09:02 lukakerr

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

khoren93 avatar Feb 23 '19 09:02 khoren93

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

lukakerr avatar Feb 23 '19 09:02 lukakerr

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 ?

illidandh avatar Feb 27 '19 10:02 illidandh

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

khoren93 avatar Feb 27 '19 12:02 khoren93

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

illidandh avatar May 03 '19 03:05 illidandh

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

khoren93 avatar May 03 '19 04:05 khoren93

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?

dev-yong avatar May 04 '19 01:05 dev-yong

ViewModel is not released?

SunShineLOL avatar Jun 24 '19 08:06 SunShineLOL

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?

SunShineLOL avatar Jun 24 '19 09:06 SunShineLOL

@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

alouanemed avatar Jul 06 '19 10:07 alouanemed

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

khoren93 avatar Jul 06 '19 13:07 khoren93

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

alouanemed avatar Jul 06 '19 15:07 alouanemed

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

khoren93 avatar Jul 06 '19 16:07 khoren93

Aha, Can you elaborate about this?

alouanemed avatar Jul 06 '19 17:07 alouanemed

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

Minion3665 avatar Aug 02 '19 19:08 Minion3665

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

khoren93 avatar Aug 03 '19 08:08 khoren93

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.

jhlake avatar Nov 24 '19 01:11 jhlake

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.

rgmyyw avatar Nov 25 '19 03:11 rgmyyw

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?

ShenYj avatar Aug 17 '21 01:08 ShenYj

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

wang22290 avatar Mar 14 '22 09:03 wang22290

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

khoren93 avatar Mar 14 '22 10:03 khoren93