This repository has been archived by the owner on Jun 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscrachpad.dart
134 lines (113 loc) · 3.2 KB
/
scrachpad.dart
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
import 'package:flutter/material.dart';
import 'package:path_provider/path_provider.dart';
import 'lib/fbLib/fbAuthLib.dart';
import 'package:uuid/uuid.dart';
import 'dart:async';
import 'dart:io';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:path_provider/path_provider.dart';
import 'dart:io';
import 'dart:async';
class ChatScreen extends StatefulWidget {
final String id, name, description;
ChatScreen(this.id, this.name, this.description);
@override
State createState() => new ChatScreenState(id, name, description);
}
class ChatScreenState extends State<ChatScreen> {
final String id, name, description;
final Uuid uuid = new Uuid();
bool canRecord = false;
double recordPower = 0.0;
double recordPosition = 0.0;
bool isRecord = false;
bool isPlay = false;
double playPosition = 0.0;
String currentTopic = "!EMPTY!";
ChatScreenState(this.id, this.name, this.description);
Future<String> get _localPath async {
final directory = await getApplicationDocumentsDirectory();
return directory.path;
}
Future _initialize() async{
return;
}
@override
Widget build(BuildContext context){
_initialize();
return new Scaffold(
appBar: new AppBar(title: new Text(id)),
body: new Center(
child: new FloatingActionButton(
onPressed: () {
},
child: new Text('Do Audio Thiny'),
),
),
);
}
}
// --------------------------
//var key = AuthenticationKey();
//key.createAccount("[email protected]", "test123");
//key.fbUser
// -------------
class AudioItem{
FirebaseUser user;
var audioObject;
var locale;
var timeStamp;
var uid;
Map<String, dynamic> toMap() => {
'audio': this.audioObject,
'locale': this.locale,
'timestamp': this.timeStamp,
'uid': this.uid,
};
static AudioItem fromMap(Map<String, dynamic> map) {
AudioItem _obj = AudioItem();
_obj.audioObject = map['audio'];
_obj.locale = map['locale'];
_obj.timeStamp = map['timestamp'];
_obj.uid = map['uid'];
return _obj;
}
}
class Audio{
String path;
List<int> audioBytes;
File audioFile;
FirebaseUser user;
String collectionName;
List<double> locale;
CollectionReference collection;
Audio(String path, List<double> locale, FirebaseUser user, [collectionName="community"]){
this.path = path;
this.user = user;
this.collectionName = collectionName;
this.collection = Firestore.instance.collection(collectionName);
this.audioFile = File(path);
this.locale = locale;
}
Future<Map<String, dynamic>> _generateDI() async {
this.audioBytes = await audioFile.readAsBytes();
return {
'audio': this.audioBytes,
'locale': new GeoPoint(this.locale[0], this.locale[1]),
'timestamp': DateTime.now().toUtc().toIso8601String(),
'uid': this.user.uid,
};
}
void create() async{
var di = await _generateDI();
final TransactionHandler transactionCreator = (Transaction tx) async {
final DocumentSnapshot newDoc = await tx.get(collection.document());
await tx.set(newDoc.reference, di);
return di;
};
print("as");
print(di);
print("sa");
}
}