Compare commits

...

2 Commits

Author SHA1 Message Date
a2cde7de81 add basic file chooser 2024-01-06 13:01:12 +00:00
b14f438597 add ability to share projects 2024-01-06 12:39:33 +00:00
6 changed files with 125 additions and 8 deletions

View File

@ -1,4 +1,38 @@
PODS: PODS:
- DKImagePickerController/Core (4.3.4):
- DKImagePickerController/ImageDataManager
- DKImagePickerController/Resource
- DKImagePickerController/ImageDataManager (4.3.4)
- DKImagePickerController/PhotoGallery (4.3.4):
- DKImagePickerController/Core
- DKPhotoGallery
- DKImagePickerController/Resource (4.3.4)
- DKPhotoGallery (0.0.17):
- DKPhotoGallery/Core (= 0.0.17)
- DKPhotoGallery/Model (= 0.0.17)
- DKPhotoGallery/Preview (= 0.0.17)
- DKPhotoGallery/Resource (= 0.0.17)
- SDWebImage
- SwiftyGif
- DKPhotoGallery/Core (0.0.17):
- DKPhotoGallery/Model
- DKPhotoGallery/Preview
- SDWebImage
- SwiftyGif
- DKPhotoGallery/Model (0.0.17):
- SDWebImage
- SwiftyGif
- DKPhotoGallery/Preview (0.0.17):
- DKPhotoGallery/Model
- DKPhotoGallery/Resource
- SDWebImage
- SwiftyGif
- DKPhotoGallery/Resource (0.0.17):
- SDWebImage
- SwiftyGif
- file_picker (0.0.1):
- DKImagePickerController/PhotoGallery
- Flutter
- Firebase/CoreOnly (10.9.0): - Firebase/CoreOnly (10.9.0):
- FirebaseCore (= 10.9.0) - FirebaseCore (= 10.9.0)
- Firebase/Messaging (10.9.0): - Firebase/Messaging (10.9.0):
@ -64,15 +98,20 @@ PODS:
- Flutter - Flutter
- FlutterMacOS - FlutterMacOS
- PromisesObjC (2.2.0) - PromisesObjC (2.2.0)
- SDWebImage (5.18.8):
- SDWebImage/Core (= 5.18.8)
- SDWebImage/Core (5.18.8)
- share_plus (0.0.1): - share_plus (0.0.1):
- Flutter - Flutter
- shared_preferences_foundation (0.0.1): - shared_preferences_foundation (0.0.1):
- Flutter - Flutter
- FlutterMacOS - FlutterMacOS
- SwiftyGif (5.4.4)
- url_launcher_ios (0.0.1): - url_launcher_ios (0.0.1):
- Flutter - Flutter
DEPENDENCIES: DEPENDENCIES:
- file_picker (from `.symlinks/plugins/file_picker/ios`)
- firebase_core (from `.symlinks/plugins/firebase_core/ios`) - firebase_core (from `.symlinks/plugins/firebase_core/ios`)
- firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`) - firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`)
- Flutter (from `Flutter`) - Flutter (from `Flutter`)
@ -84,6 +123,8 @@ DEPENDENCIES:
SPEC REPOS: SPEC REPOS:
trunk: trunk:
- DKImagePickerController
- DKPhotoGallery
- Firebase - Firebase
- FirebaseCore - FirebaseCore
- FirebaseCoreInternal - FirebaseCoreInternal
@ -93,8 +134,12 @@ SPEC REPOS:
- GoogleUtilities - GoogleUtilities
- nanopb - nanopb
- PromisesObjC - PromisesObjC
- SDWebImage
- SwiftyGif
EXTERNAL SOURCES: EXTERNAL SOURCES:
file_picker:
:path: ".symlinks/plugins/file_picker/ios"
firebase_core: firebase_core:
:path: ".symlinks/plugins/firebase_core/ios" :path: ".symlinks/plugins/firebase_core/ios"
firebase_messaging: firebase_messaging:
@ -113,6 +158,9 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/url_launcher_ios/ios" :path: ".symlinks/plugins/url_launcher_ios/ios"
SPEC CHECKSUMS: SPEC CHECKSUMS:
DKImagePickerController: b512c28220a2b8ac7419f21c491fc8534b7601ac
DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179
file_picker: 15fd9539e4eb735dc54bae8c0534a7a9511a03de
Firebase: bd152f0f3d278c4060c5c71359db08ebcfd5a3e2 Firebase: bd152f0f3d278c4060c5c71359db08ebcfd5a3e2
firebase_core: ce64b0941c6d87c6ef5022ae9116a158236c8c94 firebase_core: ce64b0941c6d87c6ef5022ae9116a158236c8c94
firebase_messaging: 42912365e62efc1ea3e00724e5eecba6068ddb88 firebase_messaging: 42912365e62efc1ea3e00724e5eecba6068ddb88
@ -127,8 +175,10 @@ SPEC CHECKSUMS:
nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431 nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943 path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
PromisesObjC: 09985d6d70fbe7878040aa746d78236e6946d2ef PromisesObjC: 09985d6d70fbe7878040aa746d78236e6946d2ef
SDWebImage: a81bbb3ba4ea5f810f4069c68727cb118467a04a
share_plus: c3fef564749587fc939ef86ffb283ceac0baf9f5 share_plus: c3fef564749587fc939ef86ffb283ceac0baf9f5
shared_preferences_foundation: e2dae3258e06f44cc55f49d42024fd8dd03c590c shared_preferences_foundation: e2dae3258e06f44cc55f49d42024fd8dd03c590c
SwiftyGif: 93a1cc87bf3a51916001cf8f3d63835fb64c819f
url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4 url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4
PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3 PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3

View File

@ -13,6 +13,7 @@ class _ObjectScreenState extends State<ObjectScreen> {
final Map<String,dynamic> _project; final Map<String,dynamic> _project;
Map<String,dynamic> _object; Map<String,dynamic> _object;
Map<String,dynamic>? _pattern; Map<String,dynamic>? _pattern;
bool _isLoading = false;
final Function _onUpdate; final Function _onUpdate;
final Function _onDelete; final Function _onDelete;
final Api api = Api(); final Api api = Api();
@ -38,6 +39,7 @@ class _ObjectScreenState extends State<ObjectScreen> {
} }
void _shareObject() async { void _shareObject() async {
setState(() => _isLoading = true);
File? file; File? file;
if (_object['type'] == 'pattern') { if (_object['type'] == 'pattern') {
var data = await api.request('GET', '/objects/' + _object['_id'] + '/wif'); var data = await api.request('GET', '/objects/' + _object['_id'] + '/wif');
@ -52,6 +54,7 @@ class _ObjectScreenState extends State<ObjectScreen> {
if (file != null) { if (file != null) {
util.shareFile(file!); util.shareFile(file!);
} }
setState(() => _isLoading = false);
} }
void _deleteObject(BuildContext context, BuildContext modalContext) async { void _deleteObject(BuildContext context, BuildContext modalContext) async {
@ -213,7 +216,12 @@ class _ObjectScreenState extends State<ObjectScreen> {
), ),
body: Container( body: Container(
margin: const EdgeInsets.all(10.0), margin: const EdgeInsets.all(10.0),
child: getObjectWidget(), child: Column(
children: [
_isLoading ? LinearProgressIndicator() : SizedBox(height: 0),
Expanded(child: getObjectWidget()),
]
)
), ),
); );
} }

View File

@ -2,8 +2,11 @@ import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:image_picker/image_picker.dart'; import 'package:image_picker/image_picker.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter_expandable_fab/flutter_expandable_fab.dart';
import 'dart:io'; import 'dart:io';
import 'api.dart'; import 'api.dart';
import 'util.dart';
import 'object.dart'; import 'object.dart';
class _ProjectScreenState extends State<ProjectScreen> { class _ProjectScreenState extends State<ProjectScreen> {
@ -11,6 +14,7 @@ class _ProjectScreenState extends State<ProjectScreen> {
final Function _onDelete; final Function _onDelete;
final picker = ImagePicker(); final picker = ImagePicker();
final Api api = Api(); final Api api = Api();
final Util util = Util();
Map<String,dynamic> _project; Map<String,dynamic> _project;
List<dynamic> _objects = []; List<dynamic> _objects = [];
bool _loading = false; bool _loading = false;
@ -36,6 +40,10 @@ class _ProjectScreenState extends State<ProjectScreen> {
} }
} }
void _shareProject() {
util.shareUrl('Check out my project on Treadl', util.appUrl(_project['fullName']));
}
void _onDeleteProject() { void _onDeleteProject() {
Navigator.pop(context); Navigator.pop(context);
_onDelete(_project['_id']); _onDelete(_project['_id']);
@ -65,6 +73,16 @@ class _ProjectScreenState extends State<ProjectScreen> {
}); });
} }
void _chooseFile() async {
FilePickerResult? result = await FilePicker.platform.pickFiles();
if (result != null) {
PlatformFile file = result.files.single;
print(file.extension);
} else {
// User canceled the picker
}
}
void _chooseImage() async { void _chooseImage() async {
File file; File file;
try { try {
@ -236,6 +254,12 @@ class _ProjectScreenState extends State<ProjectScreen> {
appBar: AppBar( appBar: AppBar(
title: Text(_project['name']), title: Text(_project['name']),
actions: <Widget>[ actions: <Widget>[
IconButton(
icon: Icon(Icons.ios_share),
onPressed: () {
_shareProject();
},
),
IconButton( IconButton(
icon: Icon(Icons.settings), icon: Icon(Icons.settings),
onPressed: () { onPressed: () {
@ -269,10 +293,20 @@ class _ProjectScreenState extends State<ProjectScreen> {
Text('Add something to this project using the button below.', textAlign: TextAlign.center), Text('Add something to this project using the button below.', textAlign: TextAlign.center),
]) ])
), ),
floatingActionButton: FloatingActionButton( floatingActionButtonLocation: ExpandableFab.location,
onPressed: _chooseImage, floatingActionButton: ExpandableFab(
child: Icon(Icons.cloud_upload), children: [
backgroundColor: Colors.pink[500], FloatingActionButton(
heroTag: null,
onPressed: _chooseImage,
child: Icon(Icons.image_outlined),
),
FloatingActionButton(
heroTag: null,
child: const Icon(Icons.insert_drive_file_outlined),
onPressed: _chooseFile,
),
],
), ),
); );
} }

View File

@ -4,6 +4,8 @@ import 'package:share_plus/share_plus.dart';
import 'dart:io'; import 'dart:io';
import 'api.dart'; import 'api.dart';
String APP_URL = 'https://www.treadl.com';
class Util { class Util {
ImageProvider avatarUrl(Map<String,dynamic> user) { ImageProvider avatarUrl(Map<String,dynamic> user) {
@ -40,6 +42,10 @@ class Util {
return Color.fromRGBO(iParts[0], iParts[1], iParts[2], 1); return Color.fromRGBO(iParts[0], iParts[1], iParts[2], 1);
} }
String appUrl(String path) {
return APP_URL + '/' + path;
}
Future<String> storagePath() async { Future<String> storagePath() async {
final Directory directory = await getApplicationDocumentsDirectory(); final Directory directory = await getApplicationDocumentsDirectory();
return directory.path; return directory.path;

View File

@ -129,6 +129,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "6.1.4" version: "6.1.4"
file_picker:
dependency: "direct main"
description:
name: file_picker
sha256: "4e42aacde3b993c5947467ab640882c56947d9d27342a5b6f2895b23956954a6"
url: "https://pub.dev"
source: hosted
version: "6.1.1"
file_selector_linux: file_selector_linux:
dependency: transitive dependency: transitive
description: description:
@ -214,6 +222,14 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
flutter_expandable_fab:
dependency: "direct main"
description:
name: flutter_expandable_fab
sha256: "2aa5735bebcdbc49f43bcb32a29f9f03a9b7029212b8cd9837ae332ab2edf647"
url: "https://pub.dev"
source: hosted
version: "2.0.0"
flutter_html: flutter_html:
dependency: "direct main" dependency: "direct main"
description: description:
@ -745,10 +761,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: win32 name: win32
sha256: "5a751eddf9db89b3e5f9d50c20ab8612296e4e8db69009788d6c8b060a84191c" sha256: f2add6fa510d3ae152903412227bda57d0d5a8da61d2c39c1fb022c9429a41c0
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.1.4" version: "5.0.6"
xdg_directories: xdg_directories:
dependency: transitive dependency: transitive
description: description:

View File

@ -31,10 +31,13 @@ dependencies:
flutter_html: ^3.0.0-alpha.3 flutter_html: ^3.0.0-alpha.3
intl: ^0.17.0 intl: ^0.17.0
image_picker: ^0.8.5+3 image_picker: ^0.8.5+3
file_picker: ^6.1.1
flutter_launcher_icons: ^0.9.0 flutter_launcher_icons: ^0.9.0
firebase_messaging: ^14.4.0 firebase_messaging: ^14.4.0
path_provider: ^2.1.1 path_provider: ^2.1.1
share_plus: ^7.2.1 share_plus: ^7.2.1
flutter_expandable_fab: ^2.0.0
#fluttertoast: ^8.0.9 #fluttertoast: ^8.0.9
dev_dependencies: dev_dependencies: