@@ -26,38 +26,34 @@ public struct WidgetNavigator {
26
26
// dismissible functionality
27
27
28
28
/// Pushes the widget onto the navigation stack in a new UIWidgetHostController.
29
- public func push( _ widget: Widget , animated: Bool = true ) {
29
+ public func push( _ widget: WidgetControllerType , animated: Bool = true ) {
30
30
let context = self . context. set ( presentation: . pushed)
31
- let viewController = UIWidgetHostController ( widget, with: context)
31
+ let viewController = widget. controller ( with: context)
32
32
navigationController? . pushViewController ( viewController, animated: animated)
33
33
}
34
34
35
35
/// Pushes the widget onto the navigation stack in a new UIWidgetHostController with a return value handler.
36
- public func push< ReturnType> ( _ widget: Widget , animated: Bool = true , onDismiss handler : @escaping WidgetDismissibleReturnHandler < ReturnType > ) {
37
- let context = self . context . set ( presentation : . pushed )
36
+ public func push< ReturnType> ( _ widget: WidgetControllerType , animated: Bool = true ,
37
+ onDismiss handler : @escaping WidgetDismissibleReturnHandler < ReturnType > ) {
38
38
let dismissible = WidgetDismissibleReturn < ReturnType > ( handler)
39
- let viewController = UIWidgetHostController ( widget, with: context, dismissible: dismissible)
39
+ let context = self . context. set ( presentation: . pushed) . set ( dismissible: dismissible)
40
+ let viewController = widget. controller ( with: context)
40
41
navigationController? . pushViewController ( viewController, animated: animated)
41
42
}
42
43
43
44
/// Presents a widget on the navigation stack in a new UIWidgetHostController.
44
- public func present( _ widget: Widget , animated: Bool = true ) {
45
+ public func present( _ widget: WidgetControllerType , animated: Bool = true ) {
45
46
let context = self . context. set ( presentation: . presented)
46
- let viewController = UIWidgetHostController ( widget, with: context)
47
+ let viewController = widget. controller ( with: context)
47
48
navigationController? . present ( viewController, animated: animated, completion: nil )
48
49
}
49
50
50
51
/// Presents a widget on the navigation stack in a new UIWidgetHostController with a return value handler.
51
- public func present< ReturnType> ( _ widget: Widget , animated: Bool = true , onDismiss handler : @escaping WidgetDismissibleReturnHandler < ReturnType > ) {
52
- let context = self . context . set ( presentation : . presented )
52
+ public func present< ReturnType> ( _ widget: WidgetControllerType , animated: Bool = true ,
53
+ onDismiss handler : @escaping WidgetDismissibleReturnHandler < ReturnType > ) {
53
54
let dismissible = WidgetDismissibleReturn < ReturnType > ( handler)
54
- let viewController = UIWidgetHostController ( widget, with: context, dismissible: dismissible)
55
- navigationController? . present ( viewController, animated: animated, completion: nil )
56
- }
57
-
58
- public func present( _ widget: WidgetController , animated: Bool = true ) {
59
- let context = self . context. set ( presentation: . alert)
60
- let viewController = widget. build ( with: context)
55
+ let context = self . context. set ( presentation: . presented) . set ( dismissible: dismissible)
56
+ let viewController = widget. controller ( with: context)
61
57
navigationController? . present ( viewController, animated: animated, completion: nil )
62
58
}
63
59
0 commit comments