This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Stock.swift | |
// stocks | |
// | |
// Created by Mohammad Azam on 12/24/19. | |
// Copyright © 2019 Mohammad Azam. All rights reserved. | |
// | |
import Foundation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Webservice.swift | |
// stocks | |
// | |
// Created by Mohammad Azam on 12/24/19. | |
// Copyright © 2019 Mohammad Azam. All rights reserved. | |
// | |
import Foundation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// server.js | |
// where your node app starts | |
// init project | |
const express = require("express"); | |
const app = express(); | |
app.get("/top-news", (req, res) => { | |
let articles = [ | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ContentView.swift | |
// stocks | |
// | |
// Created by Mohammad Azam on 12/19/19. | |
// Copyright © 2019 Mohammad Azam. All rights reserved. | |
// | |
import SwiftUI |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void _showCamera() async { | |
final cameras = await availableCameras(); | |
final camera = cameras.first; | |
final result = await Navigator.push( | |
context, | |
MaterialPageRoute( | |
builder: (context) => TakePicturePage(camera: camera))); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: SafeArea( | |
child: Column(children: <Widget>[ | |
_path == null ? Image.asset("images/place-holder.png") : | |
Image.file(File(_path)) | |
, | |
FlatButton( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void _showPhotoLibrary() async { | |
final file = await ImagePicker.pickImage(source: ImageSource.gallery); | |
setState(() { | |
_path = file.path; | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void _takePicture(BuildContext context) async { | |
try { | |
await _initializeCameraControllerFuture; | |
final path = | |
join((await getTemporaryDirectory()).path, '${DateTime.now()}.png'); | |
await _cameraController.takePicture(path); | |
Navigator.pop(context,path); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@override | |
Widget build(BuildContext context) { | |
return Stack(children: <Widget>[ | |
FutureBuilder( | |
future: _initializeCameraControllerFuture, | |
builder: (context, snapshot) { | |
if (snapshot.connectionState == ConnectionState.done) { | |
return CameraPreview(_cameraController); | |
} else { | |
return Center(child: CircularProgressIndicator()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class _TakePicturePageState extends State<TakePicturePage> { | |
CameraController _cameraController; | |
Future<void> _initializeCameraControllerFuture; | |
@override | |
void initState() { | |
super.initState(); | |
_cameraController = | |
CameraController(widget.camera, ResolutionPreset.medium); |