Anuj-Panthri commited on
Commit
f21ac8b
Β·
1 Parent(s): 7c7b2d5

renamed everything to make everything consistent

Browse files
client/lib/Loading.dart CHANGED
@@ -5,7 +5,7 @@ class Loading extends StatelessWidget{
5
 
6
  @override
7
  Widget build(BuildContext context){
8
- return Scaffold(
9
  body:Center(
10
  child:Text("Loading..."),
11
  ),
 
5
 
6
  @override
7
  Widget build(BuildContext context){
8
+ return const Scaffold(
9
  body:Center(
10
  child:Text("Loading..."),
11
  ),
client/lib/Vibration_exporter.dart CHANGED
@@ -1,3 +1,3 @@
1
- export "unsupported.dart"
2
- if (dart.library.js) 'vibrate_web.dart'
3
  if (dart.library.io) 'package:vibration/vibration.dart' show Vibration;
 
1
+ export "vibration_unsupported.dart"
2
+ if (dart.library.js) 'vibration_web.dart'
3
  if (dart.library.io) 'package:vibration/vibration.dart' show Vibration;
client/lib/{CustomButton.dart β†’ custom_button.dart} RENAMED
File without changes
client/lib/{Colors/CustomColorPicker.dart β†’ custom_color_picker_widget.dart} RENAMED
@@ -1,27 +1,27 @@
1
  import 'package:flutter/material.dart';
2
  import 'package:flutter_colorpicker/flutter_colorpicker.dart';
3
- import '../CustomButton.dart';
4
 
5
- class CustomColorPicker extends StatefulWidget{
6
- CustomColorPicker({
7
  Key? key,
8
  required this.pickerColor,
9
  required this.onSubmit,
10
  required this.size,
11
  }):super(key:key);
12
 
13
- Color pickerColor;
14
  final void Function(Color) onSubmit;
15
  final double size;
16
 
17
  @override
18
- State<CustomColorPicker> createState(){
19
- return CustomColorPickerState();
20
  }
21
 
22
  }
23
 
24
- class CustomColorPickerState extends State<CustomColorPicker>{
25
  late Color pickerColor;
26
  @override
27
  void initState(){
 
1
  import 'package:flutter/material.dart';
2
  import 'package:flutter_colorpicker/flutter_colorpicker.dart';
3
+ import 'custom_button.dart';
4
 
5
+ class CustomColorPickerWidget extends StatefulWidget{
6
+ const CustomColorPickerWidget({
7
  Key? key,
8
  required this.pickerColor,
9
  required this.onSubmit,
10
  required this.size,
11
  }):super(key:key);
12
 
13
+ final Color pickerColor;
14
  final void Function(Color) onSubmit;
15
  final double size;
16
 
17
  @override
18
+ State<CustomColorPickerWidget> createState(){
19
+ return CustomColorPickerWidgetState();
20
  }
21
 
22
  }
23
 
24
+ class CustomColorPickerWidgetState extends State<CustomColorPickerWidget>{
25
  late Color pickerColor;
26
  @override
27
  void initState(){
client/lib/{HomeScreen.dart β†’ home_screen.dart} RENAMED
@@ -4,18 +4,14 @@ import 'package:flutter/scheduler.dart'; // to add scheduler for touch collisio
4
 
5
  import 'package:shared_preferences/shared_preferences.dart';
6
 
7
- import 'package:web_socket_channel/web_socket_channel.dart';
8
- import 'package:web_socket_channel/status.dart' as status;
9
 
10
  import 'ws_server_connection_handler.dart';
11
 
12
  import 'package:flutter_colorpicker/flutter_colorpicker.dart';
13
 
14
  import 'package:flutter/foundation.dart' show kIsWeb; // to check of platform is web
15
- import 'Vibration_exporter.dart';
16
- // import 'vibrate_web.dart' if(kIsWeb) 'package:vibration/vibration.dart'; // import based on platform
17
- // import 'package:vibration/vibration.dart' if(kIsWeb) 'vibrate_web.dart'; // import based on platform
18
-
19
 
20
  import "dart:convert";
21
  import "dart:async";
@@ -38,7 +34,7 @@ class HomeScreen extends StatefulWidget{
38
  }
39
 
40
  class HomeScreenState extends State<HomeScreen>{
41
- late Custom_ws_channel channel;
42
  late double width,height;
43
  late SharedPreferences prefs;
44
  double containerHeight = 0,containerWidth=0;
@@ -58,8 +54,8 @@ class HomeScreenState extends State<HomeScreen>{
58
  String profileColor="ff000000";
59
  Map<String,Map> othersTouchPoints={};
60
  final double outsidepadding=15;
61
- final int touchRefreshRate = (1000/30).toInt(); // 30 fps
62
- // final int touchRefreshRate = (1000/1).toInt(); // 30 fps
63
 
64
  GlobalKey headerKey = GlobalKey(); // to calculate the header's height
65
 
@@ -108,7 +104,7 @@ class HomeScreenState extends State<HomeScreen>{
108
  // vibration_web.test();
109
  // vibration_web.vibrate(pattern:[200,100]);
110
  // vibration_web.vibrate(pattern:[100]);
111
- // debugPrint("asdasdas");
112
 
113
  }
114
 
@@ -130,7 +126,7 @@ class HomeScreenState extends State<HomeScreen>{
130
 
131
  double? getHeaderHeight(){
132
  var size=headerKey.currentContext?.size;
133
- // print(size?.height);
134
  return size?.height;
135
  }
136
 
@@ -154,12 +150,12 @@ class HomeScreenState extends State<HomeScreen>{
154
 
155
  void connectWebsocket() async{
156
 
157
- channel=Custom_ws_channel(
158
  const String.fromEnvironment(
159
  "WS_SERVER_URL",
160
  defaultValue: "ws://localhost:3000"
161
  ),
162
- onMessage: response_handler,
163
  // onMessage: (value){},
164
  onErrorShowMessage:(msg,e){showSnackBar(msg);},
165
  );
@@ -174,7 +170,7 @@ class HomeScreenState extends State<HomeScreen>{
174
 
175
  }
176
 
177
- void response_handler(message) {
178
  // message.get
179
  Map map;
180
  final String type;
@@ -182,13 +178,13 @@ class HomeScreenState extends State<HomeScreen>{
182
  map = jsonDecode(message);
183
  }
184
  catch(e){
185
- print("can't decode to json:\t"+message);
186
  return;
187
  }
188
 
189
  // if any error found do nothing
190
  if(map.containsKey("error")){
191
- print(map);
192
  return;
193
  }
194
 
@@ -196,27 +192,27 @@ class HomeScreenState extends State<HomeScreen>{
196
 
197
  if(type=="test_connection_response"){
198
  // testing connection
199
- print("test_connection successful");
200
 
201
  }
202
  else if(type=="join_room_response"){
203
- print(map);
204
  }
205
  else if(type=="set_username_response"){
206
- print(map);
207
  setState(() {
208
  userid=map['user']['id'];
209
  });
210
  }
211
  else if(type=="get_rooms_response"){
212
- print(map);
213
  }
214
  else if(type=="room_update"){
215
- print(map);
216
  enterRoom(map);
217
  }
218
  else if(type=="send_vibration_response"){ // handles when we send_touch without being in a room
219
- print(map);
220
  showSnackBar(map['status']);
221
  setState(() {
222
  currRoomId="";
@@ -225,26 +221,24 @@ class HomeScreenState extends State<HomeScreen>{
225
  }
226
  else if(type=="receive_touch"){
227
  if(map['user']['id']==userid){
228
- // ignore this
229
- // print("self touch received. Ignore this");
230
  return;
231
  }
232
 
233
  // touch received to update othersTouchPoints
234
- // print(map);
235
-
236
  if(map['type']=='enabled'){ // add touch point
237
 
238
- // static width and height
239
- double staticHeight=getHeaderHeight()!+outsidepadding*2; // this is the extra static height which change with resize
240
- double staticWidth=outsidepadding*2; // this is the extra static height which change with resize
241
-
242
- // rescale point according to the screen
243
- map['position']['x']*=width-staticWidth;
244
- map['position']['y']*=height-staticHeight;
245
-
246
- // print(map['position']['x'].toString());
247
- // print(map['position']['y'].toString());
248
  setState(() {
249
  othersTouchPoints[map['id']]=map;
250
  });
@@ -349,10 +343,10 @@ class HomeScreenState extends State<HomeScreen>{
349
  }
350
 
351
  Widget header(){
352
- final Color buttoncolor=Color.fromARGB(255, 70, 70, 70);
353
  return Padding(
354
  key:headerKey,
355
- padding:EdgeInsets.symmetric(vertical:20),
356
  child:Row(
357
  mainAxisAlignment: MainAxisAlignment.spaceBetween,
358
  children: [
@@ -394,7 +388,7 @@ class HomeScreenState extends State<HomeScreen>{
394
  children:[
395
  Text(
396
  currRoomName.isEmpty?"Lobby":currRoomName,
397
- style:TextStyle(
398
  fontSize: 20,
399
  fontWeight: FontWeight.w500,
400
  overflow:TextOverflow.ellipsis,
@@ -402,10 +396,10 @@ class HomeScreenState extends State<HomeScreen>{
402
  ),
403
  if(containerHeight==0)...[
404
 
405
- Icon(Icons.arrow_drop_down),
406
  ]
407
  else...[
408
- Icon(Icons.arrow_drop_up),
409
  ]
410
 
411
  ]),
@@ -422,7 +416,7 @@ class HomeScreenState extends State<HomeScreen>{
422
  // iconSize:30,
423
  tooltip: "setings",
424
  onPressed: (){},
425
- icon: Icon(
426
  Icons.settings,
427
  color:Colors.white,
428
  ),
@@ -462,8 +456,8 @@ class HomeScreenState extends State<HomeScreen>{
462
  "color": profileColor, // Hex value. Default: random
463
  // "intensity"?: 1 // Vibration intensity. Default: 1
464
  };
465
- // print(data['position']['x']);
466
- // print(data['position']['y']);
467
  channel.sink.add(jsonEncode(data));
468
  }
469
  );
@@ -532,20 +526,17 @@ class HomeScreenState extends State<HomeScreen>{
532
  required double y,
533
  }){
534
  // detect our touch point collision with any othersTouchPoints
535
- // print(othersTouchPoints);
536
- // print("listening");
537
  for(Map map in othersTouchPoints.values){
538
 
539
- // print("inside");
540
  double dx = (map["position"]["x"]-x).abs();
541
  double dy = (map["position"]["y"]-y).abs();
542
- // print("x:"+x.toString()+"\ty:"+y.toString());
543
- // print("dx:"+dx.toString()+"\tdy:"+dy.toString());
544
  if (dx<=touchsize && dy<=touchsize){
545
 
546
  if(hasCollided==false){
547
  // Collision Started
548
- print("Touch Collision started");
549
 
550
  startHapticFeedback();
551
 
@@ -558,7 +549,7 @@ class HomeScreenState extends State<HomeScreen>{
558
 
559
  if(hasCollided==true){
560
  // collision ended
561
- print("Touch Collision ended");
562
 
563
  endHapticFeedback();
564
 
@@ -566,7 +557,7 @@ class HomeScreenState extends State<HomeScreen>{
566
  hasCollided=false;
567
  });
568
  }
569
- // print("No Touch Collision.");
570
  }
571
  }
572
  }
@@ -581,10 +572,6 @@ class HomeScreenState extends State<HomeScreen>{
581
  // off,on,off
582
  Vibration.vibrate(pattern:[20,100], repeat: 0); // short fast
583
  // Vibration.vibrate(pattern:[200,2000,200], repeat: 0); // short fast
584
-
585
- // Vibration.vibrate(pattern:[0,20,100,30], repeat: 0); // short fast
586
- // Vibration.vibrate(pattern:[20,100,30], repeat: 0); // short fast
587
-
588
  // HapticFeedback.heavyImpact();
589
  }
590
  else{
@@ -597,13 +584,13 @@ class HomeScreenState extends State<HomeScreen>{
597
  }
598
 
599
  }
600
- void endHapticFeedback(){
601
  if(kIsWeb){
602
  // different handler for web
603
  Vibration.cancel();
604
  }
605
  else{
606
- if (Vibration.hasVibrator()==true) {
607
  Vibration.cancel();
608
  }
609
  }
@@ -611,7 +598,7 @@ class HomeScreenState extends State<HomeScreen>{
611
 
612
  void detectTouchStart(DragStartDetails details){
613
  // we have to stop see touch out of touch area
614
- // print(details.localPosition);
615
 
616
  // detect Collision
617
  detectTouchCollision(
@@ -647,13 +634,13 @@ class HomeScreenState extends State<HomeScreen>{
647
  y:details.localPosition.dy,
648
  );
649
 
650
- // print(details.localPosition);
651
  setState(() {
652
  touchX = details.localPosition.dx;
653
  touchY = details.localPosition.dy;
654
  });
655
- // print(profileColor);
656
- // print(details.localPosition);
657
 
658
  }
659
 
@@ -699,7 +686,7 @@ class HomeScreenState extends State<HomeScreen>{
699
  child:Container(
700
  decoration: BoxDecoration(
701
  // color:Colors.grey.shade900,
702
- color:Color.fromARGB(255, 30, 30, 30),
703
  borderRadius: BorderRadius.circular(50),
704
  ),
705
  clipBehavior: Clip.hardEdge,
@@ -737,8 +724,8 @@ class HomeScreenState extends State<HomeScreen>{
737
  }
738
 
739
 
740
-
741
- Widget build(BuildContext){
742
  width=MediaQuery.of(context).size.width;
743
  height=MediaQuery.of(context).size.height;
744
 
@@ -751,7 +738,7 @@ class HomeScreenState extends State<HomeScreen>{
751
 
752
  // background
753
  Container(
754
- color:Color.fromARGB(255, 14, 14, 14),
755
  ),
756
 
757
  //overlay
@@ -771,20 +758,20 @@ class HomeScreenState extends State<HomeScreen>{
771
  Positioned(
772
  top:100,
773
  child: AnimatedContainer(
774
- duration: Duration(milliseconds: 100),
775
  height: containerHeight,
776
  width: containerHeight,
777
  clipBehavior: Clip.hardEdge,
778
- decoration: BoxDecoration(
779
- color:const Color.fromARGB(255, 67, 67, 67),
780
- borderRadius: BorderRadius.circular(40),
 
 
 
 
 
 
781
  ),
782
- // child:TextFormField(
783
- // initialValue:currRoomId,
784
- // // decoration: InputDecoration(
785
- // // val
786
- // // ),
787
- // ),
788
  // child: ListView.builder(
789
  // itemCount: roomidList.length,
790
  // itemBuilder: ((context, index){
 
4
 
5
  import 'package:shared_preferences/shared_preferences.dart';
6
 
7
+ // import 'package:web_socket_channel/status.dart' as status;
 
8
 
9
  import 'ws_server_connection_handler.dart';
10
 
11
  import 'package:flutter_colorpicker/flutter_colorpicker.dart';
12
 
13
  import 'package:flutter/foundation.dart' show kIsWeb; // to check of platform is web
14
+ import 'vibration_exporter.dart';
 
 
 
15
 
16
  import "dart:convert";
17
  import "dart:async";
 
34
  }
35
 
36
  class HomeScreenState extends State<HomeScreen>{
37
+ late CustomWSChannel channel;
38
  late double width,height;
39
  late SharedPreferences prefs;
40
  double containerHeight = 0,containerWidth=0;
 
54
  String profileColor="ff000000";
55
  Map<String,Map> othersTouchPoints={};
56
  final double outsidepadding=15;
57
+ final int touchRefreshRate = 1000~/30; // 30 fps
58
+ // final int touchRefreshRate = 1000~/60; // 60 fps
59
 
60
  GlobalKey headerKey = GlobalKey(); // to calculate the header's height
61
 
 
104
  // vibration_web.test();
105
  // vibration_web.vibrate(pattern:[200,100]);
106
  // vibration_web.vibrate(pattern:[100]);
107
+ // debugdebugPrint("asdasdas");
108
 
109
  }
110
 
 
126
 
127
  double? getHeaderHeight(){
128
  var size=headerKey.currentContext?.size;
129
+ // debugPrint(size?.height);
130
  return size?.height;
131
  }
132
 
 
150
 
151
  void connectWebsocket() async{
152
 
153
+ channel=CustomWSChannel(
154
  const String.fromEnvironment(
155
  "WS_SERVER_URL",
156
  defaultValue: "ws://localhost:3000"
157
  ),
158
+ onMessage: responseHandler,
159
  // onMessage: (value){},
160
  onErrorShowMessage:(msg,e){showSnackBar(msg);},
161
  );
 
170
 
171
  }
172
 
173
+ void responseHandler(message) {
174
  // message.get
175
  Map map;
176
  final String type;
 
178
  map = jsonDecode(message);
179
  }
180
  catch(e){
181
+ debugPrint("can't decode to json:\t$message");
182
  return;
183
  }
184
 
185
  // if any error found do nothing
186
  if(map.containsKey("error")){
187
+ debugPrint(map.toString());
188
  return;
189
  }
190
 
 
192
 
193
  if(type=="test_connection_response"){
194
  // testing connection
195
+ debugPrint("test_connection successful");
196
 
197
  }
198
  else if(type=="join_room_response"){
199
+ debugPrint(map.toString());
200
  }
201
  else if(type=="set_username_response"){
202
+ debugPrint(map.toString());
203
  setState(() {
204
  userid=map['user']['id'];
205
  });
206
  }
207
  else if(type=="get_rooms_response"){
208
+ debugPrint(map.toString());
209
  }
210
  else if(type=="room_update"){
211
+ debugPrint(map.toString());
212
  enterRoom(map);
213
  }
214
  else if(type=="send_vibration_response"){ // handles when we send_touch without being in a room
215
+ debugPrint(map.toString());
216
  showSnackBar(map['status']);
217
  setState(() {
218
  currRoomId="";
 
221
  }
222
  else if(type=="receive_touch"){
223
  if(map['user']['id']==userid){
224
+ // debugPrint("self touch received. Ignore this");
 
225
  return;
226
  }
227
 
228
  // touch received to update othersTouchPoints
229
+ // debugPrint(map);
 
230
  if(map['type']=='enabled'){ // add touch point
231
 
232
+ // static width and height
233
+ double staticHeight=getHeaderHeight()!+outsidepadding*2; // this is the extra static height which change with resize
234
+ double staticWidth=outsidepadding*2; // this is the extra static height which change with resize
235
+
236
+ // rescale point according to the screen
237
+ map['position']['x']*=width-staticWidth;
238
+ map['position']['y']*=height-staticHeight;
239
+
240
+ // debugPrint(map['position']['x'].toString());
241
+ // debugPrint(map['position']['y'].toString());
242
  setState(() {
243
  othersTouchPoints[map['id']]=map;
244
  });
 
343
  }
344
 
345
  Widget header(){
346
+ Color buttoncolor=const Color.fromARGB(255, 70, 70, 70);
347
  return Padding(
348
  key:headerKey,
349
+ padding:const EdgeInsets.symmetric(vertical:20),
350
  child:Row(
351
  mainAxisAlignment: MainAxisAlignment.spaceBetween,
352
  children: [
 
388
  children:[
389
  Text(
390
  currRoomName.isEmpty?"Lobby":currRoomName,
391
+ style:const TextStyle(
392
  fontSize: 20,
393
  fontWeight: FontWeight.w500,
394
  overflow:TextOverflow.ellipsis,
 
396
  ),
397
  if(containerHeight==0)...[
398
 
399
+ const Icon(Icons.arrow_drop_down),
400
  ]
401
  else...[
402
+ const Icon(Icons.arrow_drop_up),
403
  ]
404
 
405
  ]),
 
416
  // iconSize:30,
417
  tooltip: "setings",
418
  onPressed: (){},
419
+ icon:const Icon(
420
  Icons.settings,
421
  color:Colors.white,
422
  ),
 
456
  "color": profileColor, // Hex value. Default: random
457
  // "intensity"?: 1 // Vibration intensity. Default: 1
458
  };
459
+ // debugPrint(data['position']['x']);
460
+ // debugPrint(data['position']['y']);
461
  channel.sink.add(jsonEncode(data));
462
  }
463
  );
 
526
  required double y,
527
  }){
528
  // detect our touch point collision with any othersTouchPoints
 
 
529
  for(Map map in othersTouchPoints.values){
530
 
 
531
  double dx = (map["position"]["x"]-x).abs();
532
  double dy = (map["position"]["y"]-y).abs();
533
+ // debugPrint("x:"+x.toString()+"\ty:"+y.toString());
534
+ // debugPrint("dx:"+dx.toString()+"\tdy:"+dy.toString());
535
  if (dx<=touchsize && dy<=touchsize){
536
 
537
  if(hasCollided==false){
538
  // Collision Started
539
+ debugPrint("Touch Collision started");
540
 
541
  startHapticFeedback();
542
 
 
549
 
550
  if(hasCollided==true){
551
  // collision ended
552
+ debugPrint("Touch Collision ended");
553
 
554
  endHapticFeedback();
555
 
 
557
  hasCollided=false;
558
  });
559
  }
560
+ // debugPrint("No Touch Collision.");
561
  }
562
  }
563
  }
 
572
  // off,on,off
573
  Vibration.vibrate(pattern:[20,100], repeat: 0); // short fast
574
  // Vibration.vibrate(pattern:[200,2000,200], repeat: 0); // short fast
 
 
 
 
575
  // HapticFeedback.heavyImpact();
576
  }
577
  else{
 
584
  }
585
 
586
  }
587
+ void endHapticFeedback() async{
588
  if(kIsWeb){
589
  // different handler for web
590
  Vibration.cancel();
591
  }
592
  else{
593
+ if (await Vibration.hasVibrator()==true) {
594
  Vibration.cancel();
595
  }
596
  }
 
598
 
599
  void detectTouchStart(DragStartDetails details){
600
  // we have to stop see touch out of touch area
601
+ // debugPrint(details.localPosition);
602
 
603
  // detect Collision
604
  detectTouchCollision(
 
634
  y:details.localPosition.dy,
635
  );
636
 
637
+ // debugPrint(details.localPosition);
638
  setState(() {
639
  touchX = details.localPosition.dx;
640
  touchY = details.localPosition.dy;
641
  });
642
+ // debugPrint(profileColor);
643
+ // debugPrint(details.localPosition);
644
 
645
  }
646
 
 
686
  child:Container(
687
  decoration: BoxDecoration(
688
  // color:Colors.grey.shade900,
689
+ color:const Color.fromARGB(255, 30, 30, 30),
690
  borderRadius: BorderRadius.circular(50),
691
  ),
692
  clipBehavior: Clip.hardEdge,
 
724
  }
725
 
726
 
727
+ @override
728
+ Widget build(BuildContext context){
729
  width=MediaQuery.of(context).size.width;
730
  height=MediaQuery.of(context).size.height;
731
 
 
738
 
739
  // background
740
  Container(
741
+ color:const Color.fromARGB(255, 14, 14, 14),
742
  ),
743
 
744
  //overlay
 
758
  Positioned(
759
  top:100,
760
  child: AnimatedContainer(
761
+ duration:const Duration(milliseconds: 100),
762
  height: containerHeight,
763
  width: containerHeight,
764
  clipBehavior: Clip.hardEdge,
765
+ decoration:const BoxDecoration(
766
+ color:Color.fromARGB(255, 67, 67, 67),
767
+ // borderRadius: BorderRadius.circular(40),
768
+ ),
769
+ child:TextFormField(
770
+ initialValue:currRoomId,
771
+ // decoration: InputDecoration(
772
+ // val
773
+ // ),
774
  ),
 
 
 
 
 
 
775
  // child: ListView.builder(
776
  // itemCount: roomidList.length,
777
  // itemBuilder: ((context, index){
client/lib/{LobbyScreen.dart β†’ lobby_screen.dart} RENAMED
@@ -3,9 +3,9 @@ import 'package:shared_preferences/shared_preferences.dart';
3
  import 'package:flutter_colorpicker/flutter_colorpicker.dart';
4
 
5
  import 'package:web_socket_channel/web_socket_channel.dart';
6
- import 'package:web_socket_channel/status.dart' as status;
7
 
8
- import 'RoomScreen.dart';
9
  import 'dart:convert';
10
 
11
  class LobbyScreen extends StatefulWidget{
@@ -53,7 +53,7 @@ class LobbyScreenState extends State<LobbyScreen>{
53
  await channel.ready; // after this we are connected to the server
54
  }
55
  catch(e){
56
- print("Can't connect to the web socket server");
57
  return;
58
  }
59
 
@@ -87,13 +87,13 @@ class LobbyScreenState extends State<LobbyScreen>{
87
  map = jsonDecode(message);
88
  }
89
  catch(e){
90
- print("can't decode to json:\t"+message);
91
  return;
92
  }
93
 
94
  // if any error found do nothing
95
  if(map.containsKey("error")){
96
- print(map);
97
  return;
98
  }
99
 
@@ -101,20 +101,20 @@ class LobbyScreenState extends State<LobbyScreen>{
101
 
102
  if(type=="test_connection_response"){
103
  // testing connection
104
- print("test_connection successful");
105
 
106
  }
107
  else if(type=="join_room_response"){
108
- print(map);
109
  }
110
  else if(type=="set_username_response"){
111
- print(map);
112
  }
113
  else if(type=="get_rooms_response"){
114
- print(map);
115
  }
116
  else if(type=="room_update"){
117
- print(map);
118
  goToRoom(map);
119
  }
120
 
@@ -145,7 +145,7 @@ class LobbyScreenState extends State<LobbyScreen>{
145
  await channel.ready;
146
  }
147
  catch(e){
148
- print("Can't connect to the web socket server");
149
  return;
150
  }
151
 
@@ -184,7 +184,7 @@ class LobbyScreenState extends State<LobbyScreen>{
184
  }
185
 
186
  Widget buildEmptyLobby(){
187
- return Text(
188
  "No Rooms yet"
189
  );
190
  }
@@ -206,7 +206,7 @@ class LobbyScreenState extends State<LobbyScreen>{
206
  children:[
207
  Text(
208
  roomidList[index], // room name
209
- style:TextStyle(
210
  color:Colors.white,
211
  fontSize:20,
212
  ),
 
3
  import 'package:flutter_colorpicker/flutter_colorpicker.dart';
4
 
5
  import 'package:web_socket_channel/web_socket_channel.dart';
6
+ // import 'package:web_socket_channel/status.dart' as status;
7
 
8
+ import 'room_screen.dart';
9
  import 'dart:convert';
10
 
11
  class LobbyScreen extends StatefulWidget{
 
53
  await channel.ready; // after this we are connected to the server
54
  }
55
  catch(e){
56
+ debugPrint("Can't connect to the web socket server");
57
  return;
58
  }
59
 
 
87
  map = jsonDecode(message);
88
  }
89
  catch(e){
90
+ debugPrint("can't decode to json:\t$message");
91
  return;
92
  }
93
 
94
  // if any error found do nothing
95
  if(map.containsKey("error")){
96
+ debugPrint(map.toString());
97
  return;
98
  }
99
 
 
101
 
102
  if(type=="test_connection_response"){
103
  // testing connection
104
+ debugPrint("test_connection successful");
105
 
106
  }
107
  else if(type=="join_room_response"){
108
+ debugPrint(map.toString());
109
  }
110
  else if(type=="set_username_response"){
111
+ debugPrint(map.toString());
112
  }
113
  else if(type=="get_rooms_response"){
114
+ debugPrint(map.toString());
115
  }
116
  else if(type=="room_update"){
117
+ debugPrint(map.toString());
118
  goToRoom(map);
119
  }
120
 
 
145
  await channel.ready;
146
  }
147
  catch(e){
148
+ debugPrint("Can't connect to the web socket server");
149
  return;
150
  }
151
 
 
184
  }
185
 
186
  Widget buildEmptyLobby(){
187
+ return const Text(
188
  "No Rooms yet"
189
  );
190
  }
 
206
  children:[
207
  Text(
208
  roomidList[index], // room name
209
+ style:const TextStyle(
210
  color:Colors.white,
211
  fontSize:20,
212
  ),
client/lib/main.dart CHANGED
@@ -1,10 +1,10 @@
1
  import 'package:flutter/material.dart';
2
  import 'package:after_layout/after_layout.dart';
3
  import 'package:shared_preferences/shared_preferences.dart';
4
- import 'LobbyScreen.dart';
5
- import 'SetupScreen.dart';
6
- import 'HomeScreen.dart';
7
- import 'Loading.dart';
8
 
9
  void main() {
10
  runApp(const MainApp());
@@ -21,7 +21,7 @@ class MainApp extends StatelessWidget {
21
  theme:ThemeData.dark(),
22
  // home: SetupScreen(),
23
  // home: Loading(),
24
- home: Splash(),
25
  );
26
  }
27
  }
@@ -66,6 +66,6 @@ class SplashState extends State<Splash> with AfterLayoutMixin<Splash>{
66
  }
67
  @override
68
  Widget build(BuildContext context){
69
- return Loading();
70
  }
71
  }
 
1
  import 'package:flutter/material.dart';
2
  import 'package:after_layout/after_layout.dart';
3
  import 'package:shared_preferences/shared_preferences.dart';
4
+ // import 'lobby_screen.dart';
5
+ import 'setup_screen.dart';
6
+ import 'home_screen.dart';
7
+ import 'loading.dart';
8
 
9
  void main() {
10
  runApp(const MainApp());
 
21
  theme:ThemeData.dark(),
22
  // home: SetupScreen(),
23
  // home: Loading(),
24
+ home: const Splash(),
25
  );
26
  }
27
  }
 
66
  }
67
  @override
68
  Widget build(BuildContext context){
69
+ return const Loading();
70
  }
71
  }
client/lib/{RoomScreen.dart β†’ room_screen.dart} RENAMED
@@ -11,8 +11,8 @@ void exitFullScreen(){
11
  }
12
 
13
  class RoomScreen extends StatefulWidget{
14
- RoomScreen({super.key,required this.roomdata});
15
- Map roomdata;
16
 
17
  @override
18
  State<RoomScreen> createState(){
@@ -71,9 +71,9 @@ class RoomScreenState extends State<RoomScreen>{
71
  }
72
  }
73
  Widget header(){
74
- final Color buttoncolor=Color.fromARGB(255, 70, 70, 70);
75
  return Padding(
76
- padding:EdgeInsets.symmetric(vertical:20),
77
  child:Stack(
78
  fit: StackFit.passthrough,
79
  clipBehavior: Clip.none,
@@ -90,7 +90,7 @@ class RoomScreenState extends State<RoomScreen>{
90
  style:IconButton.styleFrom(
91
  ),
92
  onPressed: (){},
93
- icon: Icon(Icons.add,color:Colors.white),
94
  ),
95
  ),
96
 
@@ -102,13 +102,13 @@ class RoomScreenState extends State<RoomScreen>{
102
  children:[
103
  Text(
104
  widget.roomdata['roomId'],
105
- style:TextStyle(
106
  fontSize: 20,
107
  fontWeight: FontWeight.w500,
108
  overflow:TextOverflow.ellipsis,
109
  ),
110
  ),
111
- Icon(Icons.arrow_drop_down),
112
 
113
  ]),
114
  ),
@@ -123,7 +123,7 @@ class RoomScreenState extends State<RoomScreen>{
123
  child:IconButton(
124
  // iconSize:30,
125
  onPressed: (){},
126
- icon: Icon(
127
  Icons.settings,
128
  color:Colors.white,
129
  ),
@@ -138,7 +138,7 @@ class RoomScreenState extends State<RoomScreen>{
138
  child:SizedBox(
139
  height: 200,
140
  width:200,
141
- child:Container(color:Colors.white) ,
142
  ),
143
  ),
144
 
@@ -153,24 +153,25 @@ class RoomScreenState extends State<RoomScreen>{
153
  child:Container(
154
  decoration: BoxDecoration(
155
  // color:Colors.grey.shade900,
156
- color:Color(0xff121212),
157
  borderRadius: BorderRadius.circular(50),
158
  ),
159
  // width:width*0.9,
160
- child:SizedBox(),
161
  ),
162
  );
163
  }
164
 
165
- Widget build(BuildContext){
 
166
  width=MediaQuery.of(context).size.width;
167
  height=MediaQuery.of(context).size.height;
168
 
169
  return Scaffold(
170
- backgroundColor: Color(0xff0e0e0e),
171
  // backgroundColor: Colors.white,
172
  body:Padding(
173
- padding: EdgeInsets.all(15),
174
  child:Column(
175
  crossAxisAlignment: CrossAxisAlignment.stretch,
176
  children: [
 
11
  }
12
 
13
  class RoomScreen extends StatefulWidget{
14
+ const RoomScreen({super.key,required this.roomdata});
15
+ final Map roomdata;
16
 
17
  @override
18
  State<RoomScreen> createState(){
 
71
  }
72
  }
73
  Widget header(){
74
+ Color buttoncolor=const Color.fromARGB(255, 70, 70, 70);
75
  return Padding(
76
+ padding:const EdgeInsets.symmetric(vertical:20),
77
  child:Stack(
78
  fit: StackFit.passthrough,
79
  clipBehavior: Clip.none,
 
90
  style:IconButton.styleFrom(
91
  ),
92
  onPressed: (){},
93
+ icon:const Icon(Icons.add,color:Colors.white),
94
  ),
95
  ),
96
 
 
102
  children:[
103
  Text(
104
  widget.roomdata['roomId'],
105
+ style:const TextStyle(
106
  fontSize: 20,
107
  fontWeight: FontWeight.w500,
108
  overflow:TextOverflow.ellipsis,
109
  ),
110
  ),
111
+ const Icon(Icons.arrow_drop_down),
112
 
113
  ]),
114
  ),
 
123
  child:IconButton(
124
  // iconSize:30,
125
  onPressed: (){},
126
+ icon:const Icon(
127
  Icons.settings,
128
  color:Colors.white,
129
  ),
 
138
  child:SizedBox(
139
  height: 200,
140
  width:200,
141
+ child:Container(color:Colors.white),
142
  ),
143
  ),
144
 
 
153
  child:Container(
154
  decoration: BoxDecoration(
155
  // color:Colors.grey.shade900,
156
+ color:const Color(0xff121212),
157
  borderRadius: BorderRadius.circular(50),
158
  ),
159
  // width:width*0.9,
160
+ // child:SizedBox(),
161
  ),
162
  );
163
  }
164
 
165
+ @override
166
+ Widget build(BuildContext context){
167
  width=MediaQuery.of(context).size.width;
168
  height=MediaQuery.of(context).size.height;
169
 
170
  return Scaffold(
171
+ backgroundColor:const Color(0xff0e0e0e),
172
  // backgroundColor: Colors.white,
173
  body:Padding(
174
+ padding:const EdgeInsets.all(15),
175
  child:Column(
176
  crossAxisAlignment: CrossAxisAlignment.stretch,
177
  children: [
client/lib/{SetupScreen.dart β†’ setup_screen.dart} RENAMED
@@ -1,10 +1,9 @@
1
  import 'package:flutter/material.dart';
2
  import 'package:shared_preferences/shared_preferences.dart';
3
- import 'package:hapticlink/LobbyScreen.dart';
4
  import 'package:flutter_colorpicker/flutter_colorpicker.dart';
5
- import 'Colors/CustomColorPicker.dart';
6
- import "CustomButton.dart";
7
- import "HomeScreen.dart";
8
 
9
  class SetupScreen extends StatefulWidget{
10
  const SetupScreen({super.key});
@@ -43,14 +42,11 @@ class _SetupScreenState extends State<SetupScreen>{
43
  return Column(
44
  children: [
45
  // Main Title
46
- Container(
47
- // margin:const EdgeInsets.only(top:70),
48
- child:const Text(
49
- "Haptic Link",
50
- style: TextStyle(
51
- fontSize: 40,
52
- fontWeight: FontWeight.w500,
53
- ),
54
  ),
55
  ),
56
 
@@ -83,7 +79,7 @@ class _SetupScreenState extends State<SetupScreen>{
83
  Container(
84
  margin:const EdgeInsets.only(bottom:20),
85
  child:TextField(
86
- decoration: InputDecoration(
87
  hintText: "Enter your first name",
88
  border:OutlineInputBorder(),
89
  ),
@@ -102,11 +98,11 @@ class _SetupScreenState extends State<SetupScreen>{
102
  children: [
103
 
104
  Container(
105
- margin:EdgeInsets.only(right:20),
106
- child:Text("Choose your Color"),
107
  ),
108
 
109
- CustomColorPicker(
110
  pickerColor: profileColor,
111
  // onColorChanged: (color){},
112
  onSubmit: changeColor,
@@ -147,7 +143,7 @@ class _SetupScreenState extends State<SetupScreen>{
147
  context,
148
  MaterialPageRoute(
149
  // builder: (context)=>LobbyScreen()
150
- builder: (context)=>HomeScreen()
151
  ),
152
 
153
  );
@@ -159,7 +155,7 @@ class _SetupScreenState extends State<SetupScreen>{
159
  Widget build(BuildContext context){
160
  return Scaffold(
161
  body:Container(
162
- padding: EdgeInsets.all(20),
163
 
164
  child: Center(
165
  child: Column(
 
1
  import 'package:flutter/material.dart';
2
  import 'package:shared_preferences/shared_preferences.dart';
 
3
  import 'package:flutter_colorpicker/flutter_colorpicker.dart';
4
+ import 'custom_color_picker_widget.dart';
5
+ import 'custom_button.dart';
6
+ import 'home_screen.dart';
7
 
8
  class SetupScreen extends StatefulWidget{
9
  const SetupScreen({super.key});
 
42
  return Column(
43
  children: [
44
  // Main Title
45
+ const Text(
46
+ "Haptic Link",
47
+ style: TextStyle(
48
+ fontSize: 40,
49
+ fontWeight: FontWeight.w500,
 
 
 
50
  ),
51
  ),
52
 
 
79
  Container(
80
  margin:const EdgeInsets.only(bottom:20),
81
  child:TextField(
82
+ decoration:const InputDecoration(
83
  hintText: "Enter your first name",
84
  border:OutlineInputBorder(),
85
  ),
 
98
  children: [
99
 
100
  Container(
101
+ margin:const EdgeInsets.only(right:20),
102
+ child:const Text("Choose your Color"),
103
  ),
104
 
105
+ CustomColorPickerWidget(
106
  pickerColor: profileColor,
107
  // onColorChanged: (color){},
108
  onSubmit: changeColor,
 
143
  context,
144
  MaterialPageRoute(
145
  // builder: (context)=>LobbyScreen()
146
+ builder: (context)=>const HomeScreen()
147
  ),
148
 
149
  );
 
155
  Widget build(BuildContext context){
156
  return Scaffold(
157
  body:Container(
158
+ padding:const EdgeInsets.all(20),
159
 
160
  child: Center(
161
  child: Column(
client/lib/{unsupported.dart β†’ vibration_unsupported.dart} RENAMED
@@ -6,7 +6,7 @@ class Vibration{
6
  }
7
 
8
  static Future<bool> hasVibrator(){
9
- return Future(() => true);
10
  }
11
 
12
  static void cancel(){
 
6
  }
7
 
8
  static Future<bool> hasVibrator(){
9
+ return Future(() => false);
10
  }
11
 
12
  static void cancel(){
client/lib/{vibrate_web.dart β†’ vibration_web.dart} RENAMED
@@ -1,8 +1,5 @@
1
  import 'dart:js' as js;
2
 
3
- import 'package:flutter/material.dart';
4
- // import 'dart:async';
5
-
6
 
7
  class Vibration{
8
 
 
1
  import 'dart:js' as js;
2
 
 
 
 
3
 
4
  class Vibration{
5
 
client/lib/ws_server_connection_handler.dart CHANGED
@@ -1,7 +1,7 @@
1
  import 'package:web_socket_channel/web_socket_channel.dart';
2
  import 'package:web_socket_channel/status.dart' as status;
3
 
4
- class Custom_ws_channel{
5
  late WebSocketChannel channel;
6
  bool webSocketConnected=false;
7
  int reconnectAttempts=0;
@@ -12,7 +12,7 @@ class Custom_ws_channel{
12
  void Function(String,dynamic) onErrorShowMessage;
13
 
14
 
15
- Custom_ws_channel(this.serverUrl,{this.delay=5,required this.onMessage,required this.onErrorShowMessage}){
16
  serverUri=Uri.parse(serverUrl);
17
  connect();
18
  }
 
1
  import 'package:web_socket_channel/web_socket_channel.dart';
2
  import 'package:web_socket_channel/status.dart' as status;
3
 
4
+ class CustomWSChannel{
5
  late WebSocketChannel channel;
6
  bool webSocketConnected=false;
7
  int reconnectAttempts=0;
 
12
  void Function(String,dynamic) onErrorShowMessage;
13
 
14
 
15
+ CustomWSChannel(this.serverUrl,{this.delay=5,required this.onMessage,required this.onErrorShowMessage}){
16
  serverUri=Uri.parse(serverUrl);
17
  connect();
18
  }