From 3df127ffca222825641ffcf1bb34aed2d7606cfb Mon Sep 17 00:00:00 2001 From: Veer-kesh28 Date: Sat, 25 May 2024 20:28:06 +0530 Subject: [PATCH] callpage added --- lib/screens/CallPage.dart | 70 +++++++++++++ lib/screens/HomePage.dart | 197 ++++++++++++------------------------ lib/screens/HomeScreen.dart | 101 ++++++++++++++++++ 3 files changed, 236 insertions(+), 132 deletions(-) create mode 100644 lib/screens/CallPage.dart create mode 100644 lib/screens/HomeScreen.dart diff --git a/lib/screens/CallPage.dart b/lib/screens/CallPage.dart new file mode 100644 index 0000000..844a676 --- /dev/null +++ b/lib/screens/CallPage.dart @@ -0,0 +1,70 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; + +class CallPage extends StatefulWidget { + const CallPage({super.key}); + + @override + State createState() => _CallPageState(); +} + +class _CallPageState extends State { + final List callPeople = [ + { + 'name': 'John', + "time": "10:42", + "type": ["All", "none"] + }, + { + 'name': 'John', + "time": "9:42", + "type": ["All", "missed"] + }, + { + 'name': 'John', + "time": "8:42", + "type": ["All", "missed"] + }, + { + 'name': 'John', + "time": "7:42", + "type": ["All", "none"] + } + ]; + @override + Widget build(BuildContext context) { + return Scaffold( + body: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.only(left: 20.0, bottom: 10, top: 20), + child: Align( + alignment: Alignment.topLeft, + child: Text( + "Calls", + style: TextStyle(fontSize: 28), + ), + ), + ), + Expanded( + child: Container( + child: ListView.builder( + itemCount: callPeople.length, + itemBuilder: (context, index) { + return ListTile( + leading: CircleAvatar( + child: Icon(Icons.person), + ), + title: Text(callPeople[index]['name']), + subtitle: Text(callPeople[index]['time']), + trailing: Icon(Icons.call), + ); + }), + ), + ) + ], + ), + ); + } +} diff --git a/lib/screens/HomePage.dart b/lib/screens/HomePage.dart index 5266eb5..9a556db 100644 --- a/lib/screens/HomePage.dart +++ b/lib/screens/HomePage.dart @@ -1,7 +1,9 @@ // ignore_for_file: file_names import 'package:flutter/material.dart'; +import 'package:test_app/screens/CallPage.dart'; import 'package:test_app/screens/ChatPage.dart'; +import 'package:test_app/screens/HomeScreen.dart'; class HomePage extends StatefulWidget { const HomePage({super.key}); @@ -11,6 +13,15 @@ class HomePage extends StatefulWidget { } class _HomePageState extends State { + int _selectedIndex = 0; + final _pageOptions = [HomeScreen(), CallPage()]; + + void changepage(value) { + setState(() { + _selectedIndex = value; + }); + } + List menuItems = [ "New Group", "New Broadcast", @@ -19,142 +30,64 @@ class _HomePageState extends State { "Payment", "Settings" ]; - List chats = [ - { - "name": "Ram", - "Message": "I have reached Lanka", - "time": "11:11", - "readStatus": true, - "sent": false - }, - { - "name": "Lakshman", - "Message": "Bhrata, mujhe aadesh dein, sabko mai akele maar dunga!", - "time": "11:11", - "readStatus": true, - "sent": false - }, - { - "name": "Bharat", - "Message": "Kila fateh karke aaiye! Rajya aapka intezar kar raha hai!", - "time": "11:15", - "readStatus": true, - "sent": false - }, - { - "name": "Shatrughna", - "Message": "ALl the best bhrata shree!", - "time": "11:12", - "readStatus": true, - "sent": false - }, - { - "name": "Hanuman", - "Message": "Jai Shree Ram. On your command, my lord!", - "time": "11:11", - "readStatus": true, - "sent": false - }, - { - "name": "Sita", - "Message": "I am waiting, Come soon!", - "time": "11:11", - "readStatus": true, - "sent": false - }, - { - "name": "Dashrath", - "Message": "All the best!", - "time": "11:20", - "readStatus": true, - "sent": true - }, - ]; @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - backgroundColor: Theme.of(context).colorScheme.inversePrimary, - // Here we take the value from the MyHomePage object that was created by - // the App.build method, and use it to set our appbar title. - title: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text("What's UP"), - Row( - children: [ - Icon(Icons.search), - PopupMenuButton( - onSelected: (value) => {print(value)}, - itemBuilder: (BuildContext context) => - >[ - PopupMenuItem( - value: "New Group", - child: Text("New Group"), - ), - PopupMenuItem( - value: "New Broadcast", - child: Text("New Broadcast"), - ), - PopupMenuItem( - value: "Linked devices", - child: Text("Linked devices"), - ), - PopupMenuItem( - value: "Starred message", - child: Text("Starred message"), - ), - PopupMenuItem( - value: "Payment", - child: Text("Payment"), - ), - PopupMenuItem( - value: "Settings", - child: Text("Settings"), - ), - ]) - ], - ), - ], - ), - ), - body: ListView.builder( - itemCount: chats.length, - itemBuilder: (context, index) { - return ListTile( - title: Text(chats[index]["name"]), - subtitle: chats[index]["sent"] - ? Row( - children: [ - const Icon(Icons.done_all), - Text( - chats[index]["Message"], - style: const TextStyle( - overflow: TextOverflow.ellipsis), + appBar: AppBar( + backgroundColor: Theme.of(context).colorScheme.inversePrimary, + // Here we take the value from the MyHomePage object that was created by + // the App.build method, and use it to set our appbar title. + title: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text("M Whatsapp"), + Row( + children: [ + Icon(Icons.search), + PopupMenuButton( + onSelected: (value) => {print(value)}, + itemBuilder: (BuildContext context) => + >[ + PopupMenuItem( + value: "New Group", + child: Text("New Group"), + ), + PopupMenuItem( + value: "New Broadcast", + child: Text("New Broadcast"), ), - ], - ) - : Text( - chats[index]["Message"], - style: const TextStyle(overflow: TextOverflow.ellipsis), - ), - leading: ClipRRect( - borderRadius: BorderRadius.circular(40), - child: index % 2 == 0 - ? Image.asset("assets/srk.png") - : Image.asset("assets/srk1.png"), - ), - trailing: Text(chats[index]["time"]), - onTap: () => Navigator.push(context, - MaterialPageRoute(builder: (context) { - return ChatPage( - name: chats[index]["name"], - image: - index % 2 == 0 ? "assets/srk.png" : "assets/srk1.png", - ); - })), - ); - })); + PopupMenuItem( + value: "Linked devices", + child: Text("Linked devices"), + ), + PopupMenuItem( + value: "Starred message", + child: Text("Starred message"), + ), + PopupMenuItem( + value: "Payment", + child: Text("Payment"), + ), + PopupMenuItem( + value: "Settings", + child: Text("Settings"), + ), + ]) + ], + ), + ], + ), + ), + body: _pageOptions[_selectedIndex], + bottomNavigationBar: BottomNavigationBar( + onTap: changepage, + currentIndex: _selectedIndex, + items: [ + BottomNavigationBarItem( + icon: Icon(Icons.chat_bubble), label: "chat"), + BottomNavigationBarItem(icon: Icon(Icons.call), label: "call"), + ]), + ); } } diff --git a/lib/screens/HomeScreen.dart b/lib/screens/HomeScreen.dart new file mode 100644 index 0000000..cce7606 --- /dev/null +++ b/lib/screens/HomeScreen.dart @@ -0,0 +1,101 @@ +import 'package:flutter/material.dart'; +import 'package:test_app/screens/ChatPage.dart'; + +class HomeScreen extends StatefulWidget { + const HomeScreen({super.key}); + + @override + State createState() => _HomeScreenState(); +} + +class _HomeScreenState extends State { + List chats = [ + { + "name": "Ram", + "Message": "I have reached Lanka", + "time": "11:11", + "readStatus": true, + "sent": false + }, + { + "name": "Lakshman", + "Message": "Bhrata, mujhe aadesh dein, sabko mai akele maar dunga!", + "time": "11:11", + "readStatus": true, + "sent": false + }, + { + "name": "Bharat", + "Message": "Kila fateh karke aaiye! Rajya aapka intezar kar raha hai!", + "time": "11:15", + "readStatus": true, + "sent": false + }, + { + "name": "Shatrughna", + "Message": "ALl the best bhrata shree!", + "time": "11:12", + "readStatus": true, + "sent": false + }, + { + "name": "Hanuman", + "Message": "Jai Shree Ram. On your command, my lord!", + "time": "11:11", + "readStatus": true, + "sent": false + }, + { + "name": "Sita", + "Message": "I am waiting, Come soon!", + "time": "11:11", + "readStatus": true, + "sent": false + }, + { + "name": "Dashrath", + "Message": "All the best!", + "time": "11:20", + "readStatus": true, + "sent": true + }, + ]; + @override + Widget build(BuildContext context) { + return ListView.builder( + itemCount: chats.length, + itemBuilder: (context, index) { + return ListTile( + title: Text(chats[index]["name"]), + subtitle: chats[index]["sent"] + ? Row( + children: [ + const Icon(Icons.done_all), + Text( + chats[index]["Message"], + style: const TextStyle(overflow: TextOverflow.ellipsis), + ), + ], + ) + : Text( + chats[index]["Message"], + style: const TextStyle(overflow: TextOverflow.ellipsis), + ), + leading: ClipRRect( + borderRadius: BorderRadius.circular(40), + child: index % 2 == 0 + ? Image.asset("assets/srk.png") + : Image.asset("assets/srk1.png"), + ), + trailing: Text(chats[index]["time"]), + onTap: () => + Navigator.push(context, MaterialPageRoute(builder: (context) { + return ChatPage( + name: chats[index]["name"], + image: index % 2 == 0 ? "assets/srk.png" : "assets/srk1.png", + ); + })), + ); + }); + } +}