-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
715 lines (563 loc) · 21.6 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>How I Built a Photo Tracking App with React Native</title>
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/league.css">
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
</head>
<body>
<div class="reveal">
<div class="slides">
<section data-markdown data-background="https://media.giphy.com/media/sNz7ODDP6lsRy/giphy.gif">
<textarea data-template>
PhotoStats.io:
## How I Built a Photo Tracking App with React Native
<br/>
<br/>
by Mark Koester <br />
www.markwk.com | github.com/markwk
<br />
<br />
<small>Slides: [https://rawgit.com/markwk/building-photostats.io-presentation/master/index.html](https://rawgit.com/markwk/building-photostats.io-presentation/master/index.html)</small>
</textarea>
</section>
<section data-markdown>
<textarea data-template>
## Where Can You Find Me?
* Email: mark@int3c.com
* Personal Blog: [www.markwk.com](http://www.markwk.com)
* Linkedin: [linkedin.com/in/markwkoester](https://www.linkedin.com/in/markwkoester)
* Github: [markwk](https://github.com/markwk/)
* Professional Portfolio: [Int3c.com/portfolio](http://int3c.com/portfolio)
* Twitter: [@markwkoester](https://twitter.com/markwkoester)
<br/>
### <span style="color:red">Available for Hire:</span>
<small>Builder for Web and Mobile, Dev, CTO, Technology Consultant</small>
</textarea>
</section>
<section data-markdown data-background="https://media.giphy.com/media/sNz7ODDP6lsRy/giphy.gif">
<textarea data-template>
## Slides:
[https://rawgit.com/markwk/building-photostats.io-presentation/master/index.html](https://rawgit.com/markwk/building-photostats.io-presentation/master/index.html)
</textarea>
</section>
<section id="fragments" data-background="https://media.giphy.com/media/tLqOJRWCkJ1EQ/giphy.gif">
<h1 class="fragment">475</h1>
<h2 class="fragment">or 1.3 photos per day</h2>
<br />
<h4>estimated number of photos that was taken by every smart phone user in 2017.</h4>
</section>
<section>
<img data-src="slide-images/photostats-explorting-photo-data-cover.jpg">
</section>
<section data-markdown>
<textarea data-template>
## Outline
* INTRO: Self-Tracking & Quantified Self
* What is Photo Metadata?
* IDEA: An App to Aggregate and Track My Photo Metadata
* What is React Native?
* DEMO: Initial Prototype using CameraAPI
* UI / Theming with Native Base
* Data Models
* Pro's and Con's of React Native
* What I've Learned?
</textarea>
</section>
<section data-markdown>
<textarea data-template>
<img data-src="slide-images/mark-headshot-squared.jpg">
## I'm a digital documentarist.
I am [Mark Koester](https://twitter.com/markwkoester). I'm a tech entrepreneur, a [web developer](http://int3c.com) (mostly), a [writer](http://www.markwk.com) and...
</textarea>
</section>
<section data-background="http://i.giphy.com/90F8aUepslB84.gif">
<h2>... and an obsessive tracker!</h2>
</section>
<section id="fragments">
<h2>Quantified Self: What is it?</h2>
<p class="fragment fade-left">Measuring or documenting something about your self such that it gains meaning.</p>
</section>
<section>
I track a lot of aspects of my life.
</section>
<section>
<section data-background="https://media.giphy.com/media/l3mZnuz4coJp8EBBm/giphy.gif">
<h2>What Do I Track...?</h2>
</section>
<section data-markdown>
<textarea data-template>
## Time & Productivity
* Computing Time (RescueTime)
* Project Time (Toggl)
* Mobile Screen Time (Moment app)
* Tasks (Todoist)
* Habits and Goals (via Streaks, Habitica, Productive)
* Creative Written Words (Mac Word Counter app)
</textarea>
</section>
<section>
<img data-src="slide-images/2017-A-Year-in-Computer-Time.png" width=500>
</section>
<section>
<img data-src="slide-images/2017-Year-in-Tasks-infographic.png" width=500>
</section>
<section data-markdown>
<textarea data-template>
## Health & Fitness
* Steps (Apple Watch)
* Blood Pressure
* Weight (digital scale and manual logging)
* Heart Rate & Heart Rate Variability
* Running & Cycling (Strava)
* Sleep (AutoSleep app)
* Supplements and Medicine (RoundHealth)
* Strength Workouts (FitBod)
* Daily Standing
</textarea>
</section>
<section>
<img data-src="slide-images/2017-step-count.jpg" width=600>
</section>
<section data-markdown>
<textarea data-template>
## Learning & Media Consumption
* Books Read (GoodReads)
* Articles Read (Pocket, Evernote)
* TV and Movie Watching (Trakt.tv)
* Music (Last.fm)
* Podcast Listening with beta.PodcastTracker.com <- I Built This.
</textarea>
</section>
<section data-background="/slide-images/podcasttracker-example.png">
<h2>
<a href="http://beta.podcasttracker.com"> Podcast Listening: Beta.PodcastTracker.com</a>
</h2>
</section>
<section>
<img data-src="slide-images/my-year-in-podcast-listening-cover.png">
</section>
<section data-markdown>
<textarea data-template>
## Other Random Stuff
* Money & Finances (Mint)
* Location (Moves app, Reporter App)
</textarea>
</section>
<section data-background="https://media.giphy.com/media/l0EoBlDn63scoVSXC/giphy.gif">
<h2>Exploring and Visualizing My Data: Examples</h2>
<p><a href="http://www.markwk.com/2018/01/year-in-data.html">A Year in Numbers: My Data From 2017</a></p>
</section>
</section>
<section id="fragments">
<h4>Opportunities in the Tracking and Data Space</h4>
<ul>
<li class="fragment">Deriving insight and meaning from existing data</li>
<li class="fragment">Enabling and tracking new data points.</li>
</ul>
</section>
<section id="fragments">
<h4>A Data Point to Track and Find Insight</h4>
<span class="fragment"><h1>Your Photo Data</h1>
</section>
<section id="fragments">
<h2>What is Photo Metadata?</h2>
<p class="fragment">Image metadata is text information pertaining to an image file that is embedded into the file or contained in a separate file that is associated with it.</p>
<p class="fragment">Image metadata includes details relevant to the image itself as well as information about its production. This data is generated by the device capturing the image (i.e. the camera).</p>
<p class="fragment"><strong>Metadata puts photos in context.</strong></p>
</section>
<section>
<h2>Examples of Metadata on Photos</h2>
<ul>
<li>Locational (gps, altitude, etc.)</li>
<li>Date & Time (creation, modification)</li>
<li>Camera Type</li>
<li>EXIF Data about focus, aperture, etc.</li>
</ul>
</section>
<section>How to get your photo metadata?</section>
<section>
<h2>PhotoStats.io</h2>
<img data-src="slide-images/photostats-site.png">
</section>
<section>
<h2>Photo Data Tracking App</h2>
<p>The photos on your mobile phone are one of the richest collections of data you have on yourself. If you regularly take photos with your phone (which most of us do), then your phone is collecting data on you.</p>
</section>
<section>
<h4>"Weekend Project":</h4>
<h2>Initial Feature List</h2>
<ol>
<li>Access Photo Library on Phone</li>
<li>Extract Meta Data, like gps, EXIF, etc.</li>
<li>Export the data (CSV or JSON)</li>
</ol>
</section>
<section>What is React Native?</section>
<section>
<ul>
<li>React Native is a framework to build native mobile apps using React and Javascript.</li>
<li>With React Native, you don't build a "mobile web app", an "HTML5 app", or a "hybrid app". It's indistinguishable from an app built using Objective-C or Java. React Native uses the same fundamental UI building blocks as regular iOS and Android apps.</li>
<li>React and React Native are maintained by Facebook, Instagram and a community of developers.</li>
</ul>
</section>
<section>
<h4>How Does React Native Work (vs. React)?</h4>
<img data-src="slide-images/how-does-react-native-work.png">
<small>Source: http://www.discoversdk.com/blog/how-react-native-works</small>
</section>
<section>
<h4>React's Rendering Lifecycle</h4>
<img data-src="slide-images/react-works01.png">
<img data-src="slide-images/react-works02.png">
<small>Source: http://www.discoversdk.com/blog/how-react-native-works</small>
</section>
<section>
<ul>
<li>React renders to and manipulates the browser’s DOM.</li>
<li>React Native is not rendering web-based views.</li>
<li>In contrast, React Native invokes Objective-C APIs to render to iOS components, or Java APIs to render to Android components. </li>
</ul>
</section>
<section>
<h4>React Native Views</h4>
<img data-src="slide-images/react-native-views.png" width=400>
</section>
<section>
<h4>Getting Started...</h4>
<img data-src="slide-images/rn-getting-started.png" width="600">
<small>https://facebook.github.io/react-native/docs/getting-started.html</small>
</section>
<section>
<h4>"Weekend Project":</h4>
<h2>Initial Feature List</h2>
<ol>
<li>Access Photo Library on Phone</li>
<li>Extract Meta Data, like gps, EXIF, etc.</li>
<li>Export the data (CSV or JSON)</li>
</ol>
</section>
<section>
<h2>Demo: Code Structure</h2>
<img data-src="slide-images/demo-code-structure.png">
</section>
<section>
<h4>index.ios.js</h4>
<pre><code class="hljs" data-trim contenteditable>
//index.ios.js for start ios project
import { AppRegistry } from 'react-native';
import app from './app';
AppRegistry.registerComponent('rncameraroll', app);
</code></pre>
</section>
<section>
<h4>Key API: CameraRoll</h4>
<p>CameraRoll provides access to the local camera roll / gallery.</p>
<p>Key Method: getPhotos()</p>
<small>https://facebook.github.io/react-native/docs/cameraroll.html</small>
</section>
<section>
<h4>app.js</h4>
<pre><code class="hljs" data-trim contenteditable>
import React from 'react';
import { StackNavigator } from 'react-navigation'
import ImageBrowser from './ImageBrowser'
import ImageList from './ImageList'
const Navigation = StackNavigator({
ImageList: { screen: ImageList },
ImageBrowser: { screen: ImageBrowser },
});
function setup() {
return Navigation;
}
export default setup;
</code></pre>
</section>
<section>
<h4>ImageList.js</h4>
<pre><code class="hljs" data-trim contenteditable>
//imagelist.js for date list of photo on phone.
import React from 'react'
import { //import component
View,
Text,
TouchableOpacity,
StyleSheet,
Button,
CameraRoll,
Image,
Dimensions,
ScrollView,
ActivityIndicator,
Platform
} from 'react-native'
import App from './app'
import Utils from './utils'
const { width, height } = Dimensions.get('window')
</code></pre>
</section>
<section>
<h4>ImageList.js</h4>
<pre><code class="hljs" data-trim contenteditable>
export default class ImageList extends React.Component {
static navigationOptions = {
title: 'Gallery',
};
constructor(props) {
super(props);
this.state = {
dates: [],
photos: [],
loading: true
}
}
componentDidMount() {
this.getPhotos();
}
</code></pre>
</section>
<section>
<h4>ImageList.js</h4>
<pre><code class="hljs" data-trim contenteditable>
getPhotos = () => { //function getPhotos get photo from phone
CameraRoll.getPhotos({
first: Platform.OS === 'android' ? 999 : -1,
assetType: 'All',
// groupTypes: 'All'
})
.then(r => {
this.setState({ photos: r.edges });
r.edges.forEach(data => {
let dates = Utils.clone(this.state.dates);
let newTimestamp = data.node.timestamp;
let isDateExists = false;
if (dates.length) {
for (i = 0; i < dates.length; i++) {
let date = dates[i];
if (Utils.isSameDate(new Date(date.timestamp * 1000), new Date(newTimestamp * 1000))) {
date.count++;
isDateExists = true;
break;
}
}
}
if (!isDateExists) {
dates.push({
timestamp: newTimestamp,
count: 1
})
}
this.setState({ dates: dates, loading: false });
});
});
};
</code></pre>
</section>
<section id="fragments">
<h4>Post-"Weekend Project":</h4>
<h2>Feature List</h2>
<ol>
<li><strike class="fragment">Access Photo Library on Phone</strike></li>
<li>Extract Meta Data, like gps, EXIF, etc. <span class="fragment" style="color:red">=> Library?</span></li>
<li>Export the data (CSV or JSON) <span class="fragment" style="color:red">=> Data Model?</span></li>
<li class="fragment" style="color:green">Better Structure</li>
<li class="fragment" style="color:green">Improved UI and Design</li>
</ol>
</section>
<section>
<h4>Improved Starting Position: Native Base</h4>
<img data-src="slide-images/nativebase.png">
<p><small>https://nativebase.io</small></p>
</section>
<section>
<h4>Cheating?</h4>
<h2>React Native "Theme"</h2>
<img data-src="slide-images/rn-theme.png">
<small>https://nativebase.io</small>
</section>
<section>
<h2>Revised Code Structure</h2>
<img data-src="slide-images/code-structure.png">
</section>
<section>
<h2>Screens to Start With</h2>
<img data-src="slide-images/rn-screens.png">
</section>
<section>
<h2>Library to Extract EXIF Data</h2> <small>https://github.com/francisco-sanchez-molina/react-native-exif</small>
</section>
<section>
<h4>Data Management, Storage and Models in React Native</h4>
</section>
<section data-background="https://media.giphy.com/media/3o7buirYcmV5nSwIRW/giphy.gif">
<span style="color:red">Questions: Backend? No Backend? Persistent Storage? Data Model?</span>
</section>
<section>
Redux is an open-source JavaScript library designed for managing application state. It is primarily used together with React or Angular for building user interfaces.
</section>
<section>
<h4>Data Modeling in React Native</h4>
<ul>
<li>/reducers/dateObject.js</li>
<li>/reducers/imageObject.js</li>
</ul>
</section>
<section>
<h4>/reducers/imageObject.js</h4>
<pre><code class="hljs" data-trim contenteditable>
// This method will generate a object structure for the image Object.
import Utils from "./utils.js";
import Exif from "react-native-exif";
import { Platform } from "react-native";
import { Crashlytics } from "react-native-fabric";
const imageObject = {
fetchObject(imageData) {
let cameraData = {
timestamp: imageData.timestamp,
groupName: imageData.group_name,
type: imageData.type,
location: imageData.location,
fileName: imageData.image.filename,
width: imageData.image.width,
height: imageData.image.height,
uri: imageData.image.uri,
isDeleted: false,
time: Utils.getStringTime(new Date(imageData.timestamp * 1000)),
date: Utils.getStringFromDate(new Date(imageData.timestamp * 1000)),
};
// alert(Utils.isExifDataDisable)
if(Utils.isExifDataDisable){
return new Promise((resolve, reject) => {
resolve(cameraData);
});
}else{
//adding the exif data in the image data fetched from CameraRoll
return new Promise((resolve, reject) => {
Exif.getExif(imageData.image.uri)
.then((data) =>{
cameraData = { ...cameraData, exifData:data };
resolve(cameraData);
})
.catch((error) => {
alert(error + " file: " + imageData.image.uri);
Platform.OS === "android"
// Record a non-fatal JS error
? Crashlytics.logException(error + " file: " + imageData.image.uri)
: Crashlytics.recordError(error + " file: " + imageData.image.uri)
// reject("Exif" + error);
resolve(cameraData);
});
});
}
},
};
module.exports = imageObject;
</code></pre>
</section>
<section>
<h4>/reducers/dateObject.js</h4>
<pre><code class="hljs" data-trim contenteditable>
// This method will generate a object structure for the date Object.
const dateObject = {
fetchObject(timeStamp,imagesArray,count) {
return {
timestamp: timeStamp,
images: imagesArray,
};
}
};
module.exports = dateObject;
</code></pre>
</section>
<section>
<h4>Data Storage in React Native</h4>
<ul>
<li>Async Storage ("built-in" to React Native)</li>
<li>SQLite</li>
<li>Firebase</li>
<li>Realm</li>
<li>Backends like MongoDB, Couchbase</li>
<li>Redux Persist</li>
</ul>
</section>
<section>
Redux Persist takes your redux state object and saves it to persisted storage. On app launch, it retrieves this persisted state and saves it back to redux.
</section>
<section>
<h4>How I Manage Data:</h4>
<p>No backend. Store locally. Model data for exporting and stats.</p>
</section>
<section>
<h2>PhotoStats.io</h2>
<img data-src="slide-images/photostats-screenshots01.png">
</section>
<section>
<h2>PhotoStats.io</h2>
<img data-src="slide-images/photostats-screenshots02.png">
</section>
<section data-markdown>
<textarea data-template>
## Exporting Data
library: react-native-fetch-blob
</textarea>
</section>
<section data-markdown>
<textarea data-template>
## Lessons Learned about React Native
* React Native is a good entry point for web developers to get into mobile development.
* RN Apps perform quite well, no lag...
* React Native makes theming and style changes quite easy.
* Healthy community of code and libraries (see: JS.coach ) as well as tutorials and articles.
* Not all open source code is created equal so it's best to stick with react native's core APIs where possible.
* You can mix RN code and true "native" code.
</textarea>
</section>
<section>
<img data-src="slide-images/photostats-explorting-photo-data-cover.jpg">
<p>Lessons? Next steps? Finding Insights from Photo Data?</p>
</section>
<section data-markdown>
<textarea data-template>
## Q&A: www.photostats.io
* Email: mark@int3c.com
* Personal Blog: [www.markwk.com](http://www.markwk.com)
* Linkedin: [linkedin.com/in/markwkoester](https://www.linkedin.com/in/markwkoester)
* Github: [markwk](https://github.com/markwk/)
* Professional Portfolio: [Int3c.com/portfolio](http://int3c.com/portfolio)
* Twitter: [@markwkoester](https://twitter.com/markwkoester)
<br/>
### <span style="color:red">Available for Hire:</span>
<small>Builder for Web and Mobile, Dev, CTO, Technology Consultant</small>
</textarea>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script>
// More info about config & dependencies:
// - https://github.com/hakimel/reveal.js#configuration
// - https://github.com/hakimel/reveal.js#dependencies
Reveal.initialize({
dependencies: [
{ src: 'plugin/markdown/marked.js' },
{ src: 'plugin/markdown/markdown.js' },
{ src: 'plugin/notes/notes.js', async: true },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }
]
});
</script>
</body>
</html>