-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(frame): add generic frame cleanup logic after modal dialog close (#…
- Loading branch information
1 parent
eb76a3b
commit 2704915
Showing
7 changed files
with
126 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { NavigatedData } from "tns-core-modules/ui/page"; | ||
import { View } from "tns-core-modules/ui/core/view"; | ||
import * as TKUnit from "../../TKUnit"; | ||
import { stack } from "tns-core-modules/ui/frame"; | ||
import { isAndroid } from "tns-core-modules/platform"; | ||
|
||
export function onNavigatedTo(args: NavigatedData) { | ||
TKUnit.assertEqual(stack().length, 2, "Host and tab modal frame should be instantiated at this point!"); | ||
// shownModally raised after page.NavigatedTo on iOS so we close modal there | ||
if (isAndroid) { | ||
(args.object as View).closeModal(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<Page backgroundColor="green" navigatedTo="onNavigatedTo"> | ||
|
||
<ActionBar class="action-bar"> | ||
<Label class="action-bar-title" text="Modal"></Label> | ||
</ActionBar> | ||
|
||
<Label text="Text" /> | ||
</Page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ShownModallyData } from "tns-core-modules/ui/core/view"; | ||
import { TabView } from "tns-core-modules/ui/tab-view/tab-view"; | ||
import * as TKUnit from "../../TKUnit"; | ||
import { stack } from "tns-core-modules/ui/frame"; | ||
import { isIOS } from "tns-core-modules/platform" | ||
|
||
export function onShownModally(args: ShownModallyData) { | ||
const tabView = <TabView>args.object; | ||
TKUnit.assertNotNull(tabView); | ||
if (args.context) { | ||
args.context.shownModally = true; | ||
} | ||
|
||
const hostFrame = stack()[0]; | ||
TKUnit.assertNotNull(hostFrame, "Host frame should not be null"); | ||
TKUnit.assertEqual(hostFrame.currentPage.modal, tabView, "hostFrame.currentPage.modal should be equal to the tabView instance on tabView.shownModally event handler."); | ||
|
||
// shownModally raised after page.NavigatedTo on iOS | ||
if (isIOS) { | ||
args.closeCallback("return value"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<TabView androidTabsPosition="bottom" shownModally="onShownModally"> | ||
<TabViewItem title="Modal First"> | ||
<Frame defaultPage="ui/page/modal-tab-page" /> | ||
</TabViewItem> | ||
<TabViewItem> | ||
<Frame /> | ||
</TabViewItem> | ||
<TabViewItem title="Modal Second"> | ||
<Label text="tab 2" /> | ||
</TabViewItem> | ||
</TabView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters