Skip to content

Commit

Permalink
minor android bug fix, and version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
shiv19 committed Apr 3, 2019
1 parent 4c9d4cf commit 08edd23
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 26 deletions.
6 changes: 3 additions & 3 deletions demo/app/main-page.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<GridLayout rows="" columns="">
<Image src="~/landscape.jpg" stretch="aspectFill" />
<StackLayout class="p-20">
<Button text="Pick a Date" tap="{{ selectDate }}" style="margin-top: 100;" class="btn btn-primary btn-active"/>
<Button text="Pick a Date (spinner mode)" tap="{{ selectDateSpinner }}" style="margin-top: 20;" class="btn btn-primary btn-active"/>
<Button text="Pick a Date (with limited year range)" tap="{{ selectDate }}" style="margin-top: 100;" class="btn btn-primary btn-active"/>
<Button text="Pick a Date" tap="{{ selectDateSpinner }}" style="margin-top: 20;" class="btn btn-primary btn-active"/>
<Button text="Pick a Time" tap="{{ selectTime }}" style="margin-top: 20; margin-bottom: 100;" class="btn btn-primary btn-active"/>
<Button text="Pick a Time (Overlay)" tap="{{ selectDateOverlay }}" style="margin-top: 20; margin-bottom: 100;" class="btn btn-primary btn-active"/>
<Button text="Pick a Date (Overlay)" tap="{{ selectDateOverlay }}" style="margin-top: 20; margin-bottom: 100;" class="btn btn-primary btn-active"/>
<Button text="Close programatically" tap="{{ closeProgramatically }}" style="margin-top: 20; margin-bottom: 100;" class="btn btn-primary btn-active"/>
<Label visibility="{{ date ? 'visible' : 'collapsed' }}" text="{{date}}" style="color: white; text-align: center; font-size: 20; font-weight: bold;" />
<Label visibility="{{ time ? 'visible' : 'collapsed' }}" text="{{time}}" style="color: white; text-align: center; font-size: 20; font-weight: bold;" />
Expand Down
6 changes: 3 additions & 3 deletions demo/app/vendor-platform.android.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require("application");
require("tns-core-modules/application");
if (!global["__snapshot"]) {
/*
In case snapshot generation is enabled these modules will get into the bundle but will not be required/evaluated.
The snapshot webpack plugin will add them to the tns-java-classes.js bundle file. This way, they will be evaluated on app start as early as possible.
*/
require("ui/frame");
require("ui/frame/activity");
require("tns-core-modules/ui/frame");
require("tns-core-modules/ui/frame/activity");
}
2 changes: 1 addition & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@
"build-android-bundle": "npm run ns-bundle --android --build-app",
"build-ios-bundle": "npm run ns-bundle --ios --build-app"
}
}
}
37 changes: 20 additions & 17 deletions src/modal-datetimepicker.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class ModalDatetimepicker {
if (options.startingDate) startDate = options.startingDate;

try {
let datePicker = new android.app.DatePickerDialog(
this.datePicker = new android.app.DatePickerDialog(
app.android.foregroundActivity,
new android.app.DatePickerDialog.OnDateSetListener({
onDateSet: (view, year, monthOfYear, dayOfMonth) => {
Expand Down Expand Up @@ -99,6 +99,8 @@ export class ModalDatetimepicker {

this.timePicker.show();

let toastMsg = "";

if (options.minTime) {
if (
options.minTime.hour < 24 &&
Expand All @@ -110,14 +112,11 @@ export class ModalDatetimepicker {
options.minTime.hour,
options.minTime.minute
);
android.widget.Toast.makeText(
app.android.foregroundActivity,
"Minimum Time: " +
options.minTime.hour +
":" +
options.minTime.minute,
android.widget.Toast.LENGTH_SHORT
).show();
toastMsg =
"Min Time: " +
options.minTime.hour +
":" +
options.minTime.minute;
} else {
reject("Invalid minTime");
}
Expand All @@ -134,18 +133,22 @@ export class ModalDatetimepicker {
options.maxTime.hour,
options.maxTime.minute
);
android.widget.Toast.makeText(
app.android.foregroundActivity,
"Maximum Time: " +
options.maxTime.hour +
":" +
options.maxTime.minute,
android.widget.Toast.LENGTH_SHORT
).show();
toastMsg +=
" Max Time: " +
options.maxTime.hour +
":" +
options.maxTime.minute;
} else {
reject("Invalid maxTime");
}
}
if (toastMsg !== "") {
android.widget.Toast.makeText(
app.android.foregroundActivity,
toastMsg,
android.widget.Toast.LENGTH_LONG
).show();
}
} catch (err) {
reject(err);
}
Expand Down
2 changes: 1 addition & 1 deletion src/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 29 additions & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nativescript-modal-datetimepicker",
"version": "1.1.13",
"version": "1.2.0",
"description": "A nice looking modal date time picker.",
"main": "modal-datetimepicker",
"typings": "index.d.ts",
Expand Down Expand Up @@ -80,6 +80,34 @@
"name": "Luke Curran",
"email": "[email protected]",
"url": "https://github.com/MCurran16"
},
{
"name": "Hosikiti",
"url": "https://github.com/hosikiti"
},
{
"name": "Kevin Beckers",
"url": "https://github.com/KevinBeckers"
},
{
"name": "Jack Thomson",
"url": "https://github.com/JackThomson2"
},
{
"name": "Pete Morgan",
"url": "https://github.com/pedromorgan"
},
{
"name": "Gustavo Silva Teles",
"url": "https://github.com/gustavost26"
},
{
"name": "quen09t",
"url": "https://github.com/quen09t"
},
{
"name": "Ruslan Urmeev",
"url": "https://github.com/russelarms"
}
],
"repository": {
Expand Down

0 comments on commit 08edd23

Please sign in to comment.