hapticlink / client /lib /room_screen.dart
Anuj-Panthri's picture
renamed everything to make everything consistent
f21ac8b
import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; // for going in fullscreen mode
import 'package:shared_preferences/shared_preferences.dart';
void enterFullScreen(){
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive,overlays: []);
}
void exitFullScreen(){
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,overlays:SystemUiOverlay.values);
}
class RoomScreen extends StatefulWidget{
const RoomScreen({super.key,required this.roomdata});
final Map roomdata;
@override
State<RoomScreen> createState(){
return RoomScreenState();
}
}
class RoomScreenState extends State<RoomScreen>{
late double width,height;
late SharedPreferences prefs;
double containerHeight = 0;
@override
void initState(){
super.initState();
enterFullScreen();
setPreferences();
}
@override
void dispose(){
exitFullScreen();
super.dispose();
}
void setPreferences() async{
prefs = await SharedPreferences.getInstance();
List<String> roomIds=[];
// read old rooms list
if(prefs.containsKey("roomid_list")){
roomIds=prefs.getStringList("roomid_list")!;
}
//add new room if not already exists
if(!roomIds.contains(widget.roomdata["roomId"])){
roomIds.add(widget.roomdata["roomId"]);
}
// update rooms_list in preferences
prefs.setStringList("roomid_list", roomIds);
}
void toggleContainer(){
if(containerHeight==0){
setState(() {
containerHeight=height*0.7;
});
}
else{
setState(() {
containerHeight=0;
});
}
}
Widget header(){
Color buttoncolor=const Color.fromARGB(255, 70, 70, 70);
return Padding(
padding:const EdgeInsets.symmetric(vertical:20),
child:Stack(
fit: StackFit.passthrough,
clipBehavior: Clip.none,
alignment: Alignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
// add people button
CircleAvatar(
backgroundColor: buttoncolor,
child:IconButton(
style:IconButton.styleFrom(
),
onPressed: (){},
icon:const Icon(Icons.add,color:Colors.white),
),
),
GestureDetector(
onTap:toggleContainer,
child:Row(
children:[
Text(
widget.roomdata['roomId'],
style:const TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
overflow:TextOverflow.ellipsis,
),
),
const Icon(Icons.arrow_drop_down),
]),
),
// setting button
CircleAvatar(
backgroundColor: buttoncolor,
child:IconButton(
// iconSize:30,
onPressed: (){},
icon:const Icon(
Icons.settings,
color:Colors.white,
),
),
),
]),
// room info container
Positioned(
top:20,
// top:20,
child:SizedBox(
height: 200,
width:200,
child:Container(color:Colors.white),
),
),
]),
);
}
Widget mainSection(){
return Expanded(
child:Container(
decoration: BoxDecoration(
// color:Colors.grey.shade900,
color:const Color(0xff121212),
borderRadius: BorderRadius.circular(50),
),
// width:width*0.9,
// child:SizedBox(),
),
);
}
@override
Widget build(BuildContext context){
width=MediaQuery.of(context).size.width;
height=MediaQuery.of(context).size.height;
return Scaffold(
backgroundColor:const Color(0xff0e0e0e),
// backgroundColor: Colors.white,
body:Padding(
padding:const EdgeInsets.all(15),
child:Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
header(),
mainSection(),
])
),
);
}
}