|
1 | | -import { Color, isIOS } from '@nativescript/core'; |
| 1 | +import { alert, Button, Color, EventData, GridLayout, isIOS, Label } from '@nativescript/core'; |
2 | 2 | import { Feedback, FeedbackPosition, FeedbackType } from '@valor/nativescript-feedback'; |
3 | 3 | import { DemoSharedBase } from '../utils'; |
4 | 4 |
|
@@ -142,4 +142,47 @@ export class DemoSharedNativescriptFeedback extends DemoSharedBase { |
142 | 142 | public hide(): void { |
143 | 143 | this.feedback.hide(); |
144 | 144 | } |
| 145 | + |
| 146 | + public showOverDialog(args: EventData): void { |
| 147 | + const page = (<Button>args.object).page; |
| 148 | + const grid = new GridLayout(); |
| 149 | + (<any>grid).rows = '*'; |
| 150 | + (<any>grid).columns = '*'; |
| 151 | + grid.height = 280; |
| 152 | + grid.width = 400; |
| 153 | + grid.backgroundColor = '#5d0239'; |
| 154 | + const label = new Label(); |
| 155 | + label.horizontalAlignment = 'center'; |
| 156 | + label.verticalAlignment = 'middle'; |
| 157 | + label.text = 'This is a dialog'; |
| 158 | + label.fontSize = 18; |
| 159 | + label.color = new Color('#FFFFFF'); |
| 160 | + grid.addChild(label); |
| 161 | + |
| 162 | + const dialog = page.showModal(grid, { |
| 163 | + context: null, |
| 164 | + fullscreen: false, |
| 165 | + animated: true, |
| 166 | + stretched: false, |
| 167 | + closeCallback: () => console.log('closed dialog'), |
| 168 | + }); |
| 169 | + |
| 170 | + grid.on('tap', () => page.closeModal()); |
| 171 | + |
| 172 | + setTimeout(async () => { |
| 173 | + await this.feedback.success({ |
| 174 | + title: 'Over dialog', |
| 175 | + titleSize: 17, |
| 176 | + messageSize: 14, |
| 177 | + message: "I'm configured to show over a modal presentation.", |
| 178 | + duration: 3000, |
| 179 | + titleFont: isIOS ? 'SourceSansPro-Bold' : 'SourceSansPro-Bold.otf', |
| 180 | + messageFont: isIOS ? 'Source Sans Pro' : 'SourceSansPro.otf', |
| 181 | + onTap: () => console.log('over dialog tapped'), |
| 182 | + android: { dialog }, |
| 183 | + }); |
| 184 | + console.log('closed toast'); |
| 185 | + setTimeout(() => dialog.closeModal(), 5000); |
| 186 | + }, 1000); |
| 187 | + } |
145 | 188 | } |
0 commit comments