This repository has been archived by the owner on Oct 28, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
160 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"shared_preferences","path":"/home/ewpratten/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.7+3/","dependencies":[]},{"name":"url_launcher","path":"/home/ewpratten/development/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.4.10/","dependencies":[]}],"android":[{"name":"shared_preferences","path":"/home/ewpratten/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.7+3/","dependencies":[]},{"name":"url_launcher","path":"/home/ewpratten/development/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.4.10/","dependencies":[]}],"macos":[{"name":"shared_preferences_macos","path":"/home/ewpratten/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-0.0.1+9/","dependencies":[]},{"name":"url_launcher_macos","path":"/home/ewpratten/development/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-0.0.1+7/","dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"shared_preferences_web","path":"/home/ewpratten/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-0.1.2+7/","dependencies":[]},{"name":"url_launcher_web","path":"/home/ewpratten/development/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-0.1.1+6/","dependencies":[]}]},"dependencyGraph":[{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_web","url_launcher_macos"]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]}],"date_created":"2020-05-29 14:52:05.043675","version":"1.17.1"} | ||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"image_picker","path":"/home/ewpratten/development/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.6.7/","dependencies":[]},{"name":"shared_preferences","path":"/home/ewpratten/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.7+3/","dependencies":[]},{"name":"url_launcher","path":"/home/ewpratten/development/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.4.10/","dependencies":[]}],"android":[{"name":"flutter_plugin_android_lifecycle","path":"/home/ewpratten/development/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_plugin_android_lifecycle-1.0.8/","dependencies":[]},{"name":"image_picker","path":"/home/ewpratten/development/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.6.7/","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"shared_preferences","path":"/home/ewpratten/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.7+3/","dependencies":[]},{"name":"url_launcher","path":"/home/ewpratten/development/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.4.10/","dependencies":[]}],"macos":[{"name":"shared_preferences_macos","path":"/home/ewpratten/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-0.0.1+9/","dependencies":[]},{"name":"url_launcher_macos","path":"/home/ewpratten/development/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-0.0.1+7/","dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"shared_preferences_web","path":"/home/ewpratten/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-0.1.2+7/","dependencies":[]},{"name":"url_launcher_web","path":"/home/ewpratten/development/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-0.1.1+6/","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"image_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_web","url_launcher_macos"]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]}],"date_created":"2020-05-29 16:09:09.719056","version":"1.17.1"} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:image_picker/image_picker.dart'; | ||
import 'package:url_launcher/url_launcher.dart'; | ||
import 'package:vsbro/api/auth.dart'; | ||
|
||
class UploadView extends StatefulWidget { | ||
UploadView({Key key}) : super(key: key); | ||
|
||
final String title = "Upload Post"; | ||
|
||
@override | ||
_UploadViewState createState() => _UploadViewState(); | ||
} | ||
|
||
class _UploadViewState extends State<UploadView> { | ||
// Input controllers | ||
TextEditingController captionController = TextEditingController(); | ||
|
||
File image; | ||
|
||
@override | ||
void dispose() { | ||
captionController.dispose(); | ||
super.dispose(); | ||
} | ||
|
||
upload(BuildContext context) { | ||
uploadPost((t) { | ||
if (t) { | ||
Navigator.pop(context); | ||
} else { | ||
setState(() { | ||
this.image = null; | ||
captionController.text = "Failed to upload file"; | ||
}); | ||
} | ||
}, image, captionController.text); | ||
} | ||
|
||
getImage() async { | ||
var tempImage = | ||
await new ImagePicker().getImage(source: ImageSource.gallery); | ||
|
||
setState(() { | ||
this.image = File(tempImage.path); | ||
}); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
leading: IconButton( | ||
icon: Icon(Icons.arrow_back), | ||
onPressed: () { | ||
Navigator.pop(context); | ||
}, | ||
), | ||
title: Text(widget.title), | ||
centerTitle: true, | ||
), | ||
body: ListView( | ||
children: <Widget>[ | ||
SizedBox(height: 40), | ||
Text( | ||
"IMPORTANT: Posting will fail without warning if you have not varified your email. Make sure to verify before posting. Also, there is a large delay after pressing \"post\". Please be patient."), | ||
SizedBox(height: 40), | ||
RaisedButton( | ||
child: Text("Upload Photo"), | ||
onPressed: () { | ||
getImage(); | ||
}, | ||
), | ||
SizedBox(height: 20), | ||
TextField( | ||
controller: captionController, | ||
decoration: InputDecoration(hintText: "Caption (optional)"), | ||
), | ||
RaisedButton( | ||
child: Text( | ||
(image == null) ? "Upload an image before posting" : "Post"), | ||
onPressed: () { | ||
if (image != null) { | ||
upload(context); | ||
} | ||
}, | ||
), | ||
], | ||
)); | ||
} | ||
} |
This file contains 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