ResearchKit / ResearchKit

ResearchKit is an open source software framework that makes it easy to create apps for medical research or for other research projects.
https://www.researchandcare.org
Other
5.6k stars 1.16k forks source link

Layout issue for inputs in ORKTaskView #774

Closed Geosef closed 8 years ago

Geosef commented 8 years ago

My team and I noticed issues with the layout of ORKTasks within ORKTaskViews in both sliders and text inputs. We have not tried other inputs to verify if they are affected or not.


This is text input prior to being tapped in the field: screen shot 2016-08-01 at 3 02 27 pm


Once tapped for input, the field and title both shrink: screen shot 2016-08-01 at 3 02 37 pm The placeholder text is cut off already.


This is after "12" has been entered: screen shot 2016-08-01 at 3 02 49 pm The field is so small you cannot see any input and the title is also cut off.


And after a medium length string of numbers: screen shot 2016-08-01 at 3 02 55 pm The title has reappeared, but the first few characters of the input are still cut off.


This is a slider with very short descriptions for min/max: screen shot 2016-08-01 at 3 08 56 pm


This is the same slider after being tapped for input: screen shot 2016-08-01 at 3 09 10 pm The slider is so small you can't change the value.


Finally, a slider with really long descriptions: screen shot 2016-08-01 at 3 09 24 pm


We believe a minimum width should be in place to handle text input and short descriptions on sliders. It may also be worthwhile looking into other inputs and seeing how they are affected.

YuanZhu-apple commented 8 years ago

@Geosef Assume you had some customization, can I see them in some sample code?

Geosef commented 8 years ago

I'm using ORKTaskViewController as a part of the Symptom tab in CareKit, per the CareKit sample application.

In OverviewViewController, I've added extensions for delegates for the symptom tracker and the task view.

extension OverviewViewController: OCKSymptomTrackerViewControllerDelegate {
    func symptomTrackerViewController(_ viewController: OCKSymptomTrackerViewController, didSelectRowWithAssessmentEvent assessmentEvent: OCKCarePlanEvent) {

        // Lookup the assessment the row represents.
        guard let activityType = ActivityType(rawValue: assessmentEvent.activity.identifier) else { return }
        guard let sampleAssessment = sampleData.activityWithType(type: activityType) as? Assessment else { return }
        /*
        Check if we should show a task for the selected assessment event
        based on its state.
        */
        guard assessmentEvent.state == .initial ||
            assessmentEvent.state == .notCompleted ||
            (assessmentEvent.state == .completed && assessmentEvent.activity.resultResettable) else { return }

        // Show an `ORKTaskViewController` for the assessment's task.
        let taskViewController = ORKTaskViewController(task: sampleAssessment.task(), taskRun: nil)
        taskViewController.delegate = self

        symptomTrackerNavController.pushViewController(taskViewController, animated: true)

    }
}

extension OverviewViewController: ORKTaskViewControllerDelegate {
    func taskViewController(_ taskViewController: ORKTaskViewController, didFinishWith reason: ORKTaskViewControllerFinishReason, error: NSError?) {

        guard reason == .completed else { return }
        guard let event = symptomTrackerViewController.lastSelectedAssessmentEvent,
            activityType = ActivityType(rawValue: event.activity.identifier),
            sampleAssessment = sampleData.activityWithType(type: activityType) as? Assessment else {return}

        let carePlanResult = sampleAssessment.buildResultForCarePlanEvent(event, taskResult: taskViewController.result)

        symptomTrackerViewController.store.update(event, with: carePlanResult, state: .completed) { (success, _, error) in
            if !success {
                print(error)
            }
        }

        symptomTrackerNavController.popViewController(animated: true)
    }

}

This is the only reference to the ORKTaskView in our app. No attempts for customization.

YuanZhu-apple commented 8 years ago

@Geosef taskViewController is supposed to be presented, instead of being pushed.

Geosef commented 8 years ago

We have changed taskViewController to now be presented/dismissed rather than pushed/popped; however, this did not affect the layout issue.

YuanZhu-apple commented 8 years ago

@Geosef That's weird. Are you using ResearchKit master or stable releases? Can you reproduce that in any of the ResearchKit sample/test apps?

Geosef commented 8 years ago

@YuanZhu-apple We are using 1.3.1 via CocoaPods. I could not reproduce the issue in either the ResearchKit sample app nor the CareKit sample app; however, our project is in iOS10 which could result in autolayout issues that I'm not 100% aware of. I tried converting the CareKit sample app to Swift 3/iOS 10, but it wasn't playing nice so I really couldn't test it.

Geosef commented 8 years ago

@YuanZhu-apple any update?

YuanZhu-apple commented 8 years ago

@Geosef ResearchKit is not officially support iOS 10 yet.

1) you can try the branch: https://github.com/ResearchKit/ResearchKit/tree/stable_xcode80_candidate 2) If you don't mind, please share a minimum iOS 10 project using RK 1.3.1, I can try to play it.

Geosef commented 8 years ago

@YuanZhu-apple We tried using both the CareKit and ResearchKit 'stable_xcode80_candidate' branches to no avail. We were able to reproduce the issue in a minimum project and have attached it.

CKRKDemo.zip

Geosef commented 8 years ago

@YuanZhu-apple any update?

YuanZhu-apple commented 8 years ago

@Geosef I confirm that this is an issue. Caused by https://github.com/ResearchKit/ResearchKit/blob/master/ResearchKit/Common/ORKVerticalContainerView.m#L655 It get fixed, once I change it to UILayoutPriorityDefaultHigh.

Can you verify that, and make a pull request for me?