Skip to content
This repository has been archived by the owner on Jun 17, 2018. It is now read-only.

Navigation after switched to right tab moves to the right side. #371

Open
kunass2 opened this issue Nov 22, 2017 · 3 comments
Open

Navigation after switched to right tab moves to the right side. #371

kunass2 opened this issue Nov 22, 2017 · 3 comments

Comments

@kunass2
Copy link

kunass2 commented Nov 22, 2017

This is what i do in the app:

private struct PagingMenuControllerOptions: PagingMenuControllerCustomizable {
    var lazyLoadingPage: LazyLoadingPage {
        return .all
    }
    var backgroundColor: UIColor {
        return .clear
    }
    var componentType: ComponentType
}

private struct MenuItem: MenuItemViewCustomizable {
    private var title = "..."
    var horizontalMargin: CGFloat {
        return 15
    }
    var displayMode: MenuItemDisplayMode {
        return .text(title: MenuItemText(text: title,
                                         color: .lightGrey,
                                         selectedColor: .white,
                                         font: .contentTextLarge,
                                         selectedFont: .contentTextLarge))
    }
    init(title: String) {
        self.title = title
    }
}

private struct MenuOptions: MenuViewCustomizable {
    var backgroundColor: UIColor {
        return .clear
    }
    var selectedBackgroundColor: UIColor {
        return .clear
    }
    var height: CGFloat {
        return 27
    }
    var displayMode: MenuDisplayMode {
        return .standard(widthMode: .flexible, centerItem: false, scrollingMode: .scrollEnabledAndBouces)
    }
    var focusMode: MenuFocusMode {
        return .underline(height: 3, color: .white, horizontalPadding: 15, verticalPadding: 0)
    }
    var itemsOptions: [MenuItemViewCustomizable]
}

and this is how I implement it:

func setupPageMenu(with controllers: [UIViewController]) {
    let menuItems = controllers.map { MenuItem(title: $0.title ?? "...") }
    let menuOptions = MenuOptions(itemsOptions: menuItems)
    let options = PagingMenuControllerOptions(componentType: .all(menuOptions: menuOptions, pagingControllers: controllers))
    pageMenu = PagingMenuController(options: options)
    addSubview(pageMenu.view)
    pageMenu.view.snp.makeConstraints { make in
        make.bottom.equalToSuperview()
        make.top.equalTo(navigationBar.snp.bottom).offset(Constants.PageView.top)
        make.leading.equalTo(Constants.PageView.leading)
        make.trailing.equalTo(Constants.PageView.trailing)
    }
}

What is wrong. Why it moves to the right side?

@robertlechowicz
Copy link

Hi, I have similar problem, is there any way to change this behaviour?

@t
Copy link
Contributor

t commented Nov 22, 2017

I already made a fix and it was merged to master. #333

Unfortunately, it seems new version has not been released yet after it was merged. However, you can use master branch anyway.

If you use cocoapods, below should works.

pod 'PagingMenuController',:git => 'https://github.com/kitasuke/PagingMenuController.git'

@kunass2
Copy link
Author

kunass2 commented Nov 27, 2017

Why dont you release it to cocoapods? you need to change the tag to 2.3 and run pod trunk push

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

No branches or pull requests

3 participants