suicidesafetyplan / safetyplan-ios

Suicide Safety Plan is a free mobile application for suicide prevention.
MIT License
23 stars 10 forks source link

Safety plan view controller swift conversion #18

Closed shayneptorres closed 4 years ago

shayneptorres commented 4 years ago

Closes #15

Refactor Plan ViewControllers from objc into Swift.

Closes #19 Implement RealmDB for the data persistence layer

shayneptorres commented 4 years ago

@eddielement While refactoring into Swift, I had updated some of the views to be more consistent with iOS app UI. Namely, I made the entire rows tappable on instead of just a button on the SafetyPlanViewController. I also updated the look and functionality of the text fields used to update and edit all of the plan items (Warning Signs, Coping Strategies, etc). They now look and behave more consistently with what is expected from other iOS applications.

Feel free to comment and let me know what you like and dont like. I will update anything changes you deem not wanted.

eddielement commented 4 years ago

Wow! This all looks amazing!!! I love the changes you made to make it more consistent with iOS app UI - it feels much smoother and more natural. Only two things I found -

Minor bug: Upon updating from an old version when I had two contacts entered, the app thought I had all 10 contacts filled when I actually only had two. (It showed 8 empty bullet points). This was easily fixed just by entering the edit contacts page and closing it again.

Crisis page & iPads: The third tab was typically hidden for users on iPads (since they don't have calling or texting functionality). There are lots of potential solutions here - we could make it visible, but we should probably hide the Call and Text buttons. (Or maybe just the Text button, the Call button actually does work if they also have an iPhone).

shayneptorres commented 4 years ago

@eddielement Good catch on that migration bug, I will update that so it wont happen when moving from an older version to the newer one.

Regarding Crisis Page and iPads, I like the option of keeping it visible but hiding the call/text options if those actions are not available. I think it would be a helpful page to have available for all users.

Not sure if there is a way to detect if the action is available, but I can look into it

eddielement commented 4 years ago

@shayneptorres Sounds good! When those changes are in, happy to merge it in then push out an update (unless you want to wait for the Realm change is in before shipping this to real users, either way works for me).

shayneptorres commented 4 years ago

@eddielement Since I can actually include the Realm changes in with my next push. Since I will be dealing with how we show these saved items, it might just make sense to include it all with this PR.

shayneptorres commented 4 years ago

Finished adding the changes to migrate the data persistence layer from User defaults to RealmDB. There are a couple things to note.

1.) Getting Saved data from RealmDB

2.) Saving data to Realm DB

3.) Moving from UserDefaults to RealmDB.

4.) Realm Migrations

If you have any more questions, please do reach out. Im sure there is something important I am forgetting

eddielement commented 4 years ago

@shayneptorres Wow awesome job, I'm super impressed! Overall, this codebase is SO much better than the old one!!!

I went through the code and tested the app thoroughly, and the only thing I could find that causes an error is Plan -> Contacts -> Save causes the app to crash with the error "Property ‘safetyPlanItemTypeId’ not found in object of type RLMPersonalContact".

I'm excited to get this out there! :)

shayneptorres commented 4 years ago

Nice catch, it looks like I messed up with my refactor. Pushed up another commit that should fix that problem. I also found one spot on the CrisisViewController where I hadn't migrated from UserDefaults to Realm. This should do the trick

eddielement commented 4 years ago

@shayneptorres Just submitted the update to Apple, thanks for your work on this! :) I put a little shoutout for you in the update notes.

eddielement commented 4 years ago

@shayneptorres By the way, the update was accepted and we just got a new positive review.

"Way better than paper! I have recommended this several times to others & many different mental health professionals. I have received very positive feedback from them. The just plain love it!

I had & have outstanding mental health care by the VA. However, a safety plan on a sheet of paper, upon leaving the hospital or in the course of outpatient treatment, is not practical. It’ll get lost, destroyed in the laundry, the dog will eat it, it might be shredded accidentally, or just plain wear out. Most people carry around their cell phone. This app is easy to use, wise to have, has a great layout, & was thoughtfully designed.

I recommend you review your plan every 3 months & write down what changes you think your plan needs then review with your psychotherapist before updating it. If you don’t have the energy to devote to updating it (yes, depression can do that), talk it out every 3 months with your psychotherapist (you are worth it, darn it!). I would give this app 10 stars if that were possible."

shayneptorres commented 4 years ago

That is so cool! Good job @eddielement ! It is awesome to work on a project like this that will provide a real service to people. Thank you for allowing me to contribute.