Polymers help glasses turn to sunglasses at the flick of a switch