Skip to content

Commit 539512d

Browse files
authored
Merge pull request #2 from sitefinitysteve/master
iOS Enhancements, Cross platform functionality
2 parents 8a08aa8 + bdeb363 commit 539512d

File tree

17 files changed

+803
-145
lines changed

17 files changed

+803
-145
lines changed

.npmignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ screens/
44
*.log
55
*.ts
66
!index.d.ts
7-
!checkbox.d.ts
7+
!checkbox.d.ts
8+
!BEMCheckBox.d.ts

.vscode/launch.json

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Launch on iOS Device",
6+
"type": "nativescript",
7+
"platform": "ios",
8+
"request": "launch",
9+
"appRoot": "${workspaceRoot}",
10+
"sourceMaps": true,
11+
"diagnosticLogging": false,
12+
"emulator": false
13+
},
14+
{
15+
"name": "Attach on iOS Device",
16+
"type": "nativescript",
17+
"platform": "ios",
18+
"request": "attach",
19+
"appRoot": "${workspaceRoot}",
20+
"sourceMaps": true,
21+
"diagnosticLogging": false,
22+
"emulator": false
23+
},
24+
{
25+
"name": "Launch on iOS Emulator",
26+
"type": "nativescript",
27+
"platform": "ios",
28+
"request": "launch",
29+
"appRoot": "${workspaceRoot}",
30+
"sourceMaps": true,
31+
"diagnosticLogging": false,
32+
"emulator": true
33+
},
34+
{
35+
"name": "Attach on iOS Emulator",
36+
"type": "nativescript",
37+
"platform": "ios",
38+
"request": "attach",
39+
"appRoot": "${workspaceRoot}",
40+
"sourceMaps": true,
41+
"diagnosticLogging": false,
42+
"emulator": true
43+
},
44+
{
45+
"name": "Launch on Android Device",
46+
"type": "nativescript",
47+
"platform": "android",
48+
"request": "launch",
49+
"appRoot": "${workspaceRoot}",
50+
"sourceMaps": true,
51+
"diagnosticLogging": false,
52+
"emulator": false
53+
},
54+
{
55+
"name": "Launch on Android Emulator",
56+
"type": "nativescript",
57+
"platform": "android",
58+
"request": "launch",
59+
"appRoot": "${workspaceRoot}",
60+
"sourceMaps": true,
61+
"diagnosticLogging": false,
62+
"emulator": true
63+
},
64+
{
65+
"name": "Attach on Android Device",
66+
"type": "nativescript",
67+
"platform": "android",
68+
"request": "attach",
69+
"appRoot": "${workspaceRoot}",
70+
"sourceMaps": true,
71+
"diagnosticLogging": false,
72+
"emulator": false
73+
},
74+
{
75+
"name": "Attach on Android Emulator",
76+
"type": "nativescript",
77+
"platform": "android",
78+
"request": "attach",
79+
"appRoot": "${workspaceRoot}",
80+
"sourceMaps": true,
81+
"diagnosticLogging": false,
82+
"emulator": true
83+
}
84+
]
85+
}

BEMCheckBox.d.ts

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
2+
declare class BEMAnimationManager extends NSObject {
3+
4+
static alloc(): BEMAnimationManager; // inherited from NSObject
5+
6+
static new(): BEMAnimationManager; // inherited from NSObject
7+
8+
animationDuration: number;
9+
10+
constructor(); // inherited from NSObject
11+
12+
constructor(o: { animationDuration: number; });
13+
14+
fillAnimationWithBouncesAmplitudeReverse(bounces: number, amplitude: number, reverse: boolean): CAKeyframeAnimation;
15+
16+
morphAnimationFromPathToPath(fromPath: UIBezierPath, toPath: UIBezierPath): CABasicAnimation;
17+
18+
opacityAnimationReverse(reverse: boolean): CABasicAnimation;
19+
20+
self(): BEMAnimationManager; // inherited from NSObjectProtocol
21+
22+
strokeAnimationReverse(reverse: boolean): CABasicAnimation;
23+
}
24+
25+
declare const enum BEMAnimationType {
26+
27+
Stroke = 0,
28+
29+
Fill = 1,
30+
31+
Bounce = 2,
32+
33+
Flat = 3,
34+
35+
OneStroke = 4,
36+
37+
Fade = 5
38+
}
39+
40+
declare const enum BEMBoxType {
41+
42+
Circle = 0,
43+
44+
Square = 1
45+
}
46+
47+
declare class BEMCheckBox extends UIView {
48+
49+
static appearance(): BEMCheckBox; // inherited from UIAppearance
50+
51+
static appearanceForTraitCollection(trait: UITraitCollection): BEMCheckBox; // inherited from UIAppearance
52+
53+
static appearanceForTraitCollectionWhenContainedIn(trait: UITraitCollection, ContainerClass: typeof NSObject): BEMCheckBox; // inherited from UIAppearance
54+
55+
//static appearanceForTraitCollectionWhenContainedInInstancesOfClasses(trait: UITraitCollection, containerTypes: NSArray<typeof NSObject>): BEMCheckBox; // inherited from UIAppearance
56+
57+
static appearanceWhenContainedIn(ContainerClass: typeof NSObject): BEMCheckBox; // inherited from UIAppearance
58+
59+
//static appearanceWhenContainedInInstancesOfClasses(containerTypes: NSArray<typeof NSObject>): BEMCheckBox; // inherited from UIAppearance
60+
61+
animationDuration: number;
62+
63+
boxType: BEMBoxType;
64+
65+
delegate: BEMCheckBoxDelegate;
66+
67+
hideBox: boolean;
68+
69+
lineWidth: number;
70+
71+
minimumTouchSize: CGSize;
72+
73+
offAnimationType: BEMAnimationType;
74+
75+
on: boolean;
76+
77+
onAnimationType: BEMAnimationType;
78+
79+
onCheckColor: UIColor;
80+
81+
onFillColor: UIColor;
82+
83+
onTintColor: UIColor;
84+
85+
constructor(o: { coder: NSCoder; }); // inherited from NSCoding
86+
87+
constructor(o: { frame: CGRect; }); // inherited from UIView
88+
89+
reload(): void;
90+
91+
self(): BEMCheckBox; // inherited from NSObjectProtocol
92+
93+
setOnAnimated(on: boolean, animated: boolean): void;
94+
}
95+
96+
interface BEMCheckBoxDelegate extends NSObjectProtocol {
97+
98+
animationDidStopForCheckBox?(checkBox: BEMCheckBox): void;
99+
100+
didTapCheckBox?(checkBox: BEMCheckBox): void;
101+
}
102+
declare var BEMCheckBoxDelegate: {
103+
104+
prototype: BEMCheckBoxDelegate;
105+
};
106+
107+
declare var BEMCheckBoxVersionNumber: number;
108+
109+
//declare var BEMCheckBoxVersionString: interop.Reference<number>;
110+
111+
declare class BEMPathManager extends NSObject {
112+
113+
static alloc(): BEMPathManager; // inherited from NSObject
114+
115+
static new(): BEMPathManager; // inherited from NSObject
116+
117+
boxType: BEMBoxType;
118+
119+
lineWidth: number;
120+
121+
size: number;
122+
123+
constructor(); // inherited from NSObject
124+
125+
pathForBox(): UIBezierPath;
126+
127+
pathForCheckMark(): UIBezierPath;
128+
129+
pathForFlatCheckMark(): UIBezierPath;
130+
131+
pathForLongCheckMark(): UIBezierPath;
132+
133+
self(): BEMPathManager; // inherited from NSObjectProtocol
134+
}

README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
# NativeScript CheckBox :white_check_mark:
77
A NativeScript plugin for the native checkbox widget.
88

9-
** Android only - there is no concept of a checkbox on iOS. I'm looking to find a cocoapod to bring this plugin to both platforms. **
10-
119
#### Platform controls used:
1210
Android |
1311
---------- |
14-
[Android CheckBox](https://developer.android.com/reference/android/widget/CheckBox.html) |
15-
12+
[Android CheckBox](https://developer.android.com/reference/android/widget/CheckBox.html)
13+
iOS |
14+
---------- |
15+
[BEMCheckBox](http://cocoapods.org/pods/BEMCheckBox) |
1616

1717
## Sample Usage
1818

@@ -35,7 +35,7 @@ From your command prompt/terminal go to your app's root folder and execute:
3535
xmlns:CheckBox="nativescript-checkbox" loaded="pageLoaded">
3636
<ActionBar title="Native Checkbox" />
3737
<StackLayout>
38-
<CheckBox:CheckBox checked="{{ checkProp }}" text="{{ myCheckText }}" color="{{ myCheckColor }}" id="myCheckbox" />
38+
<CheckBox:CheckBox checked="{{ checkProp }}" text="{{ myCheckText }}" fillColor="{{ myCheckColor }}" id="myCheckbox" />
3939
<CheckBox:CheckBox text="CheckBox Label" checked="false" />
4040
</StackLayout>
4141
</Page>
@@ -62,11 +62,19 @@ public getCheckProp() {
6262

6363
- **checked** - boolean
6464
- **text** - text to use with the checkbox
65+
- **fillColor** - Color of the checkbox element
6566

6667
## API
6768

6869
- **toggle()** - Change the checked state of the view to the inverse of its current state.
6970

70-
## Styling
71+
## Css Styling
72+
73+
- **color** - set the text label color
74+
- **font-size** - checkbox is sized to text from here
75+
- **border-width** - set the line width of the checkbox element: iOS only
7176

72-
- **color** - set the checkbox color tint - Android 21+ only.
77+
## Demo Setup
78+
* npm install tns-platform-declarations
79+
* preparedemo
80+
* npm run demo.ios

app/App_Resources/iOS/Info.plist

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleDisplayName</key>
8+
<string>${PRODUCT_NAME}</string>
9+
<key>CFBundleExecutable</key>
10+
<string>${EXECUTABLE_NAME}</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>${PRODUCT_NAME}</string>
15+
<key>CFBundlePackageType</key>
16+
<string>APPL</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>1.0</string>
19+
<key>CFBundleSignature</key>
20+
<string>????</string>
21+
<key>CFBundleVersion</key>
22+
<string>1.0</string>
23+
<key>LSRequiresIPhoneOS</key>
24+
<true/>
25+
<key>UILaunchStoryboardName</key>
26+
<string>LaunchScreen</string>
27+
<key>UIRequiresFullScreen</key>
28+
<true/>
29+
<key>UIRequiredDeviceCapabilities</key>
30+
<array>
31+
<string>armv7</string>
32+
</array>
33+
<key>UISupportedInterfaceOrientations</key>
34+
<array>
35+
<string>UIInterfaceOrientationPortrait</string>
36+
<string>UIInterfaceOrientationLandscapeLeft</string>
37+
<string>UIInterfaceOrientationLandscapeRight</string>
38+
</array>
39+
<key>UISupportedInterfaceOrientations~ipad</key>
40+
<array>
41+
<string>UIInterfaceOrientationPortrait</string>
42+
<string>UIInterfaceOrientationPortraitUpsideDown</string>
43+
<string>UIInterfaceOrientationLandscapeLeft</string>
44+
<string>UIInterfaceOrientationLandscapeRight</string>
45+
</array>
46+
</dict>
47+
</plist>

0 commit comments

Comments
 (0)