Skip to content

Commit 061a420

Browse files
Various stying improvements, sizing based on fontsize
1 parent 19c638a commit 061a420

File tree

8 files changed

+198
-34
lines changed

8 files changed

+198
-34
lines changed

.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+
}

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>

checkbox.android.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ declare var android: any;
1313
export class CheckBox extends View implements CheckBoxInterface {
1414
private _android: any; /// android.widget.CheckBox
1515
private _fillColor: string;
16-
private _checkBoxSize: number;
1716

1817
public static checkedProperty = new Property(
1918
"checked",
@@ -29,8 +28,6 @@ export class CheckBox extends View implements CheckBoxInterface {
2928

3029
constructor() {
3130
super();
32-
33-
this._checkBoxSize = 21;
3431
}
3532

3633
get android() {
@@ -67,14 +64,6 @@ export class CheckBox extends View implements CheckBoxInterface {
6764
this._android.setButtonTintList(android.content.res.ColorStateList.valueOf(new Color(this._fillColor).android));
6865
}
6966

70-
get checkboxSize(){
71-
return this._checkBoxSize;
72-
}
73-
74-
set checkBoxSize(size: number) {
75-
this._checkBoxSize = size;
76-
}
77-
7867
//There is no difference between tint and fill on the android widget
7968
get tintColor() : string {
8069
return this.fillColor;
@@ -93,10 +82,13 @@ export class CheckBox extends View implements CheckBoxInterface {
9382
this._android.setText(this.text);
9483
}
9584

96-
//Set bound colors
85+
9786
if(this._android){
98-
if(this.fillColor)
87+
if(this.fillColor){
88+
//Set bound colors
9989
this._android.setButtonTintList(android.content.res.ColorStateList.valueOf(new Color(this._fillColor).android));
90+
}
91+
10092
}
10193

10294
var that = new WeakRef(this);

checkbox.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export interface CheckBoxInterface{
4444
checked: boolean;
4545
fillColor: string;
4646
tintColor: string;
47-
checkBoxSize: number;
47+
//checkBoxSize: number;
4848

4949
toggle(): void;
5050
}

checkbox.ios.ts

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export class CheckBox extends Button implements CheckBoxInterface {
3030
private _animationDuration: number;
3131
private _onAnimationType: number;
3232
private _offAnimationType: number;
33-
private _checkBoxSize: number;
3433

3534
constructor() {
3635
super();
@@ -42,9 +41,8 @@ export class CheckBox extends Button implements CheckBoxInterface {
4241
this._tintColor = "#0075ff";
4342
this._onAnimationType = 2;
4443
this._offAnimationType = 2;
45-
this._checkBoxSize = 21;
46-
47-
this._iosCheckbox = <BEMCheckBox>BEMCheckBox.alloc().initWithFrame(CGRectMake(0, 0, this._checkBoxSize, this._checkBoxSize));
44+
45+
this._iosCheckbox = <BEMCheckBox>BEMCheckBox.alloc().initWithFrame(CGRectMake(0, 0, 21, 21));
4846
this._delegate = BEMCheckBoxDelegateImpl.initWithOwner(new WeakRef(this));
4947
}
5048

@@ -65,14 +63,6 @@ export class CheckBox extends Button implements CheckBoxInterface {
6563
this._iosCheckbox.onTintColor = new Color(color).ios;
6664
}
6765

68-
get checkboxSize(){
69-
return this._checkBoxSize;
70-
}
71-
72-
set checkBoxSize(size: number) {
73-
this._checkBoxSize = size;
74-
}
75-
7666
/* NATIVE PROPERTIES */
7767
set checkedAnimated(value: boolean) {
7868
if (this._iosCheckbox)
@@ -152,10 +142,14 @@ export class CheckBox extends Button implements CheckBoxInterface {
152142
public onLoaded() {
153143
super.onLoaded();
154144

145+
var fontSize = this.style.fontSize;
155146
this._iosCheckbox.delegate = this._delegate;
156-
this._iosCheckbox.frame = CGRectMake(0,0,this._checkBoxSize,this._checkBoxSize);
157147

158-
this.style.paddingLeft = this._checkBoxSize + 10;
148+
//Positioning
149+
this._iosCheckbox.frame = CGRectMake(0,0,fontSize,fontSize);
150+
this._iosCheckbox.center = CGPointMake( this._iosCheckbox.center.x, (fontSize / 2) + 3);
151+
152+
this.style.paddingLeft = fontSize + (fontSize > 20 ? 10 : 5);
159153
this.style.textAlignment = "left";
160154

161155
this.ios.addSubview(this._iosCheckbox);
@@ -229,7 +223,7 @@ export class CheckBox extends Button implements CheckBoxInterface {
229223
}
230224

231225
public _onCheckedPropertyChanged(data: PropertyChangeData) {
232-
console.log("_onCheckedPropertyChanged");
226+
console.log("_onCheckedPropertyChanged to " + data.newValue);
233227
debugger;
234228
if(this._iosCheckbox){
235229
this._iosCheckbox.setOnAnimated(data.newValue, true);
@@ -238,7 +232,7 @@ export class CheckBox extends Button implements CheckBoxInterface {
238232
}
239233

240234
function onCheckedPropertyChanged(data: PropertyChangeData) {
241-
console.log("onCheckedPropertyChanged");
235+
console.log("onCheckedPropertyChanged to " + data.newValue);
242236
debugger;
243237
var checkbox = <CheckBox>data.object;
244238
checkbox._onCheckedPropertyChanged(data);
@@ -268,10 +262,9 @@ class BEMCheckBoxDelegateImpl extends NSObject implements BEMCheckBoxDelegate {
268262
}
269263

270264
public didTapCheckBox(checkBox: BEMCheckBox): void {
271-
debugger;
272-
console.log("delegate check");
273265
let owner = this._owner.get();
274266
if (owner) {
267+
console.log("delegate check " + checkBox.on);
275268
owner._onPropertyChangedFromNative(CheckBox.checkedProperty, checkBox.on);
276269
}
277270
}

demo/app/app.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ CheckBox{
5050
color: white;
5151
border-color: yellow;
5252
border-width: 1;
53-
font-size: 20;
53+
font-size: 15;
5454
}
5555

5656
.demosection{

demo/app/main-page.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<Label text="Functions" class="title" />
99
<StackLayout class="listitem">
1010
<GridLayout columns="*, auto" class="demosection">
11-
<CheckBox:CheckBox id="toggleTest" col="0" text="toggle()" checked="false" checkBoxSize="30" />
11+
<CheckBox:CheckBox id="toggleTest" col="0" text="toggle()" checked="false" />
1212
<Button col="1" text="GO" tap="onToggleTest" class="button" />
1313
</GridLayout>
1414
</StackLayout>
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)