Skip to content

Commit

Permalink
feat: Status Bar plugin (#58)
Browse files Browse the repository at this point in the history
* Add status bar

* edit plugin comment

* Add license

* update capacitor

* docgen

* fmt

* update deps

* docgen again

Co-authored-by: Dan Imhoff <dwieeb@gmail.com>
  • Loading branch information
jcesarmobile and imhoffd authored Oct 14, 2020
1 parent 3a65a9a commit 9a04a5d
Show file tree
Hide file tree
Showing 42 changed files with 2,274 additions and 0 deletions.
1 change: 1 addition & 0 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"network",
"screen-reader",
"share",
"status-bar",
"storage",
"text-zoom",
"toast"
Expand Down
2 changes: 2 additions & 0 deletions status-bar/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
dist
61 changes: 61 additions & 0 deletions status-bar/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# node files
dist
node_modules

# iOS files
Pods
Podfile.lock
Build
xcuserdata

# macOS files
.DS_Store



# Based on Android gitignore template: https://github.com/github/gitignore/blob/HEAD/Android.gitignore

# Built application files
*.apk
*.ap_

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin
gen
out

# Gradle files
.gradle
build

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation

# Android Studio captures folder
captures

# IntelliJ
*.iml
.idea

# Keystore files
# Uncomment the following line if you do not want to check your keystore files in.
#*.jks

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
2 changes: 2 additions & 0 deletions status-bar/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
dist
17 changes: 17 additions & 0 deletions status-bar/CapacitorStatusBar.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'json'

package = JSON.parse(File.read(File.join(__dir__, 'package.json')))

Pod::Spec.new do |s|
s.name = 'CapacitorStatusBar'
s.version = package['version']
s.summary = package['description']
s.license = package['license']
s.homepage = package['repository']['url']
s.author = package['author']
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
s.ios.deployment_target = '11.0'
s.dependency 'Capacitor'
s.swift_version = '5.1'
end
23 changes: 23 additions & 0 deletions status-bar/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Copyright 2020-present Ionic
https://ionic.io

MIT License

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
203 changes: 203 additions & 0 deletions status-bar/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
# @capacitor/status-bar

The StatusBar API Provides methods for configuring the style of the Status Bar, along with showing or hiding it.

<!--DOCGEN_INDEX_START-->
<div class="docgen docgen-index">

* [`setStyle(...)`](#setstyle)
* [`setBackgroundColor(...)`](#setbackgroundcolor)
* [`show(...)`](#show)
* [`hide(...)`](#hide)
* [`getInfo()`](#getinfo)
* [`setOverlaysWebView(...)`](#setoverlayswebview)
* [Interfaces](#interfaces)
* [Enums](#enums)

</div>
<!--DOCGEN_INDEX_END-->

<!--DOCGEN_API_START-->
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
<div class="docgen docgen-api">

## API

### setStyle(...)

```typescript
setStyle(options: StatusBarStyleOptions) => Promise<void>
```

Set the current style of the status bar.

| Param | Type |
| ------------- | ----------------------------------------------------------------------- |
| **`options`** | <code><a href="#statusbarstyleoptions">StatusBarStyleOptions</a></code> |

**Returns:** <code>Promise&lt;void&gt;</code>

**Since:** 1.0.0

--------------------


### setBackgroundColor(...)

```typescript
setBackgroundColor(options: StatusBarBackgroundColorOptions) => Promise<void>
```

Set the background color of the status bar.

This method is only supported on Android.

| Param | Type |
| ------------- | ------------------------------------------------------------------------------------------- |
| **`options`** | <code><a href="#statusbarbackgroundcoloroptions">StatusBarBackgroundColorOptions</a></code> |

**Returns:** <code>Promise&lt;void&gt;</code>

**Since:** 1.0.0

--------------------


### show(...)

```typescript
show(options?: StatusBarAnimationOptions | undefined) => Promise<void>
```

Show the status bar.

| Param | Type |
| ------------- | ------------------------------------------------------------------------------- |
| **`options`** | <code><a href="#statusbaranimationoptions">StatusBarAnimationOptions</a></code> |

**Returns:** <code>Promise&lt;void&gt;</code>

**Since:** 1.0.0

--------------------


### hide(...)

```typescript
hide(options?: StatusBarAnimationOptions | undefined) => Promise<void>
```

Hide the status bar.

| Param | Type |
| ------------- | ------------------------------------------------------------------------------- |
| **`options`** | <code><a href="#statusbaranimationoptions">StatusBarAnimationOptions</a></code> |

**Returns:** <code>Promise&lt;void&gt;</code>

**Since:** 1.0.0

--------------------


### getInfo()

```typescript
getInfo() => Promise<StatusBarInfoResult>
```

Get info about the current state of the status bar.

**Returns:** <code>Promise&lt;<a href="#statusbarinforesult">StatusBarInfoResult</a>&gt;</code>

**Since:** 1.0.0

--------------------


### setOverlaysWebView(...)

```typescript
setOverlaysWebView(options: StatusBarOverlaysWebviewOptions) => Promise<void>
```

Set whether or not the status bar should overlay the webview to allow usage
of the space underneath it.

This method is only supported on Android.

| Param | Type |
| ------------- | ------------------------------------------------------------------------------------------- |
| **`options`** | <code><a href="#statusbaroverlayswebviewoptions">StatusBarOverlaysWebviewOptions</a></code> |

**Returns:** <code>Promise&lt;void&gt;</code>

**Since:** 1.0.0

--------------------


### Interfaces


#### StatusBarStyleOptions

| Prop | Type | Description | Since |
| ----------- | --------------------------------------------------------- | ------------------------------------ | ----- |
| **`style`** | <code><a href="#statusbarstyle">StatusBarStyle</a></code> | Style of the text of the status bar. | 1.0.0 |


#### StatusBarBackgroundColorOptions

| Prop | Type | Description | Since |
| ----------- | ------------------- | ------------------------------------------------------------------------------------------- | ----- |
| **`color`** | <code>string</code> | A hex color to which the status bar color is set. This option is only supported on Android. | 1.0.0 |


#### StatusBarAnimationOptions

| Prop | Type | Description | Since |
| --------------- | ----------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | ----- |
| **`animation`** | <code><a href="#statusbaranimation">StatusBarAnimation</a></code> | The type of status bar animation used when showing or hiding. This option is only supported on iOS. | 1.0.0 |


#### StatusBarInfoResult

| Prop | Type | Description | Since |
| -------------- | --------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----- |
| **`visible`** | <code>boolean</code> | Whether the status bar is visible or not. | 1.0.0 |
| **`style`** | <code><a href="#statusbarstyle">StatusBarStyle</a></code> | The current status bar style. | 1.0.0 |
| **`color`** | <code>string</code> | The current status bar color. This option is only supported on Android. | 1.0.0 |
| **`overlays`** | <code>boolean</code> | Whether the statusbar is overlaid or not. This option is only supported on Android. | 1.0.0 |


#### StatusBarOverlaysWebviewOptions

| Prop | Type | Description | Since |
| ------------- | -------------------- | ----------------------------------------- | ----- |
| **`overlay`** | <code>boolean</code> | Whether to overlay the status bar or not. | 1.0.0 |


### Enums


#### StatusBarStyle

| Members | Value | Description | Since |
| ------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
| **`Dark`** | <code>'DARK'</code> | Light text for dark backgrounds. | 1.0.0 |
| **`Light`** | <code>'LIGHT'</code> | Dark text for light backgrounds. | 1.0.0 |
| **`Default`** | <code>'DEFAULT'</code> | On iOS 13 and newer the style is based on the device appearance. If the device is using Dark mode, the statusbar text will be light. If the device is using Light mode, the statusbar text will be dark. On iOS 12 and older the statusbar text will be dark. On Android the default will be the one the app was launched with. | 1.0.0 |


#### StatusBarAnimation

| Members | Value | Description | Since |
| ----------- | -------------------- | --------------------------------- | ----- |
| **`None`** | <code>'NONE'</code> | No animation during show/hide. | 1.0.0 |
| **`Slide`** | <code>'SLIDE'</code> | Slide animation during show/hide. | 1.0.0 |
| **`Fade`** | <code>'FADE'</code> | Fade animation during show/hide. | 1.0.0 |

</div>
<!--DOCGEN_API_END-->
1 change: 1 addition & 0 deletions status-bar/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
58 changes: 58 additions & 0 deletions status-bar/android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
ext {
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.12'
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.1.0'
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.1'
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.2.0'
}

buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
}
}

apply plugin: 'com.android.library'

android {
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 29
defaultConfig {
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 21
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

repositories {
google()
jcenter()
mavenCentral()
}


dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':capacitor-android')
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
}
Loading

0 comments on commit 9a04a5d

Please sign in to comment.