Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions lib/screens/CallPage.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

class CallPage extends StatefulWidget {
const CallPage({super.key});

@override
State<CallPage> createState() => _CallPageState();
}

class _CallPageState extends State<CallPage> {
bool _showallCalls = true;
final List<Map> 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,
);
}
}))
],
);
}
}
101 changes: 101 additions & 0 deletions lib/screens/HomeScreen.dart
Original file line number Diff line number Diff line change
@@ -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<HomeScreen> createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
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",
);
})),
);
});
}
}