fermoya / SwiftUIPager

Native Pager in SwiftUI
MIT License
1.29k stars 172 forks source link

Feat/justified alignment #54

Closed teameh closed 4 years ago

teameh commented 4 years ago

Hey @fermoya

In the PositionAlignment options I was missing one useful option, the option to align to the start at the first page and to the end at the last page. I thought it would be fun to try to figure out how to add this to your library and I found out it was actually fairly easy.

I'm not sure at all if this is something you would like to add, but I'm just putting this here for you to check out. Feel free to close it if you want to limit the functionality.

pager

I called it justified but feel free to rename it. Also added an example and some tests.

fermoya commented 4 years ago

Oh I see what it is, so it's similar to .center but the difference first and last pages should be on the edges, am I right? Sounds cool, I'll take a look at it. The name seems okay, to be fair I'm struggling myself with those.

I'll give it a try myself. Thanks, it looks cool!

teameh commented 4 years ago

Yes, exactly. 😊

Naming is always hard. Current naming seems fine right? Although you could make a case to follow HorizontalAlignment and go for .leading and .trailing

¯\(ツ)/¯

fermoya commented 4 years ago

Thanks! It looks awesome! I'll keep it on hold tho, to add more features/bugs to the next release.

Although you could make a case to follow HorizontalAlignment and go for .leading and .trailing

That was my intention at the time but then I implemented vertical pagers. So then it's not .leading and .trailing any longer, it should be .top and .bottom. In case of directions, I pass them as arguments in .vertical and .horizontal so I can have two different enums. Ideally, it would show .leading and .trailing (plus center and justified) if horizontal and .top and .bottom if vertical.

teameh commented 4 years ago

Ah yeah, that makes sense. Theoretically .leading is the same as .top when it's vertical right? Haha but I agree that would be confusing. Thanks for merging an I'm looking forward to the release.