diff --git a/lib/screens/CallPage.dart b/lib/screens/CallPage.dart new file mode 100644 index 0000000..f191e6a --- /dev/null +++ b/lib/screens/CallPage.dart @@ -0,0 +1,107 @@ +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 { + bool _showallCalls = true; + final List callPeople = [ + { + 'name': 'John', + "time": "10:42", + "type": ["All", "none"] + }, + { + 'name': 'Aehmad', + "time": "9:42", + "type": ["All", "missed"] + }, + { + 'name': 'Rahul', + "time": "8:42", + "type": ["All", "missed"] + }, + { + 'name': 'Anwar', + "time": "7:42", + "type": ["All", "none"] + } + ]; + @override + Widget build(BuildContext context) { + return Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + TextButton( + onPressed: () { + setState(() { + _showallCalls = true; + }); + }, + child: Text("All")), + TextButton( + onPressed: () { + setState(() { + _showallCalls = false; + }); + }, + child: Text("Missed call")) + ], + ), + Padding( + padding: const EdgeInsets.only(left: 25.0, bottom: 10), + child: Align( + alignment: Alignment.topLeft, + child: Text( + "Calls", + style: TextStyle( + fontSize: 28, + ), + ), + ), + ), + Container( + height: MediaQuery.of(context).size.height * 0.6, + child: _showallCalls + ? 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), + ); + }) + : ListView.builder( + itemCount: callPeople.length, + itemBuilder: (context, index) { + if (callPeople[index]['type'][1] == 'missed') { + return ListTile( + leading: CircleAvatar( + child: Icon(Icons.person), + ), + title: Text(callPeople[index]['name']), + subtitle: Text(callPeople[index]['time']), + trailing: Icon(Icons.call), + ); + } else { + return SizedBox( + height: 0, + ); + } + })) + ], + ); + } +} 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", + ); + })), + ); + }); + } +}