mirror of
https://github.com/urbit/shrub.git
synced 2024-11-30 22:15:47 +03:00
get geolocation from weather app, revise clock appearance to match new
launch page
This commit is contained in:
parent
21f6be96a1
commit
c93d026a70
@ -8,7 +8,17 @@
|
|||||||
==
|
==
|
||||||
=, format
|
=, format
|
||||||
::
|
::
|
||||||
|
|%
|
||||||
|
::
|
||||||
|
+$ card card:agent:gall
|
||||||
|
+$ versioned-state
|
||||||
|
$% state-zero
|
||||||
|
==
|
||||||
|
+$ state-zero [%0 data=json]
|
||||||
|
--
|
||||||
%+ verb |
|
%+ verb |
|
||||||
|
=| state-zero
|
||||||
|
=* state -
|
||||||
^- agent:gall
|
^- agent:gall
|
||||||
|_ =bowl:gall
|
|_ =bowl:gall
|
||||||
+* this .
|
+* this .
|
||||||
@ -17,7 +27,7 @@
|
|||||||
++ on-init
|
++ on-init
|
||||||
^- (quip card:agent:gall _this)
|
^- (quip card:agent:gall _this)
|
||||||
=/ launcha
|
=/ launcha
|
||||||
[%launch-action !>([%clock /tile '/~clock/js/tile.js'])]
|
[%launch-action !>([%clock /clocktile '/~clock/js/tile.js'])]
|
||||||
:_ this
|
:_ this
|
||||||
:~ [%pass / %arvo %e %connect [~ /'~clock'] %clock]
|
:~ [%pass / %arvo %e %connect [~ /'~clock'] %clock]
|
||||||
[%pass /clock %agent [our.bowl %launch] %poke launcha]
|
[%pass /clock %agent [our.bowl %launch] %poke launcha]
|
||||||
@ -39,6 +49,9 @@
|
|||||||
++ on-poke
|
++ on-poke
|
||||||
|= [=mark =vase]
|
|= [=mark =vase]
|
||||||
^- (quip card:agent:gall _this)
|
^- (quip card:agent:gall _this)
|
||||||
|
|^
|
||||||
|
?: ?=(%json mark)
|
||||||
|
(poke-json !<(json vase))
|
||||||
?. ?=(%handle-http-request mark)
|
?. ?=(%handle-http-request mark)
|
||||||
(on-poke:def mark vase)
|
(on-poke:def mark vase)
|
||||||
=+ !<([eyre-id=@ta =inbound-request:eyre] vase)
|
=+ !<([eyre-id=@ta =inbound-request:eyre] vase)
|
||||||
@ -59,15 +72,23 @@
|
|||||||
?: =(name 'tile')
|
?: =(name 'tile')
|
||||||
(js-response:gen tile-js)
|
(js-response:gen tile-js)
|
||||||
not-found:gen
|
not-found:gen
|
||||||
|
::
|
||||||
|
++ poke-json
|
||||||
|
|= jon=json
|
||||||
|
^- (quip card:agent:gall _this)
|
||||||
|
=. data.state jon
|
||||||
|
:_ this
|
||||||
|
[%give %fact ~[/clocktile] %json !>(jon)]~
|
||||||
|
--
|
||||||
::
|
::
|
||||||
++ on-watch
|
++ on-watch
|
||||||
|= =path
|
|= =path
|
||||||
^- (quip card:agent:gall _this)
|
^- (quip card:agent:gall _this)
|
||||||
?: ?=([%http-response *] path)
|
?: ?=([%http-response *] path)
|
||||||
`this
|
`this
|
||||||
?. =(/tile path)
|
?. =(/clocktile path)
|
||||||
(on-watch:def path)
|
(on-watch:def path)
|
||||||
[[%give %fact ~ %json !>(*json)]~ this]
|
[[%give %fact ~ %json !>(data.state)]~ this]
|
||||||
::
|
::
|
||||||
++ on-leave on-leave:def
|
++ on-leave on-leave:def
|
||||||
++ on-peek on-peek:def
|
++ on-peek on-peek:def
|
||||||
|
File diff suppressed because one or more lines are too long
@ -41025,6 +41025,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleEvent(diff) {
|
handleEvent(diff) {
|
||||||
|
console.log(diff);
|
||||||
store.handleEvent(diff);
|
store.handleEvent(diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48634,7 +48635,7 @@
|
|||||||
var dist_3 = dist.sigil;
|
var dist_3 = dist.sigil;
|
||||||
var dist_4 = dist.stringRenderer;
|
var dist_4 = dist.stringRenderer;
|
||||||
|
|
||||||
const _jsxFileName = "/Users/matilde/git/urbit/pkg/interface/launch/src/js/components/sigil.js";
|
const _jsxFileName = "/Users/gavinatkinson/Documents/Apps/urbit/pkg/interface/launch/src/js/components/sigil.js";
|
||||||
class Sigil extends react_1 {
|
class Sigil extends react_1 {
|
||||||
render() {
|
render() {
|
||||||
const { props } = this;
|
const { props } = this;
|
||||||
@ -48664,7 +48665,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const _jsxFileName$1 = "/Users/matilde/git/urbit/pkg/interface/launch/src/js/components/header.js";
|
const _jsxFileName$1 = "/Users/gavinatkinson/Documents/Apps/urbit/pkg/interface/launch/src/js/components/header.js";
|
||||||
class Header extends react_1 {
|
class Header extends react_1 {
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
@ -48689,7 +48690,7 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const _jsxFileName$2 = "/Users/matilde/git/urbit/pkg/interface/launch/src/js/components/tile.js";
|
const _jsxFileName$2 = "/Users/gavinatkinson/Documents/Apps/urbit/pkg/interface/launch/src/js/components/tile.js";
|
||||||
class Tile extends react_1 {
|
class Tile extends react_1 {
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@ -48712,7 +48713,7 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const _jsxFileName$3 = "/Users/matilde/git/urbit/pkg/interface/launch/src/js/components/home.js";
|
const _jsxFileName$3 = "/Users/gavinatkinson/Documents/Apps/urbit/pkg/interface/launch/src/js/components/home.js";
|
||||||
|
|
||||||
class Home extends react_1 {
|
class Home extends react_1 {
|
||||||
|
|
||||||
@ -48742,7 +48743,7 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const _jsxFileName$4 = "/Users/matilde/git/urbit/pkg/interface/launch/src/js/app.js";
|
const _jsxFileName$4 = "/Users/gavinatkinson/Documents/Apps/urbit/pkg/interface/launch/src/js/app.js";
|
||||||
class App extends react_1 {
|
class App extends react_1 {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -48776,7 +48777,7 @@
|
|||||||
|
|
||||||
window.app = App;
|
window.app = App;
|
||||||
|
|
||||||
const _jsxFileName$5 = "/Users/matilde/git/urbit/pkg/interface/launch/src/index.js";
|
const _jsxFileName$5 = "/Users/gavinatkinson/Documents/Apps/urbit/pkg/interface/launch/src/index.js";
|
||||||
|
|
||||||
subscription.setAuthTokens({
|
subscription.setAuthTokens({
|
||||||
ship: window.ship
|
ship: window.ship
|
||||||
|
File diff suppressed because one or more lines are too long
@ -3,8 +3,8 @@ import classnames from 'classnames';
|
|||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import SunCalc from 'suncalc'
|
import SunCalc from 'suncalc'
|
||||||
|
|
||||||
const outerSize = 126; //tile size
|
const outerSize = 124; //tile size
|
||||||
const innerSize = 110; //clock size
|
const innerSize = 124; //clock size
|
||||||
|
|
||||||
//polar to cartesian
|
//polar to cartesian
|
||||||
// var ptc = function(r, theta) {
|
// var ptc = function(r, theta) {
|
||||||
@ -105,17 +105,12 @@ class Clock extends Component {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
initGeolocation() {
|
||||||
this.canvas = initCanvas(
|
if (typeof this.props.data === 'string') {
|
||||||
this.canvasRef,
|
// console.log(typeof this.props.data)
|
||||||
{ x: innerSize, y: innerSize },
|
const latlon = this.props.data.split(',')
|
||||||
4
|
const lat = latlon[0]
|
||||||
);
|
const lon = latlon[1]
|
||||||
|
|
||||||
navigator.geolocation.getCurrentPosition((res) => {
|
|
||||||
|
|
||||||
const lat = res.coords.latitude
|
|
||||||
const lon = res.coords.longitude
|
|
||||||
|
|
||||||
const suncalc = SunCalc.getTimes(new Date(), lat, lon)
|
const suncalc = SunCalc.getTimes(new Date(), lat, lon)
|
||||||
|
|
||||||
@ -137,10 +132,25 @@ class Clock extends Component {
|
|||||||
lon,
|
lon,
|
||||||
...convertedSunCalc,
|
...convertedSunCalc,
|
||||||
geolocationSuccess: true,
|
geolocationSuccess: true,
|
||||||
}, (err) => {
|
})
|
||||||
if (err) console.log(err);
|
}
|
||||||
}, { maximumAge: Infinity, timeout: 10000 });
|
}
|
||||||
});
|
|
||||||
|
componentDidUpdate(prevProps) {
|
||||||
|
if (prevProps !== this.props) {
|
||||||
|
this.initGeolocation()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this.canvas = initCanvas(
|
||||||
|
this.canvasRef,
|
||||||
|
{ x: innerSize, y: innerSize },
|
||||||
|
4
|
||||||
|
);
|
||||||
|
|
||||||
|
this.initGeolocation()
|
||||||
this.animate()
|
this.animate()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,8 +171,8 @@ class Clock extends Component {
|
|||||||
var cx = ctr
|
var cx = ctr
|
||||||
var cy = ctr
|
var cy = ctr
|
||||||
this.angle = degToRad(convert(time, this.referenceTime))
|
this.angle = degToRad(convert(time, this.referenceTime))
|
||||||
var newX = cx + (ctr - 24) * Math.cos(this.angle);
|
var newX = cx + (ctr - 15) * Math.cos(this.angle);
|
||||||
var newY = cy + (ctr - 24) * Math.sin(this.angle);
|
var newY = cy + (ctr - 15) * Math.sin(this.angle);
|
||||||
|
|
||||||
// Initial background
|
// Initial background
|
||||||
circle(
|
circle(
|
||||||
@ -296,13 +306,25 @@ class Clock extends Component {
|
|||||||
ctx,
|
ctx,
|
||||||
ctr,
|
ctr,
|
||||||
ctr,
|
ctr,
|
||||||
ctr,
|
ctr-1,
|
||||||
-1,
|
-1,
|
||||||
2 * Math.PI,
|
2 * Math.PI,
|
||||||
'#000000',
|
'#000000',
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Outer borders
|
||||||
|
circleOutline(
|
||||||
|
ctx,
|
||||||
|
ctr,
|
||||||
|
ctr,
|
||||||
|
ctr,
|
||||||
|
-1,
|
||||||
|
2 * Math.PI,
|
||||||
|
'#FFFFFF',
|
||||||
|
1
|
||||||
|
);
|
||||||
|
|
||||||
// Center white circle with time and date
|
// Center white circle with time and date
|
||||||
circle(
|
circle(
|
||||||
ctx,
|
ctx,
|
||||||
@ -311,7 +333,7 @@ class Clock extends Component {
|
|||||||
ctr/1.85,
|
ctr/1.85,
|
||||||
-1,
|
-1,
|
||||||
2 * Math.PI,
|
2 * Math.PI,
|
||||||
'#000000'
|
'#FFFFFF'
|
||||||
)
|
)
|
||||||
|
|
||||||
// Center white circle border
|
// Center white circle border
|
||||||
@ -322,7 +344,7 @@ class Clock extends Component {
|
|||||||
ctr/1.85,
|
ctr/1.85,
|
||||||
-1,
|
-1,
|
||||||
2 * Math.PI,
|
2 * Math.PI,
|
||||||
'rgb(26, 26, 26)',
|
'#000000',
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -332,12 +354,12 @@ class Clock extends Component {
|
|||||||
: moment().format('h:mm A')
|
: moment().format('h:mm A')
|
||||||
const dateText = moment().format('MMM Do')
|
const dateText = moment().format('MMM Do')
|
||||||
ctx.textAlign = 'center'
|
ctx.textAlign = 'center'
|
||||||
ctx.fillStyle = '#FFFFFF'
|
ctx.fillStyle = '#000000'
|
||||||
ctx.font = '12px Inter'
|
ctx.font = '12px Inter'
|
||||||
ctx.fillText(timeText, ctr, ctr + 6 - 12)
|
ctx.fillText(timeText, ctr, ctr + 6 - 7)
|
||||||
ctx.fillStyle = '#B1B1B1'
|
ctx.fillStyle = '#B1B1B1'
|
||||||
ctx.font = '12px Inter'
|
ctx.font = '12px Inter'
|
||||||
ctx.fillText(dateText, ctr, ctr + 6 + 12)
|
ctx.fillText(dateText, ctr, ctr + 6 + 7)
|
||||||
|
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
}
|
}
|
||||||
@ -359,7 +381,7 @@ export default class ClockTile extends Component {
|
|||||||
|
|
||||||
renderWrapper(child) {
|
renderWrapper(child) {
|
||||||
return (
|
return (
|
||||||
<div className="pa2" style={{
|
<div className="" style={{
|
||||||
width: outerSize,
|
width: outerSize,
|
||||||
height: outerSize,
|
height: outerSize,
|
||||||
background: '#fff'
|
background: '#fff'
|
||||||
@ -371,9 +393,8 @@ export default class ClockTile extends Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
let data = !!this.props.data ? this.props.data : {};
|
let data = !!this.props.data ? this.props.data : {};
|
||||||
|
|
||||||
return this.renderWrapper((
|
return this.renderWrapper((
|
||||||
<Clock/>
|
<Clock data={data}/>
|
||||||
));
|
));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,13 +31,13 @@ export default class WeatherTile extends Component {
|
|||||||
|
|
||||||
locationSubmit() {
|
locationSubmit() {
|
||||||
navigator.geolocation.getCurrentPosition((res) => {
|
navigator.geolocation.getCurrentPosition((res) => {
|
||||||
console.log(res);
|
|
||||||
let latlng = `${res.coords.latitude},${res.coords.longitude}`;
|
let latlng = `${res.coords.latitude},${res.coords.longitude}`;
|
||||||
this.setState({
|
this.setState({
|
||||||
latlng
|
latlng
|
||||||
}, (err) => {
|
}, (err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}, { maximumAge: Infinity, timeout: 10000 });
|
}, { maximumAge: Infinity, timeout: 10000 });
|
||||||
|
api.action("clock", "json", latlng);
|
||||||
api.action('weather', 'json', latlng);
|
api.action('weather', 'json', latlng);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -50,6 +50,7 @@ export default class WeatherTile extends Component {
|
|||||||
if (latlngParse.test(latlngNoSpace)) {
|
if (latlngParse.test(latlngNoSpace)) {
|
||||||
let latlng = latlngNoSpace;
|
let latlng = latlngNoSpace;
|
||||||
this.setState({latlng}, (err) => {console.log(err)}, {maximumAge: Infinity, timeout: 10000});
|
this.setState({latlng}, (err) => {console.log(err)}, {maximumAge: Infinity, timeout: 10000});
|
||||||
|
api.action("clock", "json", latlng);
|
||||||
api.action('weather', 'json', latlng);
|
api.action('weather', 'json', latlng);
|
||||||
this.setState({manualEntry: !this.state.manualEntry});
|
this.setState({manualEntry: !this.state.manualEntry});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user