Skip to content

Commit 4595248

Browse files
authored
chore: Rename git repo + improve docs (#5)
* chore: use repo 'react-native-actions-shortcuts' * chore: remove log * chore: ignore .iml files * chore: rename android package + update gradle * chore: update ios example * chore: improve README * chore: add screenshots to example README
1 parent 3f79f2e commit 4595248

27 files changed

+79
-376
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ project.xcworkspace
3535
.gradle
3636
local.properties
3737
android.iml
38+
*.iml
3839

3940
# Cocoapods
4041
#

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ yarn test
5151

5252
To edit the Objective-C files, open `example/ios/ShortcutsExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > react-native-actions-shortcuts`.
5353

54-
To edit the Kotlin files, open `example/android` in Android studio and find the source files at `reactnativeshortcuts` under `Android`.
54+
To edit the Kotlin files, open `example/android` in Android studio and find the source files at `reactnativeactionsshortcuts` under `Android`.
5555

5656
### Commit message convention
5757

README.md

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# react-native-actions-shortcuts
22

3-
iOS Home screen Quick Actions & Android App Shortcuts for react-native
3+
iOS [Home screen Quick Actions](https://developer.apple.com/design/human-interface-guidelines/ios/system-capabilities/home-screen-actions/) & Android [App Shortcuts](https://developer.android.com/guide/topics/ui/shortcuts/creating-shortcuts) for react-native
44

55
## Installation
66

@@ -14,9 +14,11 @@ npm install react-native-actions-shortcuts
1414

1515
If you are using cocoapods - you may need to run `pod install` (from `ios` directory).
1616

17-
On iOS, Quick Actions are handled by your app's `UIApplicationDelegate`
18-
(`AppDelegate.m`) - you will therefore need to add the following code in your
19-
project's `` file.
17+
On iOS, Quick Actions are handled by the
18+
[`application:performActionForShortcutItem:completionHandler`](https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1622935-application?language=objc)
19+
method of your app's [`UIApplicationDelegate`](https://developer.apple.com/documentation/uikit/uiapplicationdelegate) (i.e. `AppDelegate.m`),
20+
so, you will therefore need to add the following code in your
21+
project's [`AppDelegate.m`](./example/ios/ShortcutsExample/AppDelegate.m)) file.
2022

2123
```objective-c
2224
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler {
@@ -30,9 +32,13 @@ Android doesn't require any additional setup.
3032

3133
## Usage
3234

33-
Check out the [Example project](./example/README.md).
35+
### Example project
3436

35-
Imports
37+
See the [Example project](./example/README.md) for a working demo.
38+
39+
### Documentation
40+
41+
#### Imports
3642

3743
```js
3844
// ...
@@ -45,14 +51,17 @@ import Shortcuts, { ShortcutItem } from "react-native-actions-shortcuts";
4551
// ...
4652
```
4753

48-
Get the initial shortcut that the app was launched with.
49-
On iOS this will be returned just once, subsequent calls will return `null`.
54+
#### Initial shortcut / action
55+
56+
Get the initial shortcut that the app was launched with. On iOS this will be returned just once, subsequent calls will return `null`.
5057

5158
```js
5259
const shortcutItem = await Shortcuts.getInitialShortcut();
5360
```
5461

55-
Listen to action invocations while app is running.
62+
#### Listen for shortcut / action invocations
63+
64+
Listen to shortcut / action invocations while app is running.
5665

5766
On iOS the listener is also called for the initial
5867
invocation, unless it was already received via `Shortcuts.getInitialShortcut()`.
@@ -73,6 +82,8 @@ ShortcutsEmitter.addListener("onShortcutItemPressed", handleShortcut);
7382
ShortcutsEmitter.removeListener("onShortcutItemPressed", handleShortcut);
7483
```
7584

85+
#### Set shortcuts
86+
7687
To set shortcuts (will replace existing dynamic actions / shortcuts)
7788

7889
```js
@@ -93,15 +104,18 @@ Shortcuts.setShortcuts([shortcutItem]);
93104
const shortcutItems = await Shortcuts.setShortcuts([shortcutItem]);
94105
```
95106

96-
To clear shortcuts
107+
#### Clear shortcuts
108+
109+
Clears all dynamic shortcuts.
97110

98111
```js
99112
Shortcuts.clearShortcuts();
100113
```
101114

102-
Get the current shortcuts.
115+
#### Get shortcuts
103116

104-
Some information may be lost, such as iconName, data
117+
Get the current shortcuts. Some information may be lost, such as iconName, data,
118+
etc.
105119

106120
```js
107121
const shortcutItems = await Shortcuts.getShortcuts();
@@ -113,19 +127,29 @@ To display icons with your shortcuts / actions you will need to add them to your
113127
project. Once added use the name of your iOS asset or Android drawable as the
114128
value for `iconName` above.
115129

116-
### iOS - Asset library
130+
### iOS - Asset catalog
117131

118-
Add new assets to your Asset library by importing either `png` (scalar) or
132+
Add new assets to your [Asset catalog](https://developer.apple.com/library/archive/documentation/ToolsLanguages/Conceptual/Xcode_Overview/AddingImages.html) by importing either `png` (scalar) or
119133
`pdf` (vector) files.
120134

135+
Refer
136+
[Custom Icons : Home Screen Quick Action Icon
137+
Size](https://developer.apple.com/design/human-interface-guidelines/ios/icons-and-images/custom-icons/)
138+
to learn about the dimensions and design specifications.
139+
121140
### Android - drawable
122141

123-
Add drawable resources to you Android project. In Android studio, choose:
142+
Add [drawable resources](https://developer.android.com/studio/write/resource-manager) to you Android project. In Android studio, choose:
124143

125144
- for vector icons (SVG / PDF): __File > New > Vector Asset__
126145

127146
- for scalar icons (PNG): __File > New > Image Asset__
128147

148+
Refer
149+
[App Shortcuts: Icon design
150+
guidelines](https://commondatastorage.googleapis.com/androiddevelopers/shareables/design/app-shortcuts-design-guidelines.pdf)
151+
to learn about the dimensions and design specifications.
152+
129153
## Contributing
130154

131155
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
}
99

1010
dependencies {
11-
classpath 'com.android.tools.build:gradle:3.2.1'
11+
classpath 'com.android.tools.build:gradle:3.5.3'
1212
// noinspection DifferentKotlinGradleVersion
1313
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1414
}

0 commit comments

Comments
 (0)