Which approach to use MVVM or Static - mvvm

Im pretty new in using the MVVM architecture and looking for some advice on the "correct" to approach this task.
2 page app.
Page 1 displays the alphabet.
Page 2 displays the selected character's details.
Example - Select "A" and screen 2 displays apple, Apricot, Aprium. Select "B" screen 2 displays Banana, Blackberry, Blackcurrant, Blueberry.
Data is being retrieved from a web service everytime the user selects an alphabet character.
Would the correct approach be to create a static menu for screen 1 (as you would never have anything else other than the alphabet characters) and on the click event load the second screen with the items as above using the MVVM approach (i.e. pass in the selected character to the LoadItems method). Or is there a simpler way to do this using a MVVM structure?
Ive read around and its not very clear on when to use which approach but then again as i say im new with MVVM too and would like to learn the correct/preferred way so i can get a better understanding.

Another approach which maybe more in-keeping with the Windows Phone experience would be to have a single page containing a LongListSelector. Fruit bound to this view could then be grouped by letter. Implementing a JumpList would allow users to quickly navigate this list by jumping between groups. You can find a sample implementation here- http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj244365(v=vs.105).aspx

Microsoft actually prefers that when you use a list in windows phone it is always better to display it in another page. So you should populate the list in another page. And if you are selecting some thing to show then pass them as parameters using the NavigationService.Navigate or store the data in Phone Application State if you have to use app wide. Phone.Application.Resources . Its good that you are going through Mvvm You'll know Xaml, WP7,8, Get Metro Application Idea also Silverlight.
Heres a toolkit that might help you. It also displays the same way in a new Windows Not a popup
Long List Selector

Related

need consulting for a gui with 5 settings to be chosen by the user

I would like to let the user set 5 different settings. Each setting has a finite amount of values to choose (in my case : smaller, small, normal, large, very large)
I tried to use the UIPickerviews for this, but it needs a lot of space and I would like to have all on one page. I realized, that apple doesn't support simple dropdowns in IOS!?!?
following sample just shows only one setting and it fills up 1/3 of the screen.
In Android I managed to do this with simple dropdowns.
Any hints on how I could do this, without programming my own dropdown box ?
iOS does not have dropdowns as you say. I have created a custom control for my company that implements a dropdown. Some of my fellow iOS developers have yelled at me and said the dropdowns don't follow Apple's HIG. (You can take a look at our free app FaceDancer to see our dropdown control if you're interested.)
Apple uses picker views instead. What you can do is to have some sort of clickable element for each item (buttons for each one, e.g. "pick size", or make each field itself clickable) that displays a picker on top of the screen to let the user pick that value.
Note that there are large numbers of (both free and paid) third party frameworks offering all kinds of additional controls. I bet somebody has implemented a drop-in dropdown menu for iOS. Take a look at CocoaControls and search the iOS section for "dropdown". You can also look on Github and SourceForge.net.
I solved my problem by using a UISegmentedControl.
In my case with only 5 values, for me its the best choise. But for more then 10 values we have to use obviously external controls as Duncan mentoined.
var arraySizes5 = [sverysmall, ssmall, snormal, slarge, sverylarge];
var segmentcontrol_TextSizeTextViewer = UISegmentedControl();
segmentcontrol_TextSizeTextViewer = UISegmentedControl(items: arraySizes5);
self.view.addSubview(segmentcontrol_TextSizeTextViewer);

UIPageViewController/TextKit Multipage flow in SWIFT

Has anyone had any luck creating a multiple page view of document (one, NSTextStorage, one NSLayoutManager, and multiple NSTextContainers) in Swift. I'm having a lot of trouble finding example code not in objective C.
Basically, I'm trying to recreate the "Advanced Text Layouts and Effects with Text Kit" demo from WWDC 2013, but the whole thing is in Objective C and there is no sample code to be found. The post below seems to be having luck; but I'm having no luck translating...
UIPageViewController/TextKit Reflowing Text on paging
http://rshankar.com/quotes-app-simple-page-based-application-in-swift/
This uses the Page Based Application project template for a out-of-the-box working example, then customize for the model you want to use.
It use this same technique in my app by changing the root controller to what ever viewController I want it to be, coping the three files into my app, and all the magic is done for me.

GWT 2.1 MVP (Activities/Places) and Tabbed Displays [duplicate]

This question already has an answer here:
GWT 2.1 Places example without Activities
(1 answer)
Closed 3 years ago.
On an existing project we’re using MVP (hand crafted) reasonably well. It’s understood and does mostly what we need. For a new project I'm looking at using the MVP framework built into GWT 2.1 (Activities and Places).
Our applications are mostly tabbed displays with each tab bound to a single view widget.
I’ve tried to use Activities and Places without success for this type of display. Part of the problem is that the example Hello World article ended up leaving me chasing my tail, too many new concepts for my brain to digest.
The Hello World sample IMO is not a sufficient introduction and doesn’t deal with many of the real world use cases. I was hoping someone could point me in the direction of any sample applications that use MVP for tabbed displays. Thomas Broyer has some excellent posts on his blog but these have still left me a little perplexed.
Previously I’ve used an AppController to handle tabs changes and single presenters for each tab. The new architecture in GWT 2.1 leaves me more confused that it should.
I'm using the gwt Activities/Places framework for a tabbed display, and it works great, BUT: I decided to abandon the TabLayoutPanel widget we had been using and create my own navbar (that looks like tabs) and a content pane. The effect is the same - it looks identical - but the implementation is much cleaner.
I think the problem is in trying to mix Activities/Places, which has its own idea of navigation, with a TabPanel, which has another idea of navigation. At first I tried to throw them together, overriding tab button behavior to trigger a PlaceController, which in turn switched the tabs around, but... it was messy. With the independent navbar / content pane, the PlaceController could do everything just like it wanted to. You just have to manually switch the views, instead of letting a TabPanel do it for you.
I also faced this problem but managed to make it work using one activity per Tab and each activity using a presenter (or more) to display the components of the tab.
Regarding the solution found by Riley Lark, I, instead, opted by using a Decorator pattern and, so, keep the original TabbedPanel. How ? Each activity gets injected (GIN) a presenter that contains a decorator for the TabbedPanel.
So, for example:
Tab1Activity gets injected with Tab1Presenter, which, in turn, gets injected with Tab1Decorator which decorates the TabbedPanel with a Tab1ContentPanel (this panel contains all the widgets to be displayed on the Tab1 tab)
Tab2Activity gets injected with Tab2Presenter, which, in turn, gets injected with Tab2Decorator which decorates the same TabbedPanel with a Tab2ContentPanel (this panel contains all the widgets to be displayed on the Tab2 tab)
Seems complex but, after creating the first decorator, it really paid off and I was able to keep the TabbedPanel and take advantage of the URL history management implicit in the framework.

Iphone sdk - How to setup a 'template'

I've been working on a Cook Book App and I've been making each page individually which takes a really long time to do, I asked a question similar to this and it was brought to my attention that you can setup a way to automate the design process so all you need to do is input your data.
Can someone please explain in as much detail as possible how you setup your xcode files/code to automate such a process
So for example I would just enter the page text and it would automatically put my standard background picture in and add a scroll view and appropriate buttons etc.
Thanks
You could make one master view that contains all the controls that you need: standard background picture, scroll view, appropriate buttons, etc, and make any subsequent views that you create inherit from this view, so that they all contain those controls.
You could also use just one view and work with multiple instances of it, one instance per page. Just make sure to have a Text property on it, or a constructor that takes in your text string, so that you could set it to a different text on each page.
Xcode project templates and file templates are pretty easy to make, with a few caveats.
Check the answers to these questions:
Add new templates in Xcode
Change templates in XCode
Also take a gander at these handy tutorials:
Custom Xcode Templates
Xcode: How to customize the existing project templates
It sounds to me like your putting your data into your views (pages). That's a big design error. You need to employ the Model-View-Controller design pattern and separate your data from your views. That will make it easy to create one view (template) that you can reload with data to display each individual recipe.
The first thing to do is to separate your data from the view. You need to have the recipes stored in an array, dictionary, Core Data etc and then wrap that data in a dedicated object. The second thing to do is to create a dedicated view to display all the recipes. As the user moves from recipe to recipe the app will simply remove and add information to the same view as needed.
I would recommend Cocoa Recipes for Mac OS X: The Vermont Recipes, Second Edition because it addresses these issues and it uses a recipe type app as its example. It's for Cocoa but the basic principles apply to iPhone apps as well.

Is there an iPhone equivalent to the NSTokenField control?

In my app I want the user to type names into a UITextField (or equivalent) and then when they press return, it will put that word(s) in a blue bubble that's usually associated with tags. The cursor then moves to the end where they can add more "tags".
This can be seen when adding contacts in the To, CC & BCC fields in the Mail app, and also when selecting contacts in the Messages app.
How is this done? Is it something that's provided in the UIKit or available somewhere else?
Many thanks,
Michael
Venmo just open sourced their token field.
https://github.com/venmo/VENTokenField.git
edited:
The equivalent control in desktop Cocoa is an NSTokenField, but there doesn't seem to be an equivalent for Cocoa Touch.
Since iOS 13 there exists UISearchTextField.
https://developer.apple.com/documentation/uikit/uisearchtextfield
You can see that component in action in the Photos App.
That should fit for many use cases. By removing the leftView you can also get rid of the search icon.
But be aware: You can‘t mix text and tokens at various positions.
From the docs:
Tokens always occur contiguously before any text in the search field.
Adding this here for reference:
Feel free to check out TaggerKit (a library I made), it's more or less what OP was talking about. You can basically add tags functionality to your app by just adding a view and a couple of properties.
I dont think you can do it with any built in functionality in the SDK, never seen such a feature. What you could do however is implement it yourself, have some custom blue button with some text over it, and when the user hits return you can have some code that takes the text and returns you the button that you need, shouldnt be too bad to implement