yannickl / Splitflap

A simple split-flap display for your Swift applications
http://cocoadocs.org/docsets/Splitflap
MIT License
1.08k stars 79 forks source link

Does not handle numbers in strings well #3

Closed HasanEdain closed 8 years ago

HasanEdain commented 8 years ago

In the example application replace the first element of the words array with: "0:00:60" private let words = ["0:00:60", "Bonsoir", "12h15", "Arrival"]

the result is that the left most character ONLY counts through the lower and upper case alphabet, then the numbers to 0. None of the right characters ever change from empty.

I would expect all elements to animate to the string.

yannickl commented 8 years ago

Hi,

Yes this is the expected behaviour here. Indeed, in the example the supported tokens are those of SplitflapTokens.AlphanumericAndSpace and so the splitflap is not able to "parse" your input string. The AlphanumericAndSpace does not support the colon. If you want to support it (plus all the alphanumeric ones) you should write something like that:

func tokensInSplitflap(splitflap: Splitflap) -> [String] {
  return ": abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".characters.map { String($0) }
}
HasanEdain commented 8 years ago

Thanks, that is much closer. Is there a way to change where the cut of the font happens per character? The ':' character is being cut close to the bottom of the top dot, which looks asymmetric.

yannickl commented 8 years ago

You can configure the split flap appearance by implementing the 'func splitflap(splitflap: Splitflap, builderForFlapAtIndex index: Int) -> FlapViewBuilder' method.

Sorry I'm in the metro so that's a bit complicated to be precise.