Spaces:
Runtime error
Runtime error
Commit ·
7715c1b
1
Parent(s): a050fb1
made create/join room functional and showing touch pointer
Browse files- client/lib/HomeScreen.dart +481 -0
- client/lib/LobbyScreen.dart +80 -23
- client/lib/RoomScreen.dart +108 -34
- client/lib/SetupScreen.dart +3 -1
- client/lib/main.dart +4 -2
- server/src/socket/routes.ts +2 -0
client/lib/HomeScreen.dart
ADDED
|
@@ -0,0 +1,481 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import 'package:flutter/material.dart';
|
| 2 |
+
import 'package:flutter/services.dart'; // for going in fullscreen mode
|
| 3 |
+
|
| 4 |
+
import 'package:shared_preferences/shared_preferences.dart';
|
| 5 |
+
|
| 6 |
+
import 'package:web_socket_channel/web_socket_channel.dart';
|
| 7 |
+
import 'package:web_socket_channel/status.dart' as status;
|
| 8 |
+
|
| 9 |
+
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
|
| 10 |
+
|
| 11 |
+
import "dart:convert";
|
| 12 |
+
|
| 13 |
+
void enterFullScreen(){
|
| 14 |
+
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive,overlays: []);
|
| 15 |
+
}
|
| 16 |
+
void exitFullScreen(){
|
| 17 |
+
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,overlays:SystemUiOverlay.values);
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
class HomeScreen extends StatefulWidget{
|
| 21 |
+
const HomeScreen({super.key});
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
@override
|
| 25 |
+
State<HomeScreen> createState(){
|
| 26 |
+
return HomeScreenState();
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
class HomeScreenState extends State<HomeScreen>{
|
| 31 |
+
late WebSocketChannel channel;
|
| 32 |
+
late double width,height;
|
| 33 |
+
late SharedPreferences prefs;
|
| 34 |
+
double containerHeight = 0,containerWidth=0;
|
| 35 |
+
double touchX = 0,touchY=0;
|
| 36 |
+
bool touchIsVisible=false;
|
| 37 |
+
late List<String> roomidList,roomnameList;
|
| 38 |
+
String currRoomId="",currRoomName="";
|
| 39 |
+
String username="";
|
| 40 |
+
String profileColor="";
|
| 41 |
+
final double outsidepadding=15;
|
| 42 |
+
|
| 43 |
+
@override
|
| 44 |
+
void initState(){
|
| 45 |
+
super.initState();
|
| 46 |
+
enterFullScreen();
|
| 47 |
+
roomidList=[];
|
| 48 |
+
roomnameList=[];
|
| 49 |
+
|
| 50 |
+
// roomidList=["1","2"];
|
| 51 |
+
// roomnameList=["room 1","room 2"];
|
| 52 |
+
getPreferences();
|
| 53 |
+
// setPreferences();
|
| 54 |
+
connectWebsocket();
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
@override
|
| 58 |
+
void dispose(){
|
| 59 |
+
exitFullScreen();
|
| 60 |
+
channel.sink.close();
|
| 61 |
+
super.dispose();
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
void getPreferences() async{
|
| 65 |
+
prefs = await SharedPreferences.getInstance();
|
| 66 |
+
|
| 67 |
+
// initialize empty room list if no preferences found
|
| 68 |
+
if(!prefs.containsKey("roomid_list")){
|
| 69 |
+
prefs.setStringList("roomid_list",[]);
|
| 70 |
+
prefs.setStringList("roomname_list",[]);
|
| 71 |
+
}
|
| 72 |
+
// intialize from preferences
|
| 73 |
+
setState(() {
|
| 74 |
+
roomidList=prefs.getStringList("roomid_list")!;
|
| 75 |
+
roomnameList=prefs.getStringList("roomname_list")!;
|
| 76 |
+
username=prefs.getString("username")!;
|
| 77 |
+
profileColor=prefs.getString("profile_color")!;
|
| 78 |
+
});
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
void connectWebsocket() async{
|
| 84 |
+
|
| 85 |
+
try{
|
| 86 |
+
channel=WebSocketChannel.connect(Uri.parse(
|
| 87 |
+
"ws://localhost:3000"
|
| 88 |
+
));
|
| 89 |
+
|
| 90 |
+
await channel.ready; // after this we are connected to the server
|
| 91 |
+
}
|
| 92 |
+
catch(e){
|
| 93 |
+
print("Can't connect to the web socket server");
|
| 94 |
+
return;
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
// test connection
|
| 98 |
+
Object data = {
|
| 99 |
+
"route":"test_connection"
|
| 100 |
+
};
|
| 101 |
+
channel.sink.add(json.encode(data));
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
// // set username
|
| 105 |
+
// data = {
|
| 106 |
+
// "route": "set_username",
|
| 107 |
+
// "username": "anuj",
|
| 108 |
+
// };
|
| 109 |
+
// channel.sink.add(json.encode(data));
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
// // get rooms
|
| 114 |
+
// data = {
|
| 115 |
+
// "route": "get_rooms",
|
| 116 |
+
// };
|
| 117 |
+
// channel.sink.add(json.encode(data));
|
| 118 |
+
|
| 119 |
+
channel.stream.listen((message) {
|
| 120 |
+
// message.get
|
| 121 |
+
final Map map;
|
| 122 |
+
final String type;
|
| 123 |
+
try{
|
| 124 |
+
map = jsonDecode(message);
|
| 125 |
+
}
|
| 126 |
+
catch(e){
|
| 127 |
+
print("can't decode to json:\t"+message);
|
| 128 |
+
return;
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
// if any error found do nothing
|
| 132 |
+
if(map.containsKey("error")){
|
| 133 |
+
print(map);
|
| 134 |
+
return;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
type = map["message"];
|
| 138 |
+
|
| 139 |
+
if(type=="test_connection_response"){
|
| 140 |
+
// testing connection
|
| 141 |
+
print("test_connection successful");
|
| 142 |
+
|
| 143 |
+
}
|
| 144 |
+
else if(type=="join_room_response"){
|
| 145 |
+
print(map);
|
| 146 |
+
}
|
| 147 |
+
else if(type=="set_username_response"){
|
| 148 |
+
print(map);
|
| 149 |
+
}
|
| 150 |
+
else if(type=="get_rooms_response"){
|
| 151 |
+
print(map);
|
| 152 |
+
}
|
| 153 |
+
else if(type=="room_update"){
|
| 154 |
+
print(map);
|
| 155 |
+
enterRoom(map);
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
});
|
| 159 |
+
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
void enterRoom(Map roomdata){
|
| 163 |
+
setState((){
|
| 164 |
+
currRoomId=roomdata['roomId'];
|
| 165 |
+
currRoomName=roomdata['roomId'];
|
| 166 |
+
});
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
void toggleContainer(){
|
| 170 |
+
if(containerHeight==0){
|
| 171 |
+
setState(() {
|
| 172 |
+
containerHeight=200;
|
| 173 |
+
containerWidth=width;
|
| 174 |
+
});
|
| 175 |
+
}
|
| 176 |
+
else{
|
| 177 |
+
setState(() {
|
| 178 |
+
containerHeight=0;
|
| 179 |
+
containerWidth=0;
|
| 180 |
+
});
|
| 181 |
+
}
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
void createRoom({String roomId=""}) async{
|
| 185 |
+
// it is used to create a room in server
|
| 186 |
+
Map data;
|
| 187 |
+
|
| 188 |
+
try{
|
| 189 |
+
await channel.ready;
|
| 190 |
+
}
|
| 191 |
+
catch(e){
|
| 192 |
+
print("Can't connect to the web socket server");
|
| 193 |
+
return;
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
// join room
|
| 197 |
+
data = {
|
| 198 |
+
"route": "join_room",
|
| 199 |
+
"username": username,
|
| 200 |
+
};
|
| 201 |
+
|
| 202 |
+
// to join existing room
|
| 203 |
+
if(roomId.isNotEmpty){
|
| 204 |
+
data["roomId"]=roomId;
|
| 205 |
+
}
|
| 206 |
+
channel.sink.add(json.encode(data));
|
| 207 |
+
|
| 208 |
+
// we will move to the room screen with the server data
|
| 209 |
+
// from the room_update callback
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
void joinRoomForm(){
|
| 213 |
+
// close old dialog
|
| 214 |
+
showDialog(
|
| 215 |
+
context: context,
|
| 216 |
+
builder:(context) {
|
| 217 |
+
// return SingleChildScrollView(
|
| 218 |
+
// child: Text("Enter Room ID"),
|
| 219 |
+
// );
|
| 220 |
+
return AlertDialog(
|
| 221 |
+
content:SingleChildScrollView(
|
| 222 |
+
child:Column(
|
| 223 |
+
children: [
|
| 224 |
+
TextField(
|
| 225 |
+
decoration:const InputDecoration(
|
| 226 |
+
hintText: "Enter Room ID",
|
| 227 |
+
),
|
| 228 |
+
onSubmitted: (value){
|
| 229 |
+
Navigator.pop(context); // close the dialog
|
| 230 |
+
createRoom(roomId:value); // join room
|
| 231 |
+
},
|
| 232 |
+
),
|
| 233 |
+
])
|
| 234 |
+
),
|
| 235 |
+
);
|
| 236 |
+
},
|
| 237 |
+
);
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
Widget header(){
|
| 241 |
+
final Color buttoncolor=Color.fromARGB(255, 70, 70, 70);
|
| 242 |
+
return Padding(
|
| 243 |
+
padding:EdgeInsets.symmetric(vertical:20),
|
| 244 |
+
child:Row(
|
| 245 |
+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
| 246 |
+
children: [
|
| 247 |
+
// create/join room popup
|
| 248 |
+
CircleAvatar(
|
| 249 |
+
backgroundColor: buttoncolor,
|
| 250 |
+
child: PopupMenuButton(
|
| 251 |
+
onSelected: (value){
|
| 252 |
+
switch(value){
|
| 253 |
+
case 'createRoom':
|
| 254 |
+
return createRoom();
|
| 255 |
+
case 'joinRoom':
|
| 256 |
+
return joinRoomForm();
|
| 257 |
+
default:
|
| 258 |
+
throw UnimplementedError();
|
| 259 |
+
}
|
| 260 |
+
},
|
| 261 |
+
icon:const Icon(Icons.add,color:Colors.white),
|
| 262 |
+
tooltip: "Create/Join Room",
|
| 263 |
+
itemBuilder: (context)=>const[
|
| 264 |
+
|
| 265 |
+
PopupMenuItem(
|
| 266 |
+
value:"createRoom",
|
| 267 |
+
child: Text("Create Room"),
|
| 268 |
+
),
|
| 269 |
+
|
| 270 |
+
PopupMenuItem(
|
| 271 |
+
value:"joinRoom",
|
| 272 |
+
child: Text("Join Room"),
|
| 273 |
+
),
|
| 274 |
+
|
| 275 |
+
],
|
| 276 |
+
),
|
| 277 |
+
),
|
| 278 |
+
|
| 279 |
+
GestureDetector(
|
| 280 |
+
onTap:toggleContainer,
|
| 281 |
+
child:Row(
|
| 282 |
+
children:[
|
| 283 |
+
Text(
|
| 284 |
+
currRoomName.isEmpty?"Lobby":currRoomName,
|
| 285 |
+
style:TextStyle(
|
| 286 |
+
fontSize: 20,
|
| 287 |
+
fontWeight: FontWeight.w500,
|
| 288 |
+
overflow:TextOverflow.ellipsis,
|
| 289 |
+
),
|
| 290 |
+
),
|
| 291 |
+
if(containerHeight==0)...[
|
| 292 |
+
|
| 293 |
+
Icon(Icons.arrow_drop_down),
|
| 294 |
+
]
|
| 295 |
+
else...[
|
| 296 |
+
Icon(Icons.arrow_drop_up),
|
| 297 |
+
]
|
| 298 |
+
|
| 299 |
+
]),
|
| 300 |
+
),
|
| 301 |
+
|
| 302 |
+
|
| 303 |
+
|
| 304 |
+
|
| 305 |
+
|
| 306 |
+
// setting button
|
| 307 |
+
CircleAvatar(
|
| 308 |
+
backgroundColor: buttoncolor,
|
| 309 |
+
child:IconButton(
|
| 310 |
+
// iconSize:30,
|
| 311 |
+
tooltip: "setings",
|
| 312 |
+
onPressed: (){},
|
| 313 |
+
icon: Icon(
|
| 314 |
+
Icons.settings,
|
| 315 |
+
color:Colors.white,
|
| 316 |
+
),
|
| 317 |
+
),
|
| 318 |
+
),
|
| 319 |
+
]),
|
| 320 |
+
|
| 321 |
+
|
| 322 |
+
|
| 323 |
+
|
| 324 |
+
);
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
void detectTouchStart(DragStartDetails details){
|
| 328 |
+
// we have to stop see touch out of touch area
|
| 329 |
+
print(details.localPosition);
|
| 330 |
+
setState(() {
|
| 331 |
+
touchX = details.globalPosition.dx;
|
| 332 |
+
touchY = details.globalPosition.dy;
|
| 333 |
+
touchIsVisible=true; // show it
|
| 334 |
+
});
|
| 335 |
+
}
|
| 336 |
+
void detectTouchUpdate(DragUpdateDetails details){
|
| 337 |
+
// we have to stop see touch out of touch area
|
| 338 |
+
|
| 339 |
+
print(details.localPosition);
|
| 340 |
+
setState(() {
|
| 341 |
+
touchX = details.globalPosition.dx;
|
| 342 |
+
touchY = details.globalPosition.dy;
|
| 343 |
+
});
|
| 344 |
+
// print(profileColor);
|
| 345 |
+
// print(details.globalPosition);
|
| 346 |
+
}
|
| 347 |
+
|
| 348 |
+
void detectTouchEnd(DragEndDetails details){
|
| 349 |
+
|
| 350 |
+
setState(() {
|
| 351 |
+
touchX = 0;
|
| 352 |
+
touchY = 0;
|
| 353 |
+
touchIsVisible=false; // hide it
|
| 354 |
+
});
|
| 355 |
+
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
Widget mainSection(){
|
| 359 |
+
return Expanded(
|
| 360 |
+
child: GestureDetector(
|
| 361 |
+
onPanStart:(details){
|
| 362 |
+
detectTouchStart(details);
|
| 363 |
+
},
|
| 364 |
+
onPanUpdate:(details){
|
| 365 |
+
detectTouchUpdate(details);
|
| 366 |
+
},
|
| 367 |
+
onPanEnd:(details){
|
| 368 |
+
detectTouchEnd(details);
|
| 369 |
+
},
|
| 370 |
+
child:Container(
|
| 371 |
+
decoration: BoxDecoration(
|
| 372 |
+
// color:Colors.grey.shade900,
|
| 373 |
+
color:Color.fromARGB(255, 30, 30, 30),
|
| 374 |
+
borderRadius: BorderRadius.circular(50),
|
| 375 |
+
),
|
| 376 |
+
// width:width*0.9,
|
| 377 |
+
|
| 378 |
+
),
|
| 379 |
+
),
|
| 380 |
+
);
|
| 381 |
+
}
|
| 382 |
+
|
| 383 |
+
|
| 384 |
+
|
| 385 |
+
Widget build(BuildContext){
|
| 386 |
+
width=MediaQuery.of(context).size.width-(outsidepadding*2);
|
| 387 |
+
height=MediaQuery.of(context).size.height-(outsidepadding*2);
|
| 388 |
+
|
| 389 |
+
return Scaffold(
|
| 390 |
+
// backgroundColor: Color(0xff0e0e0e),
|
| 391 |
+
// backgroundColor: Colors.white,
|
| 392 |
+
body:Stack(
|
| 393 |
+
alignment: Alignment.center,
|
| 394 |
+
children: [
|
| 395 |
+
|
| 396 |
+
// background
|
| 397 |
+
Container(
|
| 398 |
+
color:Color.fromARGB(255, 14, 14, 14),
|
| 399 |
+
),
|
| 400 |
+
|
| 401 |
+
//overlay
|
| 402 |
+
|
| 403 |
+
Padding(
|
| 404 |
+
padding: EdgeInsets.all(outsidepadding),
|
| 405 |
+
child: Column(
|
| 406 |
+
crossAxisAlignment: CrossAxisAlignment.stretch,
|
| 407 |
+
children: [
|
| 408 |
+
header(),
|
| 409 |
+
mainSection(),
|
| 410 |
+
],
|
| 411 |
+
),
|
| 412 |
+
),
|
| 413 |
+
|
| 414 |
+
//floating Room section
|
| 415 |
+
Positioned(
|
| 416 |
+
top:100,
|
| 417 |
+
child: AnimatedContainer(
|
| 418 |
+
duration: Duration(milliseconds: 100),
|
| 419 |
+
height: containerHeight,
|
| 420 |
+
width: containerHeight,
|
| 421 |
+
clipBehavior: Clip.hardEdge,
|
| 422 |
+
decoration: BoxDecoration(
|
| 423 |
+
color:const Color.fromARGB(255, 67, 67, 67),
|
| 424 |
+
borderRadius: BorderRadius.circular(40),
|
| 425 |
+
),
|
| 426 |
+
child: ListView.builder(
|
| 427 |
+
itemCount: roomidList.length,
|
| 428 |
+
itemBuilder: ((context, index){
|
| 429 |
+
return Row(
|
| 430 |
+
mainAxisAlignment: MainAxisAlignment.center,
|
| 431 |
+
// crossAxisAlignment: CrossAxisAlignment.stretch,
|
| 432 |
+
children: [
|
| 433 |
+
Expanded(
|
| 434 |
+
child: Container(
|
| 435 |
+
padding:EdgeInsets.all(8),
|
| 436 |
+
decoration: BoxDecoration(
|
| 437 |
+
// border:Border(
|
| 438 |
+
// bottom:BorderSide(
|
| 439 |
+
// color:Color.fromRGBO(200, 200, 200, 1),
|
| 440 |
+
// width: 4
|
| 441 |
+
// ),
|
| 442 |
+
// ),
|
| 443 |
+
),
|
| 444 |
+
child: Text(
|
| 445 |
+
roomnameList[index],
|
| 446 |
+
textAlign:TextAlign.center,
|
| 447 |
+
maxLines: 1,
|
| 448 |
+
style:TextStyle(
|
| 449 |
+
fontSize:20,
|
| 450 |
+
overflow: TextOverflow.clip,
|
| 451 |
+
|
| 452 |
+
),
|
| 453 |
+
)
|
| 454 |
+
),
|
| 455 |
+
),
|
| 456 |
+
],
|
| 457 |
+
);
|
| 458 |
+
})),
|
| 459 |
+
curve: Curves.easeIn,
|
| 460 |
+
),
|
| 461 |
+
),
|
| 462 |
+
|
| 463 |
+
// touch point
|
| 464 |
+
Visibility(
|
| 465 |
+
visible:touchIsVisible,
|
| 466 |
+
child: Positioned(
|
| 467 |
+
left:touchX,
|
| 468 |
+
top:touchY,
|
| 469 |
+
child: Container(
|
| 470 |
+
width:50,
|
| 471 |
+
height:50,
|
| 472 |
+
color:colorFromHex(profileColor),
|
| 473 |
+
),
|
| 474 |
+
),
|
| 475 |
+
),
|
| 476 |
+
|
| 477 |
+
]),
|
| 478 |
+
|
| 479 |
+
);
|
| 480 |
+
}
|
| 481 |
+
}
|
client/lib/LobbyScreen.dart
CHANGED
|
@@ -23,18 +23,25 @@ class LobbyScreenState extends State<LobbyScreen>{
|
|
| 23 |
late String username;
|
| 24 |
late Color profileColor;
|
| 25 |
late WebSocketChannel channel;
|
|
|
|
| 26 |
|
| 27 |
@override
|
| 28 |
void initState(){
|
| 29 |
super.initState();
|
| 30 |
username="";
|
| 31 |
profileColor=Colors.black;
|
|
|
|
| 32 |
loadPreferences();
|
| 33 |
// deletePreferences();
|
| 34 |
connectWebsocket();
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
| 38 |
}
|
| 39 |
void connectWebsocket() async{
|
| 40 |
|
|
@@ -57,17 +64,18 @@ class LobbyScreenState extends State<LobbyScreen>{
|
|
| 57 |
channel.sink.add(json.encode(data));
|
| 58 |
|
| 59 |
|
| 60 |
-
// set username
|
| 61 |
// data = {
|
| 62 |
// "route": "set_username",
|
| 63 |
// "username": "anuj",
|
| 64 |
// };
|
| 65 |
// channel.sink.add(json.encode(data));
|
| 66 |
|
| 67 |
-
|
|
|
|
|
|
|
| 68 |
// data = {
|
| 69 |
-
// "route": "
|
| 70 |
-
// "username": "anuj",
|
| 71 |
// };
|
| 72 |
// channel.sink.add(json.encode(data));
|
| 73 |
|
|
@@ -99,19 +107,72 @@ class LobbyScreenState extends State<LobbyScreen>{
|
|
| 99 |
else if(type=="join_room_response"){
|
| 100 |
print(map);
|
| 101 |
}
|
| 102 |
-
else if(type=="
|
| 103 |
print(map);
|
| 104 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
|
| 106 |
});
|
| 107 |
|
| 108 |
-
|
| 109 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
void loadPreferences() async{
|
| 111 |
prefs = await SharedPreferences.getInstance();
|
| 112 |
setState(() {
|
| 113 |
username= prefs.getString("username")!;
|
| 114 |
-
profileColor= colorFromHex(prefs.getString("profile_color")!)!;
|
|
|
|
|
|
|
|
|
|
| 115 |
});
|
| 116 |
}
|
| 117 |
void deletePreferences() async{
|
|
@@ -119,6 +180,7 @@ class LobbyScreenState extends State<LobbyScreen>{
|
|
| 119 |
prefs.remove('setup_done');
|
| 120 |
prefs.remove('username');
|
| 121 |
prefs.remove('profile_color');
|
|
|
|
| 122 |
}
|
| 123 |
|
| 124 |
Widget buildEmptyLobby(){
|
|
@@ -126,17 +188,12 @@ class LobbyScreenState extends State<LobbyScreen>{
|
|
| 126 |
"No Rooms yet"
|
| 127 |
);
|
| 128 |
}
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
context,
|
| 132 |
-
MaterialPageRoute(
|
| 133 |
-
builder:(context) => RoomScreen(),
|
| 134 |
-
)
|
| 135 |
-
);
|
| 136 |
-
}
|
| 137 |
-
Widget buildRoomTile(){
|
| 138 |
return GestureDetector(
|
| 139 |
-
onTap:
|
|
|
|
|
|
|
| 140 |
child:Container(
|
| 141 |
height:170,
|
| 142 |
margin:const EdgeInsets.only(top:40)+const EdgeInsets.symmetric(horizontal:20),
|
|
@@ -148,7 +205,7 @@ class LobbyScreenState extends State<LobbyScreen>{
|
|
| 148 |
child:Row(
|
| 149 |
children:[
|
| 150 |
Text(
|
| 151 |
-
|
| 152 |
style:TextStyle(
|
| 153 |
color:Colors.white,
|
| 154 |
fontSize:20,
|
|
@@ -168,7 +225,7 @@ class LobbyScreenState extends State<LobbyScreen>{
|
|
| 168 |
),
|
| 169 |
),
|
| 170 |
|
| 171 |
-
onPressed:
|
| 172 |
child: Container(
|
| 173 |
padding:const EdgeInsets.all(20),
|
| 174 |
child:const Text("New Room",
|
|
@@ -194,9 +251,9 @@ class LobbyScreenState extends State<LobbyScreen>{
|
|
| 194 |
|
| 195 |
Expanded(
|
| 196 |
child:ListView.builder(
|
| 197 |
-
itemCount:
|
| 198 |
itemBuilder: (context, index){
|
| 199 |
-
return buildRoomTile();
|
| 200 |
},
|
| 201 |
),
|
| 202 |
|
|
|
|
| 23 |
late String username;
|
| 24 |
late Color profileColor;
|
| 25 |
late WebSocketChannel channel;
|
| 26 |
+
late List<String> roomidList;
|
| 27 |
|
| 28 |
@override
|
| 29 |
void initState(){
|
| 30 |
super.initState();
|
| 31 |
username="";
|
| 32 |
profileColor=Colors.black;
|
| 33 |
+
roomidList=[];
|
| 34 |
loadPreferences();
|
| 35 |
// deletePreferences();
|
| 36 |
connectWebsocket();
|
| 37 |
+
|
| 38 |
+
}
|
| 39 |
|
| 40 |
+
@override
|
| 41 |
+
void dispose() async{
|
| 42 |
+
|
| 43 |
+
await channel.sink.close();
|
| 44 |
+
super.dispose();
|
| 45 |
}
|
| 46 |
void connectWebsocket() async{
|
| 47 |
|
|
|
|
| 64 |
channel.sink.add(json.encode(data));
|
| 65 |
|
| 66 |
|
| 67 |
+
// // set username
|
| 68 |
// data = {
|
| 69 |
// "route": "set_username",
|
| 70 |
// "username": "anuj",
|
| 71 |
// };
|
| 72 |
// channel.sink.add(json.encode(data));
|
| 73 |
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
// // get rooms
|
| 77 |
// data = {
|
| 78 |
+
// "route": "get_rooms",
|
|
|
|
| 79 |
// };
|
| 80 |
// channel.sink.add(json.encode(data));
|
| 81 |
|
|
|
|
| 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 |
|
| 121 |
});
|
| 122 |
|
|
|
|
| 123 |
}
|
| 124 |
+
|
| 125 |
+
void goToRoom(roomdata){
|
| 126 |
+
// if(!roomidList.contains(roomdata['roomId'])){
|
| 127 |
+
// setState((){
|
| 128 |
+
// // update roomidList
|
| 129 |
+
// roomidList.add(roomdata['roomId']);
|
| 130 |
+
// });
|
| 131 |
+
// }
|
| 132 |
+
Navigator.push(
|
| 133 |
+
context,
|
| 134 |
+
MaterialPageRoute(
|
| 135 |
+
builder:(context) => RoomScreen(roomdata:roomdata),
|
| 136 |
+
)
|
| 137 |
+
);
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
void createRoom({String roomId=""}) async{
|
| 141 |
+
// it is used to create a room in server
|
| 142 |
+
Map data;
|
| 143 |
+
|
| 144 |
+
try{
|
| 145 |
+
await channel.ready;
|
| 146 |
+
}
|
| 147 |
+
catch(e){
|
| 148 |
+
print("Can't connect to the web socket server");
|
| 149 |
+
return;
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
// join room
|
| 153 |
+
data = {
|
| 154 |
+
"route": "join_room",
|
| 155 |
+
"username": username,
|
| 156 |
+
};
|
| 157 |
+
|
| 158 |
+
// to join existing room
|
| 159 |
+
if(roomId.isNotEmpty){
|
| 160 |
+
data["roomId"]=roomId;
|
| 161 |
+
}
|
| 162 |
+
channel.sink.add(json.encode(data));
|
| 163 |
+
|
| 164 |
+
// we will move to the room screen with the server data
|
| 165 |
+
// from the room_update callback
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
void loadPreferences() async{
|
| 169 |
prefs = await SharedPreferences.getInstance();
|
| 170 |
setState(() {
|
| 171 |
username= prefs.getString("username")!;
|
| 172 |
+
profileColor = colorFromHex(prefs.getString("profile_color")!)!;
|
| 173 |
+
if(prefs.containsKey("roomid_list")){
|
| 174 |
+
roomidList = prefs.getStringList("roomid_list")!;
|
| 175 |
+
}
|
| 176 |
});
|
| 177 |
}
|
| 178 |
void deletePreferences() async{
|
|
|
|
| 180 |
prefs.remove('setup_done');
|
| 181 |
prefs.remove('username');
|
| 182 |
prefs.remove('profile_color');
|
| 183 |
+
prefs.remove('roomid_list');
|
| 184 |
}
|
| 185 |
|
| 186 |
Widget buildEmptyLobby(){
|
|
|
|
| 188 |
"No Rooms yet"
|
| 189 |
);
|
| 190 |
}
|
| 191 |
+
|
| 192 |
+
Widget buildRoomTile(index){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
return GestureDetector(
|
| 194 |
+
onTap:(){
|
| 195 |
+
createRoom(roomId:roomidList[index]);
|
| 196 |
+
},
|
| 197 |
child:Container(
|
| 198 |
height:170,
|
| 199 |
margin:const EdgeInsets.only(top:40)+const EdgeInsets.symmetric(horizontal:20),
|
|
|
|
| 205 |
child:Row(
|
| 206 |
children:[
|
| 207 |
Text(
|
| 208 |
+
roomidList[index], // room name
|
| 209 |
style:TextStyle(
|
| 210 |
color:Colors.white,
|
| 211 |
fontSize:20,
|
|
|
|
| 225 |
),
|
| 226 |
),
|
| 227 |
|
| 228 |
+
onPressed: createRoom,
|
| 229 |
child: Container(
|
| 230 |
padding:const EdgeInsets.all(20),
|
| 231 |
child:const Text("New Room",
|
|
|
|
| 251 |
|
| 252 |
Expanded(
|
| 253 |
child:ListView.builder(
|
| 254 |
+
itemCount: roomidList.length,
|
| 255 |
itemBuilder: (context, index){
|
| 256 |
+
return buildRoomTile(index);
|
| 257 |
},
|
| 258 |
),
|
| 259 |
|
client/lib/RoomScreen.dart
CHANGED
|
@@ -1,6 +1,8 @@
|
|
| 1 |
import 'package:flutter/material.dart';
|
| 2 |
import 'package:flutter/services.dart'; // for going in fullscreen mode
|
| 3 |
|
|
|
|
|
|
|
| 4 |
void enterFullScreen(){
|
| 5 |
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive,overlays: []);
|
| 6 |
}
|
|
@@ -9,7 +11,8 @@ void exitFullScreen(){
|
|
| 9 |
}
|
| 10 |
|
| 11 |
class RoomScreen extends StatefulWidget{
|
| 12 |
-
|
|
|
|
| 13 |
|
| 14 |
@override
|
| 15 |
State<RoomScreen> createState(){
|
|
@@ -18,12 +21,16 @@ class RoomScreen extends StatefulWidget{
|
|
| 18 |
}
|
| 19 |
|
| 20 |
class RoomScreenState extends State<RoomScreen>{
|
| 21 |
-
late double width,height;
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
@override
|
| 24 |
void initState(){
|
| 25 |
super.initState();
|
| 26 |
enterFullScreen();
|
|
|
|
| 27 |
}
|
| 28 |
|
| 29 |
@override
|
|
@@ -32,46 +39,113 @@ class RoomScreenState extends State<RoomScreen>{
|
|
| 32 |
super.dispose();
|
| 33 |
}
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
Widget header(){
|
| 36 |
final Color buttoncolor=Color.fromARGB(255, 70, 70, 70);
|
| 37 |
return Padding(
|
| 38 |
padding:EdgeInsets.symmetric(vertical:20),
|
| 39 |
-
child:
|
| 40 |
-
|
|
|
|
|
|
|
| 41 |
children: [
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
),
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
backgroundColor: buttoncolor,
|
| 65 |
-
child:IconButton(
|
| 66 |
-
// iconSize:30,
|
| 67 |
-
onPressed: (){},
|
| 68 |
-
icon: Icon(
|
| 69 |
-
Icons.settings,
|
| 70 |
-
color:Colors.white,
|
| 71 |
),
|
| 72 |
-
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
]),
|
|
|
|
| 75 |
);
|
| 76 |
}
|
| 77 |
Widget mainSection(){
|
|
|
|
| 1 |
import 'package:flutter/material.dart';
|
| 2 |
import 'package:flutter/services.dart'; // for going in fullscreen mode
|
| 3 |
|
| 4 |
+
import 'package:shared_preferences/shared_preferences.dart';
|
| 5 |
+
|
| 6 |
void enterFullScreen(){
|
| 7 |
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive,overlays: []);
|
| 8 |
}
|
|
|
|
| 11 |
}
|
| 12 |
|
| 13 |
class RoomScreen extends StatefulWidget{
|
| 14 |
+
RoomScreen({super.key,required this.roomdata});
|
| 15 |
+
Map roomdata;
|
| 16 |
|
| 17 |
@override
|
| 18 |
State<RoomScreen> createState(){
|
|
|
|
| 21 |
}
|
| 22 |
|
| 23 |
class RoomScreenState extends State<RoomScreen>{
|
|
|
|
| 24 |
|
| 25 |
+
late double width,height;
|
| 26 |
+
late SharedPreferences prefs;
|
| 27 |
+
double containerHeight = 0;
|
| 28 |
+
|
| 29 |
@override
|
| 30 |
void initState(){
|
| 31 |
super.initState();
|
| 32 |
enterFullScreen();
|
| 33 |
+
setPreferences();
|
| 34 |
}
|
| 35 |
|
| 36 |
@override
|
|
|
|
| 39 |
super.dispose();
|
| 40 |
}
|
| 41 |
|
| 42 |
+
void setPreferences() async{
|
| 43 |
+
prefs = await SharedPreferences.getInstance();
|
| 44 |
+
List<String> roomIds=[];
|
| 45 |
+
|
| 46 |
+
// read old rooms list
|
| 47 |
+
if(prefs.containsKey("roomid_list")){
|
| 48 |
+
roomIds=prefs.getStringList("roomid_list")!;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
//add new room if not already exists
|
| 52 |
+
if(!roomIds.contains(widget.roomdata["roomId"])){
|
| 53 |
+
roomIds.add(widget.roomdata["roomId"]);
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
// update rooms_list in preferences
|
| 57 |
+
prefs.setStringList("roomid_list", roomIds);
|
| 58 |
+
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
void toggleContainer(){
|
| 62 |
+
if(containerHeight==0){
|
| 63 |
+
setState(() {
|
| 64 |
+
containerHeight=height*0.7;
|
| 65 |
+
});
|
| 66 |
+
}
|
| 67 |
+
else{
|
| 68 |
+
setState(() {
|
| 69 |
+
containerHeight=0;
|
| 70 |
+
});
|
| 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,
|
| 80 |
+
alignment: Alignment.center,
|
| 81 |
children: [
|
| 82 |
+
|
| 83 |
+
Row(
|
| 84 |
+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
| 85 |
+
children: [
|
| 86 |
+
// add people button
|
| 87 |
+
CircleAvatar(
|
| 88 |
+
backgroundColor: buttoncolor,
|
| 89 |
+
child:IconButton(
|
| 90 |
+
style:IconButton.styleFrom(
|
| 91 |
+
),
|
| 92 |
+
onPressed: (){},
|
| 93 |
+
icon: Icon(Icons.add,color:Colors.white),
|
| 94 |
+
),
|
| 95 |
+
),
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
GestureDetector(
|
| 100 |
+
onTap:toggleContainer,
|
| 101 |
+
child:Row(
|
| 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 |
),
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
// setting button
|
| 121 |
+
CircleAvatar(
|
| 122 |
+
backgroundColor: buttoncolor,
|
| 123 |
+
child:IconButton(
|
| 124 |
+
// iconSize:30,
|
| 125 |
+
onPressed: (){},
|
| 126 |
+
icon: Icon(
|
| 127 |
+
Icons.settings,
|
| 128 |
+
color:Colors.white,
|
| 129 |
+
),
|
| 130 |
+
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
),
|
| 132 |
+
]),
|
| 133 |
+
|
| 134 |
+
// room info container
|
| 135 |
+
Positioned(
|
| 136 |
+
top:20,
|
| 137 |
+
// top:20,
|
| 138 |
+
child:SizedBox(
|
| 139 |
+
height: 200,
|
| 140 |
+
width:200,
|
| 141 |
+
child:Container(color:Colors.white) ,
|
| 142 |
+
),
|
| 143 |
+
),
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
|
| 147 |
]),
|
| 148 |
+
|
| 149 |
);
|
| 150 |
}
|
| 151 |
Widget mainSection(){
|
client/lib/SetupScreen.dart
CHANGED
|
@@ -4,6 +4,7 @@ import 'package:hapticlink/LobbyScreen.dart';
|
|
| 4 |
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
|
| 5 |
import 'Colors/CustomColorPicker.dart';
|
| 6 |
import "CustomButton.dart";
|
|
|
|
| 7 |
|
| 8 |
class SetupScreen extends StatefulWidget{
|
| 9 |
const SetupScreen({super.key});
|
|
@@ -145,7 +146,8 @@ class _SetupScreenState extends State<SetupScreen>{
|
|
| 145 |
Navigator.pushReplacement(
|
| 146 |
context,
|
| 147 |
MaterialPageRoute(
|
| 148 |
-
builder: (context)=>LobbyScreen()
|
|
|
|
| 149 |
),
|
| 150 |
|
| 151 |
);
|
|
|
|
| 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});
|
|
|
|
| 146 |
Navigator.pushReplacement(
|
| 147 |
context,
|
| 148 |
MaterialPageRoute(
|
| 149 |
+
// builder: (context)=>LobbyScreen()
|
| 150 |
+
builder: (context)=>HomeScreen()
|
| 151 |
),
|
| 152 |
|
| 153 |
);
|
client/lib/main.dart
CHANGED
|
@@ -1,8 +1,9 @@
|
|
| 1 |
import 'package:flutter/material.dart';
|
| 2 |
import 'package:after_layout/after_layout.dart';
|
| 3 |
-
import 'package:hapticlink/LobbyScreen.dart';
|
| 4 |
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
| 5 |
import 'SetupScreen.dart';
|
|
|
|
| 6 |
import 'Loading.dart';
|
| 7 |
|
| 8 |
void main() {
|
|
@@ -53,7 +54,8 @@ class SplashState extends State<Splash> with AfterLayoutMixin<Splash>{
|
|
| 53 |
Navigator.pushReplacement(
|
| 54 |
context,
|
| 55 |
MaterialPageRoute(
|
| 56 |
-
builder: (context)=>LobbyScreen()
|
|
|
|
| 57 |
)
|
| 58 |
);
|
| 59 |
}
|
|
|
|
| 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() {
|
|
|
|
| 54 |
Navigator.pushReplacement(
|
| 55 |
context,
|
| 56 |
MaterialPageRoute(
|
| 57 |
+
// builder: (context)=>LobbyScreen()
|
| 58 |
+
builder: (context)=>HomeScreen()
|
| 59 |
)
|
| 60 |
);
|
| 61 |
}
|
server/src/socket/routes.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { HapticLinkServer } from "./hapticLinkServer";
|
|
| 2 |
import JoinRoomRoute from "./routes/join_room";
|
| 3 |
import LeaveRoomRoute from "./routes/leave_room";
|
| 4 |
import SendVibrationRoute from "./routes/send_vibration";
|
|
|
|
| 5 |
import TestConnectionRoute from "./routes/test_connection";
|
| 6 |
|
| 7 |
export function registerRoutes(router: HapticLinkServer) {
|
|
@@ -9,4 +10,5 @@ export function registerRoutes(router: HapticLinkServer) {
|
|
| 9 |
router.addRoute(JoinRoomRoute);
|
| 10 |
router.addRoute(LeaveRoomRoute);
|
| 11 |
router.addRoute(SendVibrationRoute);
|
|
|
|
| 12 |
}
|
|
|
|
| 2 |
import JoinRoomRoute from "./routes/join_room";
|
| 3 |
import LeaveRoomRoute from "./routes/leave_room";
|
| 4 |
import SendVibrationRoute from "./routes/send_vibration";
|
| 5 |
+
import SetUsernameRoute from "./routes/set_username";
|
| 6 |
import TestConnectionRoute from "./routes/test_connection";
|
| 7 |
|
| 8 |
export function registerRoutes(router: HapticLinkServer) {
|
|
|
|
| 10 |
router.addRoute(JoinRoomRoute);
|
| 11 |
router.addRoute(LeaveRoomRoute);
|
| 12 |
router.addRoute(SendVibrationRoute);
|
| 13 |
+
router.addRoute(SetUsernameRoute);
|
| 14 |
}
|