How to create a scrollable list for Watch OS that has a fixed size? - swift

I'm a beginner to Watch OS programming (I'm using Storyboard) and would like some help with scrollable lists.
I need to create a scrollable list of numbers (e.g. from 1 to 20) that changes when user uses scrolls with the crown. I know how to create it using a Table, but the problem is, I don't know how to contain it to a single area.
I have added a screenshot of the "Sleep Cycle" app that has a similar feature. I would like to do the exact same thing, but instead of time, I need to show a list of numbers.
Edit: Another example would be "Zero" where the hours field is scrollable:

Please check out this library and try to customize it as per your use case:
https://github.com/calda/WatchKitTimePicker

Related

How to have suggestions come up when filling in TextField?

I am new to IOS development. I am trying to add simple TextField for entering Occupation. I would like to show the user some matching suggestions as they user type (from a set of occupations that I already have). This is a very common usecase. Is there a idiomatic ways of doing this? In Android there is an AutoCompleteTextView in the standard view library which takes in an array of suggestions during initalization. I could not find anything similar in IOS.
You can use some 3rd party libraries available for Auto complete text field
but
the best and easy approach from my perspective is to use UITextField and at bottom add UITableview. So the concept is when you type any character in textfield you need to filter some data from tableview and reload tableview
Check the below link you can get the suitable answer from here...
Getting autocomplete to work in swift

I am making a calculator that keeps all the different sums on the screen using flutter. Not sure how to approach this

I have been trying not to have ask but I need some help. I am building my first flutter app. It's a calculator and I can get a basic one working without problems I am even getting it to evaluate with each key press, whether it be from my numbers widgets or by typing directly into the textfield.
I want to make it a bit different. I have tried to come up with the best way to do this but am not sure how. I want multiple sums to stay shown in the textfield(I presume if it needs editing I need to use a textfield) with the result attached. (i.e 2+6+4=12 then on a new line have another 6*6=36 etc.) At any time updating the textfield with the keypad must update all the sums on screen.
I have tried to do this using just one textfield (splitting the text and adding the sums to a list then calculating each and adding them back), however seems very cumbersome and I don't think this is the best approach. I have also made a Dynamic list of textfields , but found it difficult to index each textfield widget (dont think this is the correct approach) Im not asking for code but ideas as to which route to take. Your help would be appreciated.

How to create a virtualized, reorderable list with dynamic sizes, and animated item adding and removal in Flutter?

I need a flutter list package with the following features:
Only renders items in/near visible range (virtualized)
Supports different item heights.
Reorderable through drag and drop
When an item is dragged to the edge of the screen, the list scrolls
When items enter or exit, the list animates nicely
The package ReorderableListView.builder (https://api.flutter.dev/flutter/material/ReorderableListView/ReorderableListView.builder.html) supports 1,3 and 4. No support for 5. Reordering animation was bad for items with differing heights (2) when I tried it out.
The package implicitly_animated_reorderable_list
(https://pub.dev/packages/implicitly_animated_reorderable_list/changelog) supports 3 and 5. Nothing mentioned about 1 or 2 in its readme, and a comment from January here (Flutter: Reorderable AND Animated ListView - any idea?) suggests 4 is missing.
Looking for advice on how to achieve this:
An amazing package that can do all 5.
A way to add features of these different packages together somehow. Is that at all possible?
Advice on forking or not forking and just starting from scratch.
In regards to forking what in your opinion is the most/least trivial of these features to build from scratch?
I'm new to Flutter, so anything I don't know enough to ask about in relation to this subject is also greatly appreciated.
Own answer:
There really isn't a need for any plugins or forks. ReorderableListview.builder can be used to accomplish all 5.
Not sure how I botched the code that made me think ReorderableListView.builder wasn't handling different heights of items correctly, but whatever the glitch was (maybe related to keys?), I'm not able to reproduce it. Interesting that all the docs/tutorials I found only show statically sized list items when dynamically sized list items are no problem.
As for the animated exits and entrances (i.e. not letting the list items seem to jump up and down in a disorienting way), this is really trivial to do by animating height with AnimatedContainer. The existence of a separate AnimatedList widget and ImplicitlyAnimatedList plugin threw me off a bit.

NSToolbarFlexibleSpaceItem is constraint to NSSplitViewItem in Swift

Almost all macOS official apps have this toolbar's feature which the NSToolbarItem flexible space is constraint to NSSplitViewItem view. I first thought maybe there are 3 different sections on NSToolbar. But it just ONE toolbar. You can open Notes app and customize the toolbar.
The first flexible space is detected and moved along with first split view item.
The second flexible space is detected and moved along with the second split item.
The rest will be just normal flexible spaces.
If there only two flexible spaces, the second will act as normal flexible space. The same thing applies to one and or flexible space.
I guess this is how Apple configure the flexible space items.
I found this JWToolbarAdaptiveSpaceItem but it's removable and it cannot be replaced with flexible space item like Note apps does.
There is another stackoverflow's question (I couldn't find it now) asked about this but the answer is adding fake views and buttons which is not NSToolbar.
Thus, does anyone know how to achieve this?
(Sorry about my English)
As of macOS 11 Big Sur, this is handled by NSTrackingSeparatorToolbarItem, which interacts with the dividers of an NSSplitView. There is also a new navigational property on NSToolbarItem that can influence item locations.
I do not think there is a built-in way to do this on previous macOS versions.

Arrange GUI elements in WPF in a similar way to the applications on the iPhone

I would like to arrange UIControls in WPF in a similar way to the applications on the iPhone. They should be positioned on a grid, but a user should be able to drag them somewhere else, after releasing the mouse button (or the finger in case of an iPhone) the selected UIControl should snap back to the next position in the grid. The other UIElements should be rearranged automatically.
Further the user should also be connect two elements with a line or something.
I'm not experienced with WPF. The first question is if there is a container which is suitable for something (System.Windows.Controls.Grid ?) or if I have to extend canvas or somethig else for this.
I would like to know which elements from the WPF framework can be used and which elements I have to write myself.
For people who do not own an iPhone: http://www.youtube.com/watch?v=3omhu2AUWC8
Update
I've looked at AnimatedTilePanel in the BangOTricks examples (see below), this one explains how to create your own Panel and how to let it arrange things there.. However I still need an idea how to implement drag and drop correctly in this example..
Unfortunately, you'll have to write a lot of things yourself, as WPF doesn't automatically do what you're looking for.
For positioning the controls, you can use either UniformGrid or Grid. Assuming it's much like the iPhone video you showed, you can just use the UniformGrid with 4 columns and however many rows you need.
For the dragging animation, layout-wise, you could start by manipulating the RenderTransform property on whatever is being dragged, but you'll have to set a handler to check once you've met whatever threshold necessary to move into the another "cell" -- and at that point, you'll have to changed the order of the items in the tree.
Take a look at AnimatedTilePanel from Kevin's Bag-o-Tricks at:
http://j832.com/bagotricks/
It doesn't do everything you want but it will show you how to write a panel that animates its children when changing size or order.
New input to this old post in 09. Earlier this year (2012) someone has wrote a FluidWrapPanel and open sourced it. I tried it and it works like a charm - just like that on the iPhone menu.
You can also apply to other UI Elements or UserControl.