Material: clarification - switch properties

Created on 11 Apr 2017  路  8Comments  路  Source: CosmicMind/Material

it wasn't clear to me how to achieve this stretched look from looking through switch class.

screen shot 2017-04-11 at 12 34 28 pm

thus far
screen shot 2017-04-11 at 12 35 48 pm

help wanted

Most helpful comment

Yes, I have a prototype for a PopMenu. I am almost done the latest rebuild of the PageTabBarController, now being called TabMenuController. Once that is done, the PopMenu will probably be one of the next on the list to complete, alongside the BottomSheetController :)

All 8 comments

screen shot 2017-04-12 at 9 36 44 am

I can achieve making switch longer by changing these internal variable values. but need better way to over ride this. It does say it's open.... maybe I'll try subclassing it.
screen shot 2017-04-12 at 9 37 14 am

this seems to get the job done.


import Foundation
import Material

class MySwitch:Switch{
    open override var intrinsicContentSize: CGSize {
        switch switchSize {
        case .small:
            return CGSize(width: 44, height: 44)
        case .medium:
            return CGSize(width: 30, height: 30)
        case .large:
            return CGSize(width: 36, height: 36)
        }
    }

    /// Fix for tapping. 
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        super.touchesBegan(touches, with: event)
        print("touchesBegan")
        self.toggle()
    }
}

Another way you could do this is by using a Bar and setting the views to the rightViews, or really any side and then placing the Bar in the position you would like.

Hi Daniel, thanks for your hard work. Can I ask - did you ever attempt to do an expand menu from the kebab / overflow / more icon on timeline?

perhaps - maybe not production worthy - but just a crude gist you could share?

@johndpope You mean Expansion Panels ? If so, this is good, I will probably want to add these soon, they are quite useful. Thanks!

There are a bunch of new features coming. I am working on a way to help make the process of creating new components much easier and faster. Thank you for your support!

like a popup menu / but in a timeline / tableview /collectionview setting.
screen shot 2017-04-12 at 1 29 30 pm

Yes, I have a prototype for a PopMenu. I am almost done the latest rebuild of the PageTabBarController, now being called TabMenuController. Once that is done, the PopMenu will probably be one of the next on the list to complete, alongside the BottomSheetController :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jnystad picture jnystad  路  4Comments

shshalom picture shshalom  路  4Comments

posaninagendra picture posaninagendra  路  4Comments

ravigupta049 picture ravigupta049  路  5Comments

goribchat picture goribchat  路  5Comments