How to expand iOS Today Widget by default? - ios

I'm setting [self.extensionContext setWidgetLargestAvailableDisplayMode:NCWidgetDisplayModeExpanded] in viewDidLoad and, as expected, I'm getting the "show more" button that toggles between compact and expanded widget mode.
When the widget starts, it's always in compact mode by default. How can I change that and make widget be in expanded mode when it starts?

It is impossible.
A widget should not take over the screen by default. It defeats the purpose of a widget. You should make the content you want to display to user minimum and small (like a brief info), and user should be able to expand to view more details. This is how Widget works as intended.

Related

Prevent default app opening on ios widget click

I have a widget made using widgetkit extension which have four tappable icons which opens specific screen in the app using deeplinks.
Link(destination: URL(string: deepLinkUrl)!) {
..... //tappable UI components
}
However, on tapping the area outside the icons, i.e the widget itself(the blank area), it opens the app by default. Is there any way to stop this default behaviour. Similar to Today widgets like whatsapp,snapchat

How to add Buttons to a iOS 14 Widget

I'm trying to add buttons to a widget having family type ".systemLarge". I want to execute some code without opening the app.
Anyone knows how to do that?
For example the Shortcuts App Widget includes buttons you can tap to execute a shortcut without opening the app.
Widgets are read only. The Shortcuts app is an exception.
https://developer.apple.com/documentation/widgetkit/creating-a-widget-extension
Widgets present read-only information and don’t support interactive elements such as scrolling elements or switches. WidgetKit omits interactive elements when rendering a widget’s content.
You can add Link controls on medium and large size widgets to get a button like behavior.
This won't allow you to create interactive widgets, which change their content by clicking elements inside the widgets.
But you will be able to tell which "link" was clicked based on the widgetUrl provided when your app gets activated through the widget.
See the chapter Respond to User Interactions here:
https://developer.apple.com/documentation/widgetkit/creating-a-widget-extension

How to immobilize widget layout when keyboard is open?

I am developing a Flutter App. In a specific screen, I have a Cupertino style text field. (The whole app is Cupertino, I have four TabBars below the screen). Whenever I click on the textfield, the virtual keyboard opens and all the widgets squeeze between the textfield and the keyboard (with yellow-black bands of course).
The widgets are Expandable rows and columns (Flexible also has the same result).
resizeToAvoidBottomPadding is disabled.
resizeToAvoidBottomInset does not have any functionality.
SingleChildScrollView does not work.
ListView is meaningless, since my widgets are stateless and static.
What I need is to have keyboard open on top of the current widgets, instead of moving them. This problem exists both in iOS and Android.
After couple of weeks, I finally reached the solution. Despite indicating 'resizeToAvoidBottomInset' as not working above, I was using that in one of the folders of tabs. However this should be added where you build the tabs.

Flutter Vertical Drawer

I'm new to flutter, and after doing some searching, can't find a widget similar to the Drawer for the top of the page coming down, instead of the left or right side of the page coming out. Is there such a widget or a way to create one?
Not an easy task, but Flutter is open source. You can create your own version of Scaffold and Drawer with a vertical orientation. Just copy and modify the source code.
As of this date the Drawer widget doesn't support this, and there is no 'Vertical Drawer' widget in the Flutter widget catalog.
Thankfully, Akshath Jain created a nice SlidingUpPanel widget which does the trick nicely. For my use case I just needed it to slide from the bottom. I haven't tested it myself, but there is a slideDirection property which you can set to SlideDirection.DOWN and it should do what you're asking for.

Is there a way/tool/framework to write test automation for individual UI elements on iOS? (whitebox)

I have an application and I want to test individual ui elements in the application from the inside. The purpose is to verify that display controls such as labels are displaying what they should and that touches trigger the correct results.
And I don't mean any E2E tests (I will use Appium for that), I'm looking for something that would allow me to open the app in a state that I need and test one element(if it is displayed correctly and if it behaves correctly - I will probably split these two actions into two separate tests).
For example:
Let's say I have an app that has a "Hello" button in the middle of the screen and upon clicking on that button a new screen opens that has two other buttons. One has label "Red" the other has label "Blue". If I click on "Red" the background of the application turns red and if I click the "Blue" button the background turns blue.
Now I want to write separate tests that would open the app on:
initial screen and check the "Hello" button is there
initial screen and check that clicking on the "Hello" button opens new screen
second screen and check that there is "Red" button
second screen and check that upon clicking on "Red" button the screen turns red
and so on..
I don't know how to call this testing but for me it sounds like "ui unit testing"
I know this is possible on Android using Espresso so I hope it is possible on iOS too.
Have you looked at the new UI Testing tools (XCUITest) in Xcode 7? With it, you would definitely be able to detect the presence of UI elements, and manipulate them (such as tapping on buttons). However, I'm not sure if you'd be able to confirm that the background view's color changed, unless you set the view's UIAccessibility value to include color information.
UI Testing overview: https://developer.apple.com/videos/play/wwdc2015-406/
potential limitations: https://medium.com/#larcus94/ui-testing-with-xcode-7-221d16bad276

Resources