Skip to content

Commit

Permalink
#70 qr bug fix, punch bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
opjoobe committed Aug 3, 2022
1 parent 0659984 commit 714a0b1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 27 deletions.
36 changes: 21 additions & 15 deletions lib/screens/sharing/punch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@ class PunchPage extends StatefulWidget {
class _PunchPageState extends State<PunchPage> {
final Color _backgroundColor = Color.fromARGB(255, 255, 255, 255);
List<double>? _userAccelerometerValues;
var cnt = 0;
bool isTooked = false;

@override
void initState() {
// super.initState();
userAccelerometerEvents.listen((UserAccelerometerEvent event) {
setState(() {
// Manipulate the UI here, something like:
if ((event.y > 5 || event.y < -5) && cnt == 0) {
cnt++;
if (!isTooked) {
userAccelerometerEvents.listen((UserAccelerometerEvent event) {
if ((event.y > 5 || event.y < -5) && !isTooked) {
setState(() {
isTooked = true;
});
Navigator.push(
context,
MaterialPageRoute(
Expand All @@ -37,8 +38,10 @@ class _PunchPageState extends State<PunchPage> {
friendId: widget.friendId,
latlng: widget.latlng,
)));
} else if ((event.x < -4 || event.x > 4) && cnt == 0) {
cnt++;
} else if ((event.x < -4 || event.x > 4) && !isTooked) {
setState(() {
isTooked = true;
});

Navigator.push(
context,
Expand All @@ -48,8 +51,10 @@ class _PunchPageState extends State<PunchPage> {
friendId: widget.friendId,
latlng: widget.latlng,
)));
} else if ((event.z < -4 || event.z > 4) && cnt == 0) {
cnt++;
} else if ((event.z < -4 || event.z > 4) && !isTooked) {
setState(() {
isTooked = true;
});
Navigator.push(
context,
MaterialPageRoute(
Expand All @@ -59,12 +64,13 @@ class _PunchPageState extends State<PunchPage> {
latlng: widget.latlng,
)));
} else {}
super.dispose();
for (final subscription in _streamSubscriptions) {
subscription.cancel();
}
});
});
} else {
super.dispose();
for (final subscription in _streamSubscriptions) {
subscription.cancel();
}
}
}

final _streamSubscriptions = <StreamSubscription<dynamic>>[];
Expand Down
28 changes: 16 additions & 12 deletions lib/screens/sharing/sharing_qr_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ class _QRforTOOKState extends State<QRforTOOK> {
});

socket.on('took', (data) {
int friendId = widget.isSender ? data.receiverID : data.senderID;
socket.emit('leave', data.chatroomID); // receiver, sender 공통
var tookData = Map<String, dynamic>.from(data);
int friendId =
widget.isSender ? tookData['receiverID'] : tookData['senderID'];
socket.emit('leave', tookData['chatroomID']); // receiver, sender 공통
socket.emit('disconnect');
Navigator.push(
context,
Expand Down Expand Up @@ -166,19 +168,21 @@ class _QRforTOOKState extends State<QRforTOOK> {
this.controller = controller;
controller.scannedDataStream.listen((scanData) {
int senderId;
String? chatRoomId = stringToBase64
.decode(scanData.code!); // 'QRTOOKExchange${widget.myId.toString()}'
String? senderIdinStr = chatRoomId.substring(14);
senderId = int.parse(senderIdinStr);

setState(() {
result = scanData;
socket.emit('join', chatRoomId);
socket.emit('took', {
'chatroomID': chatRoomId,
'senderID': senderId,
'receiverID': widget.myId
}); // 칭구
if (result != null) {
String? chatRoomId = stringToBase64.decode(
result!.code!); // 'QRTOOKExchange${widget.myId.toString()}'
String? senderIdinStr = chatRoomId.substring(14);
senderId = int.parse(senderIdinStr);
socket.emit('join', chatRoomId);
socket.emit('took', {
'chatroomID': chatRoomId,
'senderID': senderId,
'receiverID': widget.myId
});
} // 칭구
});
});
}
Expand Down

0 comments on commit 714a0b1

Please sign in to comment.