@nativescript-community/ui-snackbar 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/LICENSE +201 -0
- package/README.md +189 -2
- package/index-common.d.ts +26 -0
- package/index-common.js +48 -0
- package/index-common.js.map +1 -0
- package/index.android.d.ts +13 -0
- package/index.android.js +220 -0
- package/index.android.js.map +1 -0
- package/index.d.ts +100 -0
- package/index.ios.d.ts +15 -0
- package/index.ios.js +66 -0
- package/index.ios.js.map +1 -0
- package/package.json +49 -5
- package/platforms/android/include.gradle +6 -0
- package/platforms/android/java/com/nativescript/ui/snackbar/SnackCallback.java +38 -0
- package/platforms/android/native-api-usage.json +16 -0
- package/platforms/ios/build.xcconfig +3 -0
- package/platforms/ios/native-api-usage.json +12 -0
- package/platforms/ios/src/NSCLiquidToast.swift +83 -0
- package/tsconfig.tsbuildinfo +1 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## 1.0.0 (2026-10-18)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* Material 1.14 / Material 3 Expressive (wavy indicators) and edge-to-edge demo ([9fb8637](https://github.com/nativescript-community/ui-native-components/commit/9fb8637820b0c021677342a9bd95da33d3f2847c))
|
|
11
|
+
* native-api-usage.json for every package on Android and iOS ([cfd7dcc](https://github.com/nativescript-community/ui-native-components/commit/cfd7dcc4b996b02319cfacee233bc56c29df70e4))
|
|
12
|
+
* ui-* components, Material 3 on Android and native UIKit on iOS ([42e3ddd](https://github.com/nativescript-community/ui-native-components/commit/42e3dddb222da766c2eca35ee248dfda2e63172c))
|
|
13
|
+
* **ui-snackbar:** iOS snackbar with liquid-toasts (SwiftUI Liquid Glass) ([ec93fd7](https://github.com/nativescript-community/ui-native-components/commit/ec93fd7067b2a7b779bdf9a094c25a7ac8b22693))
|
|
14
|
+
* **ui-snackbar:** position option (top|bottom) on iOS ([a19bc8f](https://github.com/nativescript-community/ui-native-components/commit/a19bc8f5e4bf23ffc79de4022243f3b18f74c770))
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* **android:** rename native package, layouts and styles so they coexist with ui-material-* ([ff8c61e](https://github.com/nativescript-community/ui-native-components/commit/ff8c61e8c26ca2f7a85e4f7fefdd8d860c98bcc1))
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright {yyyy} {name of copyright owner}
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,190 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- ⚠️ This README has been generated from the file(s) "blueprint.md" ⚠️-->
|
|
2
|
+
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
4
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
5
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
6
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!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!!!!!!! -->
|
|
21
|
+
<h1 align="center">@nativescript-community/ui-snackbar</h1>
|
|
22
|
+
<p align="center">
|
|
23
|
+
<a href="https://npmcharts.com/compare/@nativescript-community/ui-snackbar?minimal=true"><img alt="Downloads per month" src="https://img.shields.io/npm/dm/@nativescript-community/ui-snackbar.svg" height="20"/></a>
|
|
24
|
+
<a href="https://www.npmjs.com/package/@nativescript-community/ui-snackbar"><img alt="NPM Version" src="https://img.shields.io/npm/v/@nativescript-community/ui-snackbar.svg" height="20"/></a>
|
|
25
|
+
</p>
|
|
2
26
|
|
|
3
|
-
|
|
27
|
+
<p align="center">
|
|
28
|
+
<b>SnackBar: Material 3 Snackbar on Android, liquid-toasts toast on iOS.</b></br>
|
|
29
|
+
<sub><sub>
|
|
30
|
+
</p>
|
|
31
|
+
|
|
32
|
+
<br />
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
| iOS | Android |
|
|
36
|
+
| --- | --- |
|
|
37
|
+
| <img src="https://github.com/nativescript-community/ui-native-components/raw/master/images/ui-snackbar-ios.png" height="500" /> | <img src="https://github.com/nativescript-community/ui-native-components/raw/master/images/ui-snackbar-android.png" height="500" /> |
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
[](#table-of-contents)
|
|
41
|
+
|
|
42
|
+
## Table of Contents
|
|
43
|
+
|
|
44
|
+
* [Installation](#installation)
|
|
45
|
+
* [Usage](#usage)
|
|
46
|
+
* [API](#api)
|
|
47
|
+
* [Demos and Development](#demos-and-development)
|
|
48
|
+
* [Repo Setup](#repo-setup)
|
|
49
|
+
* [Build](#build)
|
|
50
|
+
* [Demos](#demos)
|
|
51
|
+
* [Contributing](#contributing)
|
|
52
|
+
* [Update repo ](#update-repo-)
|
|
53
|
+
* [Update readme ](#update-readme-)
|
|
54
|
+
* [Update doc ](#update-doc-)
|
|
55
|
+
* [Publish](#publish)
|
|
56
|
+
* [modifying submodules](#modifying-submodules)
|
|
57
|
+
* [Questions](#questions)
|
|
58
|
+
|
|
59
|
+
| Android | iOS |
|
|
60
|
+
|---|---|
|
|
61
|
+
| `Snackbar` | liquid-toasts `LiquidToast` (bottom, with optional action button) |
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
[](#installation)
|
|
65
|
+
|
|
66
|
+
## Installation
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npm install @nativescript-community/ui-snackbar
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The Android components use **Material 3**: see the [repository README](https://github.com/nativescript-community/ui-native-components#installation) for the theme.
|
|
73
|
+
|
|
74
|
+
The iOS Swift package is declared by this plugin `nativescript.config.ts` (`ios.SPMPackages`) and bridged to JS by `platforms/ios/src/NSCLiquidToast.swift`: nothing to configure, but it needs a NativeScript CLI with plugin Swift Package Manager support, and it raises the app iOS deployment target to 17 and `SWIFT_VERSION` to 5 (`platforms/ios/build.xcconfig`). The liquid-toasts repository currently has no license file: check it fits your needs. On iOS `isRTL`, `view` and `anchorView` are ignored, and `position: 'top'` shows the toast at the top of the screen (below the status bar / Dynamic Island) instead of the bottom.
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
[](#usage)
|
|
78
|
+
|
|
79
|
+
## Usage
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
import { showSnack } from '@nativescript-community/ui-snackbar';
|
|
83
|
+
showSnack({ message: 'Saved', actionText: 'Undo' }).then((result) => {});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
[](#api)
|
|
88
|
+
|
|
89
|
+
## API
|
|
90
|
+
|
|
91
|
+
See `SnackBarOptions` in the typings: `message`, `actionText`, `hideDelay`, `textColor`, `backgroundColor`, `actionTextColor`...
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
[](#demos-and-development)
|
|
95
|
+
|
|
96
|
+
## Demos and Development
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
### Repo Setup
|
|
100
|
+
|
|
101
|
+
The repo uses submodules. If you did not clone with ` --recursive` then you need to call
|
|
102
|
+
```
|
|
103
|
+
git submodule update --init
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The package manager used to install and link dependencies must be `pnpm` or `yarn`. `npm` wont work.
|
|
107
|
+
|
|
108
|
+
To develop and test:
|
|
109
|
+
if you use `yarn` then run `yarn`
|
|
110
|
+
if you use `pnpm` then run `pnpm i`
|
|
111
|
+
|
|
112
|
+
**Interactive Menu:**
|
|
113
|
+
|
|
114
|
+
To start the interactive menu, run `npm start` (or `yarn start` or `pnpm start`). This will list all of the commonly used scripts.
|
|
115
|
+
|
|
116
|
+
### Build
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
npm run build.all
|
|
120
|
+
```
|
|
121
|
+
WARNING: it seems `yarn build.all` wont always work (not finding binaries in `node_modules/.bin`) which is why the doc explicitly uses `npm run`
|
|
122
|
+
|
|
123
|
+
### Demos
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
npm run demo.[ng|react|svelte|vue].[ios|android]
|
|
127
|
+
|
|
128
|
+
npm run demo.svelte.ios # Example
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Demo setup is a bit special in the sense that if you want to modify/add demos you dont work directly in `demo-[ng|react|svelte|vue]`
|
|
132
|
+
Instead you work in `demo-snippets/[ng|react|svelte|vue]`
|
|
133
|
+
You can start from the `install.ts` of each flavor to see how to register new demos
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
[](#contributing)
|
|
137
|
+
|
|
138
|
+
## Contributing
|
|
139
|
+
|
|
140
|
+
### Update repo
|
|
141
|
+
|
|
142
|
+
You can update the repo files quite easily
|
|
143
|
+
|
|
144
|
+
First update the submodules
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
npm run update
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Then commit the changes
|
|
151
|
+
Then update common files
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
npm run sync
|
|
155
|
+
```
|
|
156
|
+
Then you can run `yarn|pnpm`, commit changed files if any
|
|
157
|
+
|
|
158
|
+
### Update readme
|
|
159
|
+
```bash
|
|
160
|
+
npm run readme
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Update doc
|
|
164
|
+
```bash
|
|
165
|
+
npm run doc
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Publish
|
|
169
|
+
|
|
170
|
+
The publishing is completely handled by `lerna` (you can add `-- --bump major` to force a major release)
|
|
171
|
+
Simply run
|
|
172
|
+
```shell
|
|
173
|
+
npm run publish
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### modifying submodules
|
|
177
|
+
|
|
178
|
+
The repo uses https:// for submodules which means you won't be able to push directly into the submodules.
|
|
179
|
+
One easy solution is t modify `~/.gitconfig` and add
|
|
180
|
+
```
|
|
181
|
+
[url "ssh://git@github.com/"]
|
|
182
|
+
pushInsteadOf = https://github.com/
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
[](#questions)
|
|
187
|
+
|
|
188
|
+
## Questions
|
|
189
|
+
|
|
190
|
+
If you have any questions/issues/comments please feel free to create an issue or start a conversation in the [NativeScript Community Discord](https://nativescript.org/discord).
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { View } from '@nativescript/core';
|
|
2
|
+
import { SnackBarOptions } from './index';
|
|
3
|
+
export { SnackBarOptions } from './index';
|
|
4
|
+
export declare enum DismissReasons {
|
|
5
|
+
SWIPE = "swipe",
|
|
6
|
+
ACTION = "action",
|
|
7
|
+
TIMEOUT = "timeout",
|
|
8
|
+
MANUAL = "manual",
|
|
9
|
+
CONSECUTIVE = "consecutive",
|
|
10
|
+
UNKNOWN = "unknown"
|
|
11
|
+
}
|
|
12
|
+
export declare enum SnackBarAction {
|
|
13
|
+
ACTION = "action",
|
|
14
|
+
NONE = "none",
|
|
15
|
+
DISMISS = "dismiss"
|
|
16
|
+
}
|
|
17
|
+
export declare abstract class SnackBarBase {
|
|
18
|
+
_options: SnackBarOptions;
|
|
19
|
+
constructor(options?: SnackBarOptions);
|
|
20
|
+
simple(message: string, textColor?: string, backgroundColor?: string, maxLines?: number, isRTL?: boolean, view?: View): Promise<any>;
|
|
21
|
+
action(options: SnackBarOptions): any;
|
|
22
|
+
showSnack(options: SnackBarOptions): any;
|
|
23
|
+
abstract show(): any;
|
|
24
|
+
abstract dismiss(): any;
|
|
25
|
+
abstract initSnack(options: SnackBarOptions, resolve?: Function): any;
|
|
26
|
+
}
|
package/index-common.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export var DismissReasons;
|
|
2
|
+
(function (DismissReasons) {
|
|
3
|
+
DismissReasons["SWIPE"] = "swipe";
|
|
4
|
+
DismissReasons["ACTION"] = "action";
|
|
5
|
+
DismissReasons["TIMEOUT"] = "timeout";
|
|
6
|
+
DismissReasons["MANUAL"] = "manual";
|
|
7
|
+
DismissReasons["CONSECUTIVE"] = "consecutive";
|
|
8
|
+
DismissReasons["UNKNOWN"] = "unknown";
|
|
9
|
+
})(DismissReasons || (DismissReasons = {}));
|
|
10
|
+
export var SnackBarAction;
|
|
11
|
+
(function (SnackBarAction) {
|
|
12
|
+
SnackBarAction["ACTION"] = "action";
|
|
13
|
+
SnackBarAction["NONE"] = "none";
|
|
14
|
+
SnackBarAction["DISMISS"] = "dismiss";
|
|
15
|
+
})(SnackBarAction || (SnackBarAction = {}));
|
|
16
|
+
export class SnackBarBase {
|
|
17
|
+
constructor(options) {
|
|
18
|
+
this._options = options;
|
|
19
|
+
}
|
|
20
|
+
simple(message, textColor, backgroundColor, maxLines, isRTL, view) {
|
|
21
|
+
return this.showSnack({
|
|
22
|
+
message,
|
|
23
|
+
textColor,
|
|
24
|
+
backgroundColor,
|
|
25
|
+
maxLines,
|
|
26
|
+
isRTL,
|
|
27
|
+
view
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
action(options) {
|
|
31
|
+
return this.showSnack(options);
|
|
32
|
+
}
|
|
33
|
+
showSnack(options) {
|
|
34
|
+
// if (!options) {
|
|
35
|
+
// options = this._options;
|
|
36
|
+
// }
|
|
37
|
+
this._options = options;
|
|
38
|
+
// return new Promise((resolve, reject) => {
|
|
39
|
+
// try {
|
|
40
|
+
// this.initSnack(options, resolve);
|
|
41
|
+
return this.show();
|
|
42
|
+
// } catch (ex) {
|
|
43
|
+
// reject(ex);
|
|
44
|
+
// }
|
|
45
|
+
// });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=index-common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-common.js","sourceRoot":"","sources":["../../src/ui-snackbar/index-common.ts"],"names":[],"mappings":"AAKA,MAAM,CAAN,IAAY,cAOX;AAPD,WAAY,cAAc;IACtB,iCAAe,CAAA;IACf,mCAAiB,CAAA;IACjB,qCAAmB,CAAA;IACnB,mCAAiB,CAAA;IACjB,6CAA2B,CAAA;IAC3B,qCAAmB,CAAA;AACvB,CAAC,EAPW,cAAc,KAAd,cAAc,QAOzB;AAED,MAAM,CAAN,IAAY,cAIX;AAJD,WAAY,cAAc;IACtB,mCAAiB,CAAA;IACjB,+BAAa,CAAA;IACb,qCAAmB,CAAA;AACvB,CAAC,EAJW,cAAc,KAAd,cAAc,QAIzB;AAED,MAAM,OAAgB,YAAY;IAE9B,YAAY,OAAyB;QACjC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC5B,CAAC;IAEM,MAAM,CAAC,OAAe,EAAE,SAAkB,EAAE,eAAwB,EAAE,QAAiB,EAAE,KAAe,EAAE,IAAW;QACxH,OAAO,IAAI,CAAC,SAAS,CAAC;YAClB,OAAO;YACP,SAAS;YACT,eAAe;YACf,QAAQ;YACR,KAAK;YACL,IAAI;SACP,CAAC,CAAC;IACP,CAAC;IAEM,MAAM,CAAC,OAAwB;QAClC,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAEM,SAAS,CAAC,OAAwB;QACrC,kBAAkB;QAClB,+BAA+B;QAC/B,IAAI;QACJ,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,4CAA4C;QAC5C,QAAQ;QACR,oCAAoC;QACpC,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;QACnB,iBAAiB;QACjB,cAAc;QACd,IAAI;QACJ,MAAM;IACV,CAAC;CAIJ"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DismissReasons, SnackBarAction, SnackBarBase, SnackBarOptions } from './index-common';
|
|
2
|
+
export { DismissReasons, SnackBarAction };
|
|
3
|
+
export declare class SnackBar extends SnackBarBase {
|
|
4
|
+
private static _SNACKBAR_TEXT_ID;
|
|
5
|
+
get SNACKBAR_TEXT_ID(): any;
|
|
6
|
+
private _snackbar;
|
|
7
|
+
private _snackbarCallback;
|
|
8
|
+
constructor(options?: SnackBarOptions);
|
|
9
|
+
initSnack(options: SnackBarOptions, resolve?: Function): void;
|
|
10
|
+
show(): Promise<unknown>;
|
|
11
|
+
dismiss(): Promise<unknown>;
|
|
12
|
+
}
|
|
13
|
+
export declare function showSnack(options: SnackBarOptions): any;
|
package/index.android.js
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { Color, Frame, Page } from '@nativescript/core';
|
|
2
|
+
import { DismissReasons, SnackBarAction, SnackBarBase } from './index-common';
|
|
3
|
+
export { DismissReasons, SnackBarAction };
|
|
4
|
+
function _getReason(value) {
|
|
5
|
+
switch (value) {
|
|
6
|
+
// Indicates that the Snackbar was dismissed via a swipe.
|
|
7
|
+
case com.google.android.material.snackbar.BaseTransientBottomBar.BaseCallback.DISMISS_EVENT_SWIPE:
|
|
8
|
+
return DismissReasons.SWIPE;
|
|
9
|
+
// Indicates that the Snackbar was dismissed via an action click.
|
|
10
|
+
case com.google.android.material.snackbar.BaseTransientBottomBar.BaseCallback.DISMISS_EVENT_ACTION:
|
|
11
|
+
return DismissReasons.ACTION;
|
|
12
|
+
// Indicates that the Snackbar was dismissed via a swipe.
|
|
13
|
+
case com.google.android.material.snackbar.BaseTransientBottomBar.BaseCallback.DISMISS_EVENT_TIMEOUT:
|
|
14
|
+
return DismissReasons.TIMEOUT;
|
|
15
|
+
// Indicates that the Snackbar was dismissed via a call to dismiss().
|
|
16
|
+
case com.google.android.material.snackbar.BaseTransientBottomBar.BaseCallback.DISMISS_EVENT_MANUAL:
|
|
17
|
+
return DismissReasons.MANUAL;
|
|
18
|
+
// Indicates that the Snackbar was dismissed from a new Snackbar being shown.
|
|
19
|
+
case com.google.android.material.snackbar.BaseTransientBottomBar.BaseCallback.DISMISS_EVENT_CONSECUTIVE:
|
|
20
|
+
return DismissReasons.CONSECUTIVE;
|
|
21
|
+
default:
|
|
22
|
+
return DismissReasons.UNKNOWN;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function getMaterialR(rtype, field) {
|
|
26
|
+
return +java.lang.Class.forName('com.google.android.material.R$' + rtype)
|
|
27
|
+
.getDeclaredField(field)
|
|
28
|
+
.get(null);
|
|
29
|
+
}
|
|
30
|
+
export class SnackBar extends SnackBarBase {
|
|
31
|
+
get SNACKBAR_TEXT_ID() {
|
|
32
|
+
if (!SnackBar._SNACKBAR_TEXT_ID) {
|
|
33
|
+
SnackBar._SNACKBAR_TEXT_ID = getMaterialR('id', 'snackbar_text');
|
|
34
|
+
}
|
|
35
|
+
return SnackBar._SNACKBAR_TEXT_ID;
|
|
36
|
+
}
|
|
37
|
+
constructor(options) {
|
|
38
|
+
super(options);
|
|
39
|
+
}
|
|
40
|
+
initSnack(options, resolve) {
|
|
41
|
+
options.hideDelay = options.hideDelay ? options.hideDelay : 3000;
|
|
42
|
+
let attachView = options.view;
|
|
43
|
+
if (!attachView) {
|
|
44
|
+
attachView = Frame.topmost().currentPage;
|
|
45
|
+
const modalViews = attachView._getRootModalViews();
|
|
46
|
+
if (modalViews.length) {
|
|
47
|
+
attachView = modalViews[modalViews.length - 1];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const page = (attachView instanceof Page ? attachView : attachView.page) || attachView;
|
|
51
|
+
let nView = page instanceof Page ? page.nativeViewProtected?.getParent() : attachView.nativeViewProtected;
|
|
52
|
+
if (!nView) {
|
|
53
|
+
console.warn(`the snackbar parent ${page} is not loaded`);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
let nCoordinatorLayout = page.nCoordinatorLayout;
|
|
57
|
+
if (!nCoordinatorLayout && !(nView instanceof androidx.coordinatorlayout.widget.CoordinatorLayout) && nView instanceof android.view.ViewGroup) {
|
|
58
|
+
nCoordinatorLayout = new androidx.coordinatorlayout.widget.CoordinatorLayout(attachView._context);
|
|
59
|
+
if (options.view) {
|
|
60
|
+
const nAttachedView = options.view.nativeViewProtected;
|
|
61
|
+
const params = new android.widget.FrameLayout.LayoutParams(nAttachedView.getWidth(), nAttachedView.getHeight());
|
|
62
|
+
params.gravity = android.view.Gravity.BOTTOM;
|
|
63
|
+
const locationArray = Array.create('int', 2);
|
|
64
|
+
options.view.nativeViewProtected.getLocationOnScreen(locationArray);
|
|
65
|
+
params.bottomMargin = nView.getHeight() - locationArray[1] - nAttachedView.getHeight();
|
|
66
|
+
nView.addView(nCoordinatorLayout, params);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
nView.addView(nCoordinatorLayout, new android.view.ViewGroup.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT));
|
|
70
|
+
}
|
|
71
|
+
nView = nCoordinatorLayout;
|
|
72
|
+
}
|
|
73
|
+
this._snackbar = com.google.android.material.snackbar.Snackbar.make(nView, options.message, options.hideDelay);
|
|
74
|
+
if (options.anchorView) {
|
|
75
|
+
this._snackbar.setAnchorView(options.anchorView.nativeViewProtected);
|
|
76
|
+
}
|
|
77
|
+
// this._snackbar.setText(options.message);
|
|
78
|
+
// this._snackbar.setDuration(options.hideDelay);
|
|
79
|
+
// set text color of the TextView in the Android SnackBar
|
|
80
|
+
if (options.textColor && Color.isValid(options.textColor)) {
|
|
81
|
+
const color = (options.textColor instanceof Color ? options.textColor : new Color(options.textColor)).android;
|
|
82
|
+
if (this._snackbar.setTextColor) {
|
|
83
|
+
this._snackbar.setTextColor(color);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
const mainTextView = this._snackbar.getView().findViewById(this.SNACKBAR_TEXT_ID);
|
|
87
|
+
if (mainTextView) {
|
|
88
|
+
mainTextView.setTextColor(color);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// this._snackbar.setTextColor(color);
|
|
92
|
+
}
|
|
93
|
+
if (options.actionTextColor && Color.isValid(options.actionTextColor)) {
|
|
94
|
+
const color = (options.actionTextColor instanceof Color ? options.actionTextColor : new Color(options.actionTextColor)).android;
|
|
95
|
+
this._snackbar.setActionTextColor(color);
|
|
96
|
+
}
|
|
97
|
+
// set background color
|
|
98
|
+
if (options.backgroundColor && Color.isValid(options.backgroundColor)) {
|
|
99
|
+
const color = (options.backgroundColor instanceof Color ? options.backgroundColor : new Color(options.backgroundColor)).android;
|
|
100
|
+
const sbView = this._snackbar.getView();
|
|
101
|
+
sbView.setBackgroundColor(new Color(color).android);
|
|
102
|
+
}
|
|
103
|
+
// set maxLines for the textview
|
|
104
|
+
// https://github.com/Akylas/nativescript-snackbar/issues/33
|
|
105
|
+
if (options.maxLines) {
|
|
106
|
+
const sbView = this._snackbar.getView();
|
|
107
|
+
const tv = sbView.findViewById(this.SNACKBAR_TEXT_ID);
|
|
108
|
+
tv.setMaxLines(options.maxLines);
|
|
109
|
+
}
|
|
110
|
+
// set RTL for snackbar
|
|
111
|
+
// https://github.com/Akylas/nativescript-snackbar/issues/26
|
|
112
|
+
if (options.isRTL === true) {
|
|
113
|
+
const sbView = this._snackbar.getView();
|
|
114
|
+
const tv = sbView.findViewById(this.SNACKBAR_TEXT_ID);
|
|
115
|
+
tv.setLayoutDirection(android.view.View.LAYOUT_DIRECTION_RTL);
|
|
116
|
+
}
|
|
117
|
+
if (resolve) {
|
|
118
|
+
const that = new WeakRef(this);
|
|
119
|
+
const listener = new android.view.View.OnClickListener({
|
|
120
|
+
onClick: (args) => {
|
|
121
|
+
resolve({
|
|
122
|
+
command: SnackBarAction.ACTION,
|
|
123
|
+
reason: _getReason(1),
|
|
124
|
+
event: args
|
|
125
|
+
});
|
|
126
|
+
const owner = that?.get();
|
|
127
|
+
if (owner) {
|
|
128
|
+
if (owner._snackbarCallback) {
|
|
129
|
+
owner._snackbarCallback.cb = null;
|
|
130
|
+
owner._snackbarCallback = null;
|
|
131
|
+
}
|
|
132
|
+
owner._snackbar = null;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
// set the action text, click listener
|
|
137
|
+
this._snackbar.setAction(options.actionText, listener);
|
|
138
|
+
}
|
|
139
|
+
const cb = (this._snackbarCallback = new com.nativescript.ui.snackbar.SnackCallback());
|
|
140
|
+
const callbackListener = new com.nativescript.ui.snackbar.SnackCallback.SnackCallbackListener({
|
|
141
|
+
onDismissed(snackbar, event) {
|
|
142
|
+
// if the dismiss was not caused by the action button click listener
|
|
143
|
+
const resolve = cb.resolve;
|
|
144
|
+
if (event !== com.google.android.material.snackbar.BaseTransientBottomBar.BaseCallback.DISMISS_EVENT_ACTION && resolve) {
|
|
145
|
+
resolve({
|
|
146
|
+
command: SnackBarAction.DISMISS,
|
|
147
|
+
reason: _getReason(event),
|
|
148
|
+
event
|
|
149
|
+
});
|
|
150
|
+
cb.resolve.resolve = null;
|
|
151
|
+
}
|
|
152
|
+
cb.nListener = null;
|
|
153
|
+
if (nCoordinatorLayout) {
|
|
154
|
+
const parent = nCoordinatorLayout.getParent();
|
|
155
|
+
// in case of the view being in background the parent might already be null
|
|
156
|
+
if (parent) {
|
|
157
|
+
parent.removeView(nCoordinatorLayout);
|
|
158
|
+
}
|
|
159
|
+
page.nCoordinatorLayout = null;
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
onShown(snackbar) { }
|
|
163
|
+
});
|
|
164
|
+
cb.setListener(callbackListener);
|
|
165
|
+
cb.nListener = callbackListener; // handles the resolve of the promise
|
|
166
|
+
cb.resolve = resolve; // handles the resolve of the promise
|
|
167
|
+
this._snackbar.addCallback(cb);
|
|
168
|
+
}
|
|
169
|
+
show() {
|
|
170
|
+
return new Promise((resolve, reject) => {
|
|
171
|
+
try {
|
|
172
|
+
// if (!this._snackbar) {
|
|
173
|
+
this.initSnack(this._options, resolve);
|
|
174
|
+
// }
|
|
175
|
+
if (this._snackbar && !this._snackbar.isShown()) {
|
|
176
|
+
this._snackbar.show();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
catch (ex) {
|
|
180
|
+
reject(ex);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
// if (!this._snackbar) {
|
|
184
|
+
// this.initSnack(this._options);
|
|
185
|
+
// }
|
|
186
|
+
// if (this._snackbar && !this._snackbar.isShown()) {
|
|
187
|
+
// this._snackbar.show();
|
|
188
|
+
// }
|
|
189
|
+
}
|
|
190
|
+
dismiss() {
|
|
191
|
+
return new Promise((resolve, reject) => {
|
|
192
|
+
if (this._snackbar) {
|
|
193
|
+
try {
|
|
194
|
+
this._snackbar.dismiss();
|
|
195
|
+
// return AFTER the item is dismissed, 200ms delay
|
|
196
|
+
setTimeout(() => {
|
|
197
|
+
resolve({
|
|
198
|
+
action: SnackBarAction.DISMISS,
|
|
199
|
+
reason: _getReason(3)
|
|
200
|
+
});
|
|
201
|
+
}, 200);
|
|
202
|
+
this._snackbar = null;
|
|
203
|
+
}
|
|
204
|
+
catch (ex) {
|
|
205
|
+
reject(ex);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
resolve({
|
|
210
|
+
action: SnackBarAction.NONE,
|
|
211
|
+
message: 'No actionbar to dismiss'
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
export function showSnack(options) {
|
|
218
|
+
return new SnackBar().showSnack(options);
|
|
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AC;IACP,CAAC;CACJ;AAED,MAAM,UAAU,SAAS,CAAC,OAAwB;IAC9C,OAAO,IAAI,QAAQ,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AAC7C,CAAC"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SnackBar component. Material Snackbar on Android, liquid-toasts (SwiftUI, Liquid Glass on iOS 26) on iOS.
|
|
3
|
+
* @module @nativescript-community/ui-snackbar
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { Color, View } from '@nativescript/core';
|
|
7
|
+
export { SnackBarAction, DismissReasons } from './index-common';
|
|
8
|
+
|
|
9
|
+
export declare class SnackBar {
|
|
10
|
+
/**
|
|
11
|
+
* Shows a simple SnackBar.
|
|
12
|
+
* @param {string} - The SnackBar text.
|
|
13
|
+
* @param {string} - The color of the snackbar text.backgroundColor
|
|
14
|
+
* @param {string} - The background color of the snackbar.
|
|
15
|
+
* @param {number} - The max lines for the text of the snackbar. * Android Only *
|
|
16
|
+
* @param {boolean} - Set RTL for the textview of the snackbar. * Android Only *
|
|
17
|
+
*/
|
|
18
|
+
simple(message: string, textColor?: string, backgroundColor?: string, maxLines?: number, isRTL?: boolean): Promise<any>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Show a SnackBar with Action
|
|
22
|
+
*/
|
|
23
|
+
action(options: SnackBarOptions): Promise<any>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Manually Dismiss an active SnackBar.
|
|
27
|
+
*/
|
|
28
|
+
dismiss(): Promise<any>;
|
|
29
|
+
|
|
30
|
+
showSnack(options: SnackBarOptions): Promise<{
|
|
31
|
+
action: SnackBarAction;
|
|
32
|
+
reason: DismissReasons;
|
|
33
|
+
}>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function showSnack(options: SnackBarOptions);
|
|
37
|
+
|
|
38
|
+
export interface SnackBarOptions {
|
|
39
|
+
/**
|
|
40
|
+
* The action button text of the snackbar.
|
|
41
|
+
*/
|
|
42
|
+
actionText?: string;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The text of the snackbar.
|
|
46
|
+
*/
|
|
47
|
+
message: string;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Delay in ms to hide the snackbar.
|
|
51
|
+
* Note: iOS only allows a maximum of 10s. If the value is more than that for iOS, the hideDelay will be set to 10s
|
|
52
|
+
*/
|
|
53
|
+
hideDelay?: number;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Action Text Color of the snackbar.
|
|
57
|
+
*/
|
|
58
|
+
actionTextColor?: string | Color;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Text Color of the snackbar.
|
|
62
|
+
*/
|
|
63
|
+
textColor?: string | Color;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Background Color of the snackbar.
|
|
67
|
+
*/
|
|
68
|
+
backgroundColor?: string | Color;
|
|
69
|
+
/**
|
|
70
|
+
* *Android Only*
|
|
71
|
+
* Set the maxLines if you are displaying a long string of text and it will wrap.
|
|
72
|
+
*/
|
|
73
|
+
maxLines?: number;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* *Android Only*
|
|
77
|
+
* Use RTL for textview of snackbar.
|
|
78
|
+
*/
|
|
79
|
+
isRTL?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* *iOS Only*
|
|
82
|
+
* Where the snackbar is shown. Defaults to 'bottom'. The Android Material Snackbar is always at the bottom.
|
|
83
|
+
*/
|
|
84
|
+
position?: 'top' | 'bottom';
|
|
85
|
+
/**
|
|
86
|
+
* optional View to attach the snack to
|
|
87
|
+
*/
|
|
88
|
+
view?: View;
|
|
89
|
+
/**
|
|
90
|
+
* The view you want to "anchor the snack above".
|
|
91
|
+
* The snackbar will appear above that view
|
|
92
|
+
*/
|
|
93
|
+
anchorView?: View;
|
|
94
|
+
/**
|
|
95
|
+
* iOS function to ignore special case of presentedViewController
|
|
96
|
+
* like not wanting to show a snack inside a Popover
|
|
97
|
+
*/
|
|
98
|
+
iosIgnorePresentedViewController?: (controller) => boolean;
|
|
99
|
+
}
|
|
100
|
+
|
package/index.ios.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DismissReasons, SnackBarAction, SnackBarBase, SnackBarOptions } from './index-common';
|
|
2
|
+
export { DismissReasons, SnackBarAction };
|
|
3
|
+
/**
|
|
4
|
+
* iOS: toasts are drawn with liquid-toasts (https://github.com/SimplifyJobs/liquid-toasts, SwiftUI): Liquid Glass on iOS 26,
|
|
5
|
+
* frosted material before. The Swift package is declared in this plugin `nativescript.config.ts` and bridged by `NSCLiquidToast`.
|
|
6
|
+
* `maxLines` and `position` are applied; `isRTL`, `view` and `anchorView` are Android only.
|
|
7
|
+
*/
|
|
8
|
+
export declare class SnackBar extends SnackBarBase {
|
|
9
|
+
private _toast;
|
|
10
|
+
private _resolve;
|
|
11
|
+
show(): Promise<any>;
|
|
12
|
+
dismiss(): Promise<any>;
|
|
13
|
+
initSnack(options: SnackBarOptions, resolve?: Function): void;
|
|
14
|
+
}
|
|
15
|
+
export declare function showSnack(options: SnackBarOptions): any;
|
package/index.ios.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Color } from '@nativescript/core';
|
|
2
|
+
import { DismissReasons, SnackBarAction, SnackBarBase } from './index-common';
|
|
3
|
+
export { DismissReasons, SnackBarAction };
|
|
4
|
+
function getReason(value) {
|
|
5
|
+
switch (value) {
|
|
6
|
+
case 'timeout':
|
|
7
|
+
return DismissReasons.TIMEOUT;
|
|
8
|
+
case 'swipe':
|
|
9
|
+
return DismissReasons.SWIPE;
|
|
10
|
+
case 'action':
|
|
11
|
+
return DismissReasons.ACTION;
|
|
12
|
+
case 'replaced':
|
|
13
|
+
return DismissReasons.CONSECUTIVE;
|
|
14
|
+
case 'manual':
|
|
15
|
+
case 'tap':
|
|
16
|
+
case 'dismissAll':
|
|
17
|
+
return DismissReasons.MANUAL;
|
|
18
|
+
default:
|
|
19
|
+
return DismissReasons.UNKNOWN;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function toUIColor(color) {
|
|
23
|
+
return color ? (color instanceof Color ? color : new Color(color)).ios : null;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* iOS: toasts are drawn with liquid-toasts (https://github.com/SimplifyJobs/liquid-toasts, SwiftUI): Liquid Glass on iOS 26,
|
|
27
|
+
* frosted material before. The Swift package is declared in this plugin `nativescript.config.ts` and bridged by `NSCLiquidToast`.
|
|
28
|
+
* `maxLines` and `position` are applied; `isRTL`, `view` and `anchorView` are Android only.
|
|
29
|
+
*/
|
|
30
|
+
export class SnackBar extends SnackBarBase {
|
|
31
|
+
show() {
|
|
32
|
+
return new Promise((resolve) => {
|
|
33
|
+
this.initSnack(this._options, resolve);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
dismiss() {
|
|
37
|
+
const toast = this._toast;
|
|
38
|
+
if (!toast) {
|
|
39
|
+
return Promise.resolve({ action: SnackBarAction.NONE, command: SnackBarAction.NONE, message: 'No snackbar to dismiss' });
|
|
40
|
+
}
|
|
41
|
+
return new Promise((resolve) => {
|
|
42
|
+
const previous = this._resolve;
|
|
43
|
+
this._resolve = (result) => {
|
|
44
|
+
previous?.(result);
|
|
45
|
+
resolve(result);
|
|
46
|
+
};
|
|
47
|
+
toast.dismiss();
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
initSnack(options, resolve) {
|
|
51
|
+
this._resolve = resolve;
|
|
52
|
+
const hideDelay = options.hideDelay ?? 3000;
|
|
53
|
+
this._toast = NSCLiquidToast.showWithMessageActionTextDurationTextColorBackgroundColorActionColorMaxLinesTopOnActionOnDismiss(options.message, options.actionText || null, hideDelay / 1000, toUIColor(options.textColor), toUIColor(options.backgroundColor), toUIColor(options.actionTextColor), options.maxLines || 0, options.position === 'top', null, (reason) => {
|
|
54
|
+
this._toast = null;
|
|
55
|
+
// the action handler runs after the dismissal: the reason is the only reliable signal
|
|
56
|
+
const command = reason === 'action' ? SnackBarAction.ACTION : SnackBarAction.DISMISS;
|
|
57
|
+
const result = { action: command, command, reason: getReason(reason) };
|
|
58
|
+
this._resolve?.(result);
|
|
59
|
+
this._resolve = null;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export function showSnack(options) {
|
|
64
|
+
return new SnackBar().showSnack(options);
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=index.ios.js.map
|
package/index.ios.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.ios.js","sourceRoot":"","sources":["../../src/ui-snackbar/index.ios.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAmB,MAAM,gBAAgB,CAAC;AAC/F,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,CAAC;AAmB1C,SAAS,SAAS,CAAC,KAAa;IAC5B,QAAQ,KAAK,EAAE,CAAC;QACZ,KAAK,SAAS;YACV,OAAO,cAAc,CAAC,OAAO,CAAC;QAClC,KAAK,OAAO;YACR,OAAO,cAAc,CAAC,KAAK,CAAC;QAChC,KAAK,QAAQ;YACT,OAAO,cAAc,CAAC,MAAM,CAAC;QACjC,KAAK,UAAU;YACX,OAAO,cAAc,CAAC,WAAW,CAAC;QACtC,KAAK,QAAQ,CAAC;QACd,KAAK,KAAK,CAAC;QACX,KAAK,YAAY;YACb,OAAO,cAAc,CAAC,MAAM,CAAC;QACjC;YACI,OAAO,cAAc,CAAC,OAAO,CAAC;IACtC,CAAC;AACL,CAAC;AAED,SAAS,SAAS,CAAC,KAAsB;IACrC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,I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AS,CAAC,OAAO,CAAC,eAAe,CAAC,EAClC,SAAS,CAAC,OAAO,CAAC,eAAe,CAAC,EAClC,OAAO,CAAC,QAAQ,IAAI,CAAC,EACrB,OAAO,CAAC,QAAQ,KAAK,KAAK,EAC1B,IAAI,EACJ,CAAC,MAAM,EAAE,EAAE;YACP,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;YACnB,sFAAsF;YACtF,MAAM,OAAO,GAAG,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC;YACrF,MAAM,MAAM,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;YACvE,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAC;YACxB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACzB,CAAC,CACJ,CAAC;IACN,CAAC;CACJ;AAED,MAAM,UAAU,SAAS,CAAC,OAAwB;IAC9C,OAAO,IAAI,QAAQ,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AAC7C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@nativescript-community/ui-snackbar",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "SnackBar: Material 3 Snackbar on Android, liquid-toasts toast on iOS.",
|
|
5
|
+
"main": "./index",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"typings": "./index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"tsc": "cpy '**/*.d.ts' '../../packages/ui-snackbar' --parents --cwd=../../src/ui-snackbar && tsc --build",
|
|
10
|
+
"readme": "readme generate -c ../../tools/readme/blueprint.json",
|
|
11
|
+
"build": "npm run tsc && npm run readme",
|
|
12
|
+
"build.watch": "npm run tsc -- -w",
|
|
13
|
+
"build.all": "npm run build",
|
|
14
|
+
"clean": "bin/rimraf ./*.d.ts ./*.js ./*.js.map ./*.tsbuildinfo ./*.mjs ./*.mjs.map ./angular ./svelte ./vue* ./react"
|
|
15
|
+
},
|
|
16
|
+
"nativescript": {
|
|
17
|
+
"platforms": {
|
|
18
|
+
"android": "6.2.0",
|
|
19
|
+
"ios": "6.2.0"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"NativeScript",
|
|
24
|
+
"JavaScript",
|
|
25
|
+
"Android",
|
|
26
|
+
"iOS"
|
|
27
|
+
],
|
|
28
|
+
"author": {
|
|
29
|
+
"name": "Martin Guillon",
|
|
30
|
+
"email": "martin@akylas.fr"
|
|
31
|
+
},
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/nativescript-community/ui-native-components/issues"
|
|
34
|
+
},
|
|
35
|
+
"license": "Apache-2.0",
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://github.com/nativescript-community/ui-native-components/tree/master/packages/ui-snackbar#readme",
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "https://github.com/nativescript-community/ui-native-components.git",
|
|
43
|
+
"directory": "packages/ui-snackbar"
|
|
44
|
+
},
|
|
45
|
+
"readmeFilename": "README.md",
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@nativescript-community/ui-core": "^1.0.0"
|
|
48
|
+
},
|
|
49
|
+
"gitHead": "237dd97d2b9e0f62ea9d9810169bb800dd531f7b"
|
|
50
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
package com.nativescript.ui.snackbar;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import com.google.android.material.snackbar.Snackbar;
|
|
5
|
+
|
|
6
|
+
public class SnackCallback extends
|
|
7
|
+
com.google.android.material.snackbar.BaseTransientBottomBar.BaseCallback<com.google.android.material.snackbar.Snackbar> {
|
|
8
|
+
public interface SnackCallbackListener {
|
|
9
|
+
public void onDismissed(Snackbar snackbar, int event);
|
|
10
|
+
|
|
11
|
+
public void onShown(Snackbar snackbar);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
SnackCallbackListener listener;
|
|
15
|
+
|
|
16
|
+
public SnackCallback() {
|
|
17
|
+
super();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public void setListener(SnackCallbackListener listener) {
|
|
21
|
+
this.listener = listener;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@Override
|
|
25
|
+
public void onDismissed(Snackbar snackbar, int event) {
|
|
26
|
+
if (listener != null) {
|
|
27
|
+
listener.onDismissed(snackbar, event);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@Override
|
|
32
|
+
public void onShown(Snackbar snackbar) {
|
|
33
|
+
if (listener != null) {
|
|
34
|
+
listener.onShown(snackbar);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"uses": [
|
|
3
|
+
"android.view:Gravity",
|
|
4
|
+
"android.view:View",
|
|
5
|
+
"android.view:View.OnClickListener",
|
|
6
|
+
"android.view:ViewGroup",
|
|
7
|
+
"android.view:ViewGroup.LayoutParams",
|
|
8
|
+
"android.widget:FrameLayout.LayoutParams",
|
|
9
|
+
"android.widget:TextView",
|
|
10
|
+
"androidx.coordinatorlayout.widget:CoordinatorLayout",
|
|
11
|
+
"com.google.android.material.snackbar:BaseTransientBottomBar.BaseCallback",
|
|
12
|
+
"com.google.android.material.snackbar:Snackbar",
|
|
13
|
+
"com.nativescript.ui.snackbar:SnackCallback",
|
|
14
|
+
"com.nativescript.ui.snackbar:SnackCallback.SnackCallbackListener"
|
|
15
|
+
]
|
|
16
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import LiquidToasts
|
|
2
|
+
import SwiftUI
|
|
3
|
+
import UIKit
|
|
4
|
+
|
|
5
|
+
/// ObjC-visible facade over the Swift-only `LiquidToasts` package (https://github.com/SimplifyJobs/liquid-toasts),
|
|
6
|
+
/// used by `@nativescript-community/ui-snackbar` on iOS.
|
|
7
|
+
@objcMembers
|
|
8
|
+
@objc(NSCLiquidToast)
|
|
9
|
+
public class NSCLiquidToast: NSObject {
|
|
10
|
+
private var handle: LiquidToastHandle?
|
|
11
|
+
|
|
12
|
+
/// - Parameters:
|
|
13
|
+
/// - duration: seconds; `<= 0` keeps the toast until it is dismissed
|
|
14
|
+
/// - top: shows the toast at the top of the screen instead of the bottom
|
|
15
|
+
/// - onDismiss: called once with the dismiss reason raw value (`timeout`, `manual`, `swipe`, `action`, `tap`, ...)
|
|
16
|
+
public class func show(
|
|
17
|
+
message: String,
|
|
18
|
+
actionText: String?,
|
|
19
|
+
duration: Double,
|
|
20
|
+
textColor: UIColor?,
|
|
21
|
+
backgroundColor: UIColor?,
|
|
22
|
+
actionColor: UIColor?,
|
|
23
|
+
maxLines: Int,
|
|
24
|
+
top: Bool,
|
|
25
|
+
onAction: (() -> Void)?,
|
|
26
|
+
onDismiss: ((String) -> Void)?
|
|
27
|
+
) -> NSCLiquidToast {
|
|
28
|
+
let result = NSCLiquidToast()
|
|
29
|
+
MainActor.assumeIsolated {
|
|
30
|
+
var style: ToastStyleModel? = nil
|
|
31
|
+
if textColor != nil || backgroundColor != nil {
|
|
32
|
+
var s = ToastStyleModel()
|
|
33
|
+
if let textColor { s.foreground = toastColor(textColor) }
|
|
34
|
+
if let backgroundColor { s.background = toastColor(backgroundColor) }
|
|
35
|
+
style = s
|
|
36
|
+
}
|
|
37
|
+
var action: LiquidToastAction? = nil
|
|
38
|
+
if let actionText, !actionText.isEmpty {
|
|
39
|
+
action = LiquidToastAction(
|
|
40
|
+
label: actionText,
|
|
41
|
+
role: .primary,
|
|
42
|
+
color: actionColor.map { toastColor($0) }
|
|
43
|
+
) {
|
|
44
|
+
onAction?()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if top {
|
|
48
|
+
// the overlay is hosted in the NativeScript root controller whose safe area is empty: SwiftUI adds no top
|
|
49
|
+
// padding, so ask for the device inset (plus a gap) as extra padding to clear the status bar / Dynamic Island
|
|
50
|
+
let safeArea = LiquidToast.geometrySnapshot()["safeArea"] as? [String: Any]
|
|
51
|
+
let deviceTop = CGFloat((safeArea?["top"] as? NSNumber)?.doubleValue ?? 0)
|
|
52
|
+
var configuration = LiquidToast.configuration
|
|
53
|
+
configuration.safeArea.top = deviceTop * 2 + 8
|
|
54
|
+
LiquidToast.configure(configuration)
|
|
55
|
+
}
|
|
56
|
+
let handle = LiquidToast.show(
|
|
57
|
+
message,
|
|
58
|
+
style: style,
|
|
59
|
+
position: top ? .topCenter : .bottomCenter,
|
|
60
|
+
duration: duration > 0 ? .seconds(duration) : .persistent,
|
|
61
|
+
action: action,
|
|
62
|
+
maxLines: maxLines > 0 ? maxLines : nil
|
|
63
|
+
)
|
|
64
|
+
handle.onDismissed { reason in
|
|
65
|
+
onDismiss?(reason.rawValue)
|
|
66
|
+
}
|
|
67
|
+
result.handle = handle
|
|
68
|
+
}
|
|
69
|
+
return result
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public func dismiss() {
|
|
73
|
+
MainActor.assumeIsolated {
|
|
74
|
+
handle?.dismiss()
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@MainActor
|
|
79
|
+
private class func toastColor(_ color: UIColor) -> ToastColor {
|
|
80
|
+
let c = Color(uiColor: color)
|
|
81
|
+
return ToastColor(light: c, dark: c)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../../src/ui-snackbar/index-common.ts","../../src/ui-snackbar/index.android.ts","../../src/ui-snackbar/index.d.ts","../../src/ui-snackbar/index.ios.ts","../../references.d.ts","../../tools/references.d.ts","../../src/references.d.ts"],"version":"5.8.3"}
|