Tipster is a tip calculator application for iOS.
Submitted by: Jonathan Stone
Time spent: 12.5 hours spent in total
The following required functionality is complete:
- User can enter a bill amount, choose a tip percentage, and see the tip and total values.
- Settings page to change the default tip percentage.
The following optional features are implemented:
- UI animations
- Remembering the bill amount across app restarts (if <10mins)
- Using locale-specific currency and currency thousands separators.
- Making sure the keyboard is always visible and the bill amount is always the first responder. This way the user doesn't have to tap anywhere to use this app. Just launch the app and start typing.
The following additional features are implemented:
- Custom icon
- Custom title image on navigation controller
- Custom launch screen
- Suppressed the keyboard animation on launch. Keyboard is always there and it was distracting.
- Added The Mood Slider.
- Are you a very generous person? 20% tip not enough to communicate your blossoming sense of generosity? Hit the Mood Slider to choose from up to 50% tips!
- In a crappy mood? 10% still too much tip to give out? You can probably calculate a zero percent tip on your own, but if you want to express your disdain with a nice low 2% tip, the mood slider will help you out there too.
Here's a walkthrough of implemented user stories:
GIF created with LiceCap.
-
Rounding: When converting the mood slider value (a double) to percentages (17%/22% etc.), the results didn't land exactly on a whole percentage value. Rounding off for displaying the percent value was straightforward with string formatting, but then the Tip amount would not match the displayed percentage; instead of 17%, the calculated percent value would be something like 17.124%. Solved by rounding the percent down to two decimal places, to match what is displayed in the UI.
-
Keyboard not coming back: With the code to automatically show the keyboard in the initial viewcontroller, after switching to the settings view, the keyboard would disappear when returning to the initial view. Solved by closing the keyboard before moving to the settings screen.
-
Changing the system locale doesn't change the bill amount text; if there's a decimal separator that doesn't apply to the new locale in the text, the tip won't be calculated. This could be fixed by detecting the locale change and translating the value accordingly, or just clearing out the bill text.
-
Tipster was coded as a quick prototype, so it lacks certain maintainability aspects. Were this a production app, here are some things I'd be keen to do:
- Test-driven development: Test-first coding so that all code is tested all the time.
- Better encapsulation: The ViewController.swift file is too large and does too much. Needs to be broken up. I'd separate the tip calculating code from the page navigation code more completely, and abstract out the concepts of the persistent keyboard and the short-term saving/restoring of the bill amount.
- Better encapsulation: I'd make TipPercentChooser into a component/control instead of a set of static functions.
- UI: I'd sure make it look a lot nicer.
- Responsiveness: This thing only works on one screen size.
- UX: The mood slider can result in the same percentages appearing twice (e.g. 2%, 2%, 3%). Instead of a scale, I'd use predefined sets of percentages for a fixed number of "moods" or personality types (judmental, forgiving, ??).
Copyright 2017 Jonathan Stone
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.