repo_id
stringlengths 21
168
| file_path
stringlengths 36
210
| content
stringlengths 1
9.98M
| __index_level_0__
int64 0
0
|
---|---|---|---|
mirrored_repositories/FiverrClone/lib | mirrored_repositories/FiverrClone/lib/pages/settings.dart | import 'package:flutter/material.dart';
class SettingsPage extends StatefulWidget {
@override
_SettingsPageState createState() => _SettingsPageState();
}
class _SettingsPageState extends State<SettingsPage> {
String currencyDropdownValue = "\$ USD";
bool isOut = false;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Settings"),
),
body: Column(
children: <Widget>[
InkWell(
onTap: () {},
child: Padding(
padding: const EdgeInsets.only(left: 15.0),
child: Container(
alignment: Alignment.centerLeft,
height: 60.0,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: Colors.black38,
width: 1,
),
),
),
child: Text(
"Notifications",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 15.0,
),
),
),
),
),
InkWell(
onTap: () {},
child: Padding(
padding: const EdgeInsets.only(left: 15.0),
child: Container(
alignment: Alignment.centerLeft,
height: 60.0,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: Colors.black38,
width: 1,
),
),
),
child: Text(
"Notifications sound",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 15.0,
),
),
),
),
),
InkWell(
onTap: () {},
child: Padding(
padding: const EdgeInsets.only(left: 15.0),
child: Container(
alignment: Alignment.centerLeft,
height: 60.0,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: Colors.black38,
width: 1,
),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"Currency",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 15.0,
),
),
DropdownButton<String>(
value: currencyDropdownValue,
icon: Icon(null),
iconSize: 15,
elevation: 16,
underline: Container(
height: 0.0,
color: Colors.grey,
),
style: TextStyle(
color: Theme.of(context).accentColor,
fontWeight: FontWeight.bold,
),
onChanged: (String newValue) {
setState(() {
currencyDropdownValue = newValue;
});
},
items: <String>["\$ USD", "LKR", "INR", "AUD"]
.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
),
],
),
),
),
),
InkWell(
onTap: () {},
child: Padding(
padding: const EdgeInsets.only(left: 15.0),
child: Container(
alignment: Alignment.centerLeft,
height: 60.0,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: Colors.black38,
width: 1,
),
),
),
child: Text(
"Terms of service",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 15.0,
),
),
),
),
),
InkWell(
onTap: () {},
child: Padding(
padding: const EdgeInsets.only(left: 15.0),
child: Container(
alignment: Alignment.centerLeft,
height: 60.0,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: Colors.black38,
width: 1,
),
),
),
child: Text(
"Privacy policy",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 15.0,
),
),
),
),
),
InkWell(
onTap: () {},
child: Padding(
padding: const EdgeInsets.only(left: 15.0),
child: Container(
alignment: Alignment.centerLeft,
height: 60.0,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: Colors.black38,
width: 1,
),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"Out of Office mode",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 15.0,
),
),
Switch(
value: isOut,
onChanged: (value) {
setState(() {
isOut = value;
});
},
activeTrackColor: Color(0xFF8bd9ad),
activeColor: Theme.of(context).accentColor,
),
],
),
),
),
),
InkWell(
onTap: () {},
child: Container(
alignment: Alignment.centerLeft,
height: 60.0,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: Colors.black38,
width: 1,
),
),
),
child: Padding(
padding: const EdgeInsets.only(left: 15.0),
child: Text(
"Logout",
style: TextStyle(
color: Colors.redAccent,
fontWeight: FontWeight.bold,
fontSize: 15.0,
),
),
),
),
),
Container(
alignment: Alignment.center,
height: 60.0,
width: MediaQuery.of(context).size.width,
child: Text(
"Version 3.0.5",
style: TextStyle(
color: Colors.grey,
fontSize: 15.0,
),
),
),
],
),
);
}
}
| 0 |
mirrored_repositories/FiverrClone/lib | mirrored_repositories/FiverrClone/lib/pages/earnings.dart | import 'package:flutter/material.dart';
import 'package:bezier_chart/bezier_chart.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
class EarningsPage extends StatefulWidget {
@override
_EarningsPageState createState() => _EarningsPageState();
}
class _EarningsPageState extends State<EarningsPage>
with TickerProviderStateMixin {
String currencyDropdownValue = "Last 7 Days";
@override
void initState() {
super.initState();
}
Widget _getEarnings() {
return BezierChart(
bezierChartScale: BezierChartScale.CUSTOM,
xAxisCustomValues: const [0, 5, 10, 15, 20, 25, 30, 35],
series: const [
BezierLine(
data: const [
DataPoint<double>(value: 10, xAxis: 0),
DataPoint<double>(value: 130, xAxis: 5),
DataPoint<double>(value: 50, xAxis: 10),
DataPoint<double>(value: 150, xAxis: 15),
DataPoint<double>(value: 75, xAxis: 20),
DataPoint<double>(value: 0, xAxis: 25),
DataPoint<double>(value: 5, xAxis: 30),
DataPoint<double>(value: 45, xAxis: 35),
],
),
],
config: BezierChartConfig(
displayYAxis: true,
xLinesColor: Colors.orange,
verticalIndicatorStrokeWidth: 3.0,
verticalIndicatorColor: Colors.red,
showVerticalIndicator: true,
backgroundColor: Colors.lightGreen,
snap: false,
),
);
}
Widget _getOrders() {
return BezierChart(
bezierChartScale: BezierChartScale.CUSTOM,
xAxisCustomValues: const [0, 5, 10, 15, 20, 25, 30, 35],
series: const [
BezierLine(
data: const [
DataPoint<double>(value: 10, xAxis: 0),
DataPoint<double>(value: 130, xAxis: 5),
DataPoint<double>(value: 50, xAxis: 10),
DataPoint<double>(value: 150, xAxis: 15),
DataPoint<double>(value: 75, xAxis: 20),
DataPoint<double>(value: 0, xAxis: 25),
DataPoint<double>(value: 5, xAxis: 30),
DataPoint<double>(value: 45, xAxis: 35),
],
),
],
config: BezierChartConfig(
displayYAxis: true,
xLinesColor: Colors.orange,
verticalIndicatorStrokeWidth: 3.0,
verticalIndicatorColor: Colors.red,
showVerticalIndicator: true,
backgroundColor: Colors.orangeAccent,
snap: false,
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Earnings"),
actions: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: Text(
"WITHDRAW",
style: TextStyle(
color: Theme.of(context).accentColor,
fontWeight: FontWeight.bold,
fontSize: 12.0,
),
)),
)
],
),
body: DefaultTabController(
length: 2,
child: ListView(
children: <Widget>[
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Container(
height: 140.0,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(),
Container(
child: Column(
children: <Widget>[
Text(
"US\$36.90",
style: TextStyle(
color: Theme.of(context).accentColor,
fontWeight: FontWeight.bold,
fontSize: 25.0,
),
),
Text(
"Personal balance",
style: TextStyle(
fontSize: 14.0,
),
),
],
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text("Overview"),
DropdownButton<String>(
value: currencyDropdownValue,
icon: Icon(Icons.arrow_drop_down),
iconSize: 15,
elevation: 16,
underline: Container(
height: 0.0,
color: Colors.grey,
),
style: TextStyle(
color: Colors.black,
),
onChanged: (String newValue) {
setState(() {
currencyDropdownValue = newValue;
});
},
items: <String>[
"Last 7 Days",
"Last 30 Days",
"Last 3 Months",
"This year"
].map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
),
],
)
],
),
),
),
Divider(),
TabBar(
labelColor: Theme.of(context).accentColor,
unselectedLabelColor: Colors.grey,
tabs: <Widget>[
Tab(
text: "EARNINGS",
),
Tab(
text: "ORDERS",
),
],
),
Divider(),
Container(
height: MediaQuery.of(context).size.height / 2,
width: MediaQuery.of(context).size.width * 0.9,
child: TabBarView(
children: <Widget>[
_getEarnings(),
_getOrders(),
],
),
),
Divider(),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Analytics",
style: TextStyle(
color: Colors.grey,
),
),
),
Divider(),
Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text("Earning in February"),
Text(
"US\$4",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
],
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text("Avg. selling price"),
Text(
"US\$15.87",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
],
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text("Active orders"),
Row(
children: <Widget>[
Text(
"1",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
Text(
"(US\$25)",
style: TextStyle(
color: Colors.grey,
fontWeight: FontWeight.bold,
),
),
],
)
],
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text("Available for withdrawal"),
Text(
"US\$69.60",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
],
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text("Completed orders"),
Row(
children: <Widget>[
Text(
"1",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
Text(
"(US\$4)",
style: TextStyle(
color: Colors.grey,
fontWeight: FontWeight.bold,
),
),
],
)
],
),
),
Divider(),
],
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Revenues",
style: TextStyle(
color: Colors.grey,
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"Cancelled orders",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
Row(
children: <Widget>[
Text(
"",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
Text(
"(US\$0)",
style: TextStyle(
color: Colors.grey,
fontWeight: FontWeight.bold,
),
),
Icon(
FontAwesomeIcons.angleRight,
color: Colors.grey,
),
],
)
],
),
),
Divider(),
Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"Pending clearance",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
Row(
children: <Widget>[
Text(
"",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
Text(
"US\$32",
style: TextStyle(
color: Theme.of(context).accentColor,
fontWeight: FontWeight.bold,
),
),
Icon(
FontAwesomeIcons.angleRight,
color: Colors.grey,
),
],
)
],
),
),
Divider(),
Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"Withdraw",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
Row(
children: <Widget>[
Text(
"",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
Text(
"US\$1,368.60",
style: TextStyle(
color: Theme.of(context).accentColor,
fontWeight: FontWeight.bold,
),
),
Icon(
FontAwesomeIcons.angleRight,
color: Colors.grey,
),
],
)
],
),
),
Divider(),
Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"Used for purchases",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
Row(
children: <Widget>[
Text(
"",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
Text(
"US\$4.50",
style: TextStyle(
color: Theme.of(context).accentColor,
fontWeight: FontWeight.bold,
),
),
Icon(
FontAwesomeIcons.angleRight,
color: Colors.grey,
),
],
)
],
),
),
Divider(),
Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"Cleared",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
Row(
children: <Widget>[
Text(
"",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
Text(
"US\$36.90",
style: TextStyle(
color: Theme.of(context).accentColor,
fontWeight: FontWeight.bold,
),
),
Icon(
FontAwesomeIcons.angleRight,
color: Colors.grey,
),
],
)
],
),
),
],
),
),
Divider(),
Padding(
padding: const EdgeInsets.all(4.0),
child: Card(
child: Container(
height: 285.0,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
stops: [0.1, 1.0],
colors: <Color>[Colors.white, Colors.blue[50]]),
),
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(12.0),
child: Container(
height: 160.0,
width: MediaQuery.of(context).size.width * 0.8,
child: Image.network(
"https://semantic-ui.com/images/wireframe/image.png",
fit: BoxFit.cover,
loadingBuilder: (BuildContext context,
Widget child,
ImageChunkEvent loadingProgress) {
if (loadingProgress == null) return child;
return Center(
child: CircularProgressIndicator(
value: loadingProgress.expectedTotalBytes !=
null
? loadingProgress
.cumulativeBytesLoaded /
loadingProgress.expectedTotalBytes
: null,
),
);
},
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"AND CO app advertistment",
style: TextStyle(
fontSize: 14.0,
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: 45.0,
width: MediaQuery.of(context).size.width,
child: RaisedButton(
onPressed: () {},
color: Theme.of(context).accentColor,
child: Text(
"Get the free app",
style: TextStyle(
color: Colors.white,
),
),
),
),
),
],
)),
),
)
],
),
),
);
}
}
| 0 |
mirrored_repositories/FiverrClone/lib | mirrored_repositories/FiverrClone/lib/pages/message_inbox.dart | import 'package:flutter/material.dart';
class MessageInboxPage extends StatefulWidget {
@override
_MessageInboxPageState createState() => _MessageInboxPageState();
}
class _MessageInboxPageState extends State<MessageInboxPage> {
@override
void initState() {
super.initState();
}
Future<void> _refreshMessages() async {}
var _messages = [
{
"image":
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2L-Zfe-iYizglLDH55UD3wXBJre7V98QwKfsBCfR_8YfvXPnN&s",
"username": "codeman",
"online": true,
"receivedOn": "4 days ago",
"message":
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.",
"starred": true
},
{
"image":
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2L-Zfe-iYizglLDH55UD3wXBJre7V98QwKfsBCfR_8YfvXPnN&s",
"username": "olivefam",
"online": true,
"receivedOn": "4 days ago",
"message":
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.",
"starred": false
},
{
"image":
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2L-Zfe-iYizglLDH55UD3wXBJre7V98QwKfsBCfR_8YfvXPnN&s",
"username": "mediaguy",
"online": false,
"receivedOn": "4 days ago",
"message":
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.",
"starred": true
},
{
"image":
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2L-Zfe-iYizglLDH55UD3wXBJre7V98QwKfsBCfR_8YfvXPnN&s",
"username": "upwardsquad",
"online": false,
"receivedOn": "1 week ago",
"message":
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.",
"starred": false
},
{
"image":
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2L-Zfe-iYizglLDH55UD3wXBJre7V98QwKfsBCfR_8YfvXPnN&s",
"username": "jacob",
"online": true,
"receivedOn": "3 weeks ago",
"message":
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.",
"starred": false
},
{
"image":
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2L-Zfe-iYizglLDH55UD3wXBJre7V98QwKfsBCfR_8YfvXPnN&s",
"username": "ninny",
"online": false,
"receivedOn": "4 weeks ago",
"message":
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.",
"starred": true
},
{
"image":
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2L-Zfe-iYizglLDH55UD3wXBJre7V98QwKfsBCfR_8YfvXPnN&s",
"username": "samnad",
"online": true,
"receivedOn": "4 weeks ago",
"message":
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.",
"starred": false
},
{
"image":
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2L-Zfe-iYizglLDH55UD3wXBJre7V98QwKfsBCfR_8YfvXPnN&s",
"username": "mikestad",
"online": false,
"receivedOn": "1 month ago",
"message":
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.",
"starred": false
},
{
"image":
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2L-Zfe-iYizglLDH55UD3wXBJre7V98QwKfsBCfR_8YfvXPnN&s",
"username": "sasha",
"online": true,
"receivedOn": "2 months ago",
"message":
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.",
"starred": false
},
{
"image":
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2L-Zfe-iYizglLDH55UD3wXBJre7V98QwKfsBCfR_8YfvXPnN&s",
"username": "nisha",
"online": false,
"receivedOn": "2 months ago",
"message":
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.",
"starred": false
},
{
"image":
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2L-Zfe-iYizglLDH55UD3wXBJre7V98QwKfsBCfR_8YfvXPnN&s",
"username": "belledum",
"online": false,
"receivedOn": "2 months ago",
"message":
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.",
"starred": false
},
{
"image":
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2L-Zfe-iYizglLDH55UD3wXBJre7V98QwKfsBCfR_8YfvXPnN&s",
"username": "dumble",
"online": false,
"receivedOn": "2 months ago",
"message":
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.",
"starred": false
},
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Inbox"),
actions: <Widget>[
IconButton(
icon: Icon(Icons.filter_list),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
fullscreenDialog: true,
builder: (context) => MessageFilter(),
),
);
},
),
],
),
body: RefreshIndicator(
color: Colors.black87,
onRefresh: _refreshMessages,
child: ListView.builder(
itemCount: _messages.length,
itemBuilder: (context, int index) {
return InkWell(
onTap: () {},
child: ListTile(
leading: InkWell(
onTap: () {},
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
child: CircleAvatar(
radius: 30.0,
backgroundImage: NetworkImage(_messages[index]['image']),
),
),
title: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Text(_messages[index]['username']),
SizedBox(
width: 5.0,
),
_messages[index]['online']
? Text(
"online",
style: TextStyle(
color: Theme.of(context).accentColor,
fontSize: 14.0,
),
)
: Text(""),
],
),
subtitle: Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Container(
height: 15,
child: RichText(
overflow: TextOverflow.ellipsis,
strutStyle: StrutStyle(fontSize: 12.0),
text: TextSpan(
text: _messages[index]['message'],
style: TextStyle(color: Colors.black),
),
),
),
),
trailing: Flex(
direction: Axis.vertical,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Text(
_messages[index]['receivedOn'],
style: TextStyle(color: Colors.grey, fontSize: 12.0),
),
InkWell(
onTap: () {},
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
child: Container(
width: 50.0,
height: 40.0,
child: _messages[index]['starred']
? Icon(
Icons.star,
color: Colors.amber,
)
: Icon(Icons.star_border),
),
),
],
),
),
);
},
),
),
);
}
}
class MessageFilter extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Select label"),
),
body: Container(
child: Column(
children: <Widget>[
Padding(
padding: EdgeInsets.only(left: 20.0, top: 20.0, bottom: 10.0),
child: Container(
width: MediaQuery.of(context).size.width,
child: Text(
"FILTERS",
style: TextStyle(
fontSize: 12.0,
color: Colors.grey,
),
),
),
),
InkWell(
onTap: () {},
child: Padding(
padding: EdgeInsets.only(left: 20.0, top: 15.0, bottom: 10.0),
child: Container(
width: MediaQuery.of(context).size.width,
child: Text(
"All",
style: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
),
),
),
),
),
InkWell(
onTap: () {},
child: Padding(
padding: EdgeInsets.only(left: 20.0, top: 15.0, bottom: 10.0),
child: Container(
width: MediaQuery.of(context).size.width,
child: Text(
"Unread",
style: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
),
),
),
),
),
InkWell(
onTap: () {},
child: Padding(
padding: EdgeInsets.only(left: 20.0, top: 15.0, bottom: 10.0),
child: Container(
width: MediaQuery.of(context).size.width,
child: Text(
"Starred",
style: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
),
),
),
),
),
InkWell(
onTap: () {},
child: Padding(
padding: EdgeInsets.only(left: 20.0, top: 15.0, bottom: 10.0),
child: Container(
width: MediaQuery.of(context).size.width,
child: Text(
"Archived",
style: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
),
),
),
),
),
InkWell(
onTap: () {},
child: Padding(
padding: EdgeInsets.only(left: 20.0, top: 15.0, bottom: 10.0),
child: Container(
width: MediaQuery.of(context).size.width,
child: Text(
"Spam",
style: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
),
),
),
),
),
InkWell(
onTap: () {},
child: Padding(
padding: EdgeInsets.only(left: 20.0, top: 15.0, bottom: 10.0),
child: Container(
width: MediaQuery.of(context).size.width,
child: Text(
"Sent",
style: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
),
),
),
),
),
InkWell(
onTap: () {},
child: Padding(
padding: EdgeInsets.only(left: 20.0, top: 15.0, bottom: 10.0),
child: Container(
width: MediaQuery.of(context).size.width,
child: Text(
"Custom Offers",
style: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
),
),
),
),
),
Padding(
padding: EdgeInsets.only(left: 20.0, top: 15.0, bottom: 10.0),
child: Container(
width: MediaQuery.of(context).size.width,
child: Text(
"LABELS",
style: TextStyle(
fontSize: 12.0,
color: Colors.grey,
),
),
),
),
InkWell(
onTap: () {},
child: Padding(
padding: EdgeInsets.only(left: 20.0, top: 15.0, bottom: 10.0),
child: Container(
width: MediaQuery.of(context).size.width,
child: Text(
"Follow-up",
style: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
),
),
),
),
),
InkWell(
onTap: () {},
child: Padding(
padding: EdgeInsets.only(left: 20.0, top: 15.0, bottom: 10.0),
child: Container(
width: MediaQuery.of(context).size.width,
child: Text(
"Nudge",
style: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
),
),
),
),
),
],
),
),
);
}
}
| 0 |
mirrored_repositories/FiverrClone/lib | mirrored_repositories/FiverrClone/lib/pages/manage_sales.dart | import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
class ManageSales extends StatefulWidget {
@override
_ManageSalesState createState() => _ManageSalesState();
}
class _ManageSalesState extends State<ManageSales> {
@override
void initState() {
super.initState();
}
@override
void dispose() {
super.dispose();
}
var _completedOrders = [
{
"username": "brad",
"online": true,
"image":
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2L-Zfe-iYizglLDH55UD3wXBJre7V98QwKfsBCfR_8YfvXPnN&s",
"gigTitle": "Create a react application",
"date": "20 Jan 2020",
"price": "US\$5"
},
{
"username": "femmertz",
"online": false,
"image":
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2L-Zfe-iYizglLDH55UD3wXBJre7V98QwKfsBCfR_8YfvXPnN&s",
"gigTitle": "Create an angular application",
"date": "18 Jan 2020",
"price": "US\$35"
},
{
"username": "beep",
"online": true,
"image":
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2L-Zfe-iYizglLDH55UD3wXBJre7V98QwKfsBCfR_8YfvXPnN&s",
"gigTitle": "Create an amazing flutter app",
"date": "12 Jan 2020",
"price": "US\$150"
},
{
"username": "alex",
"online": false,
"image":
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2L-Zfe-iYizglLDH55UD3wXBJre7V98QwKfsBCfR_8YfvXPnN&s",
"gigTitle": "Create a prototype with adobe xd",
"date": "15 Jan 2020",
"price": "US\$15"
},
{
"username": "ninny",
"online": false,
"image":
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2L-Zfe-iYizglLDH55UD3wXBJre7V98QwKfsBCfR_8YfvXPnN&s",
"gigTitle": "Create a nodejs rest api",
"date": "15 Jan 2020",
"price": "US\$5"
},
];
var _cancelledOrders = [
{
"username": "david",
"online": true,
"image":
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2L-Zfe-iYizglLDH55UD3wXBJre7V98QwKfsBCfR_8YfvXPnN&s",
"gigTitle": "Create a logo animation",
"date": "02 Dec 2019",
"price": "US\$25"
},
{
"username": "source",
"image":
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2L-Zfe-iYizglLDH55UD3wXBJre7V98QwKfsBCfR_8YfvXPnN&s",
"gigTitle": "Create a professional logo design",
"date": "15 Dec 2019",
"price": "US\$5"
},
];
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: 2,
child: Scaffold(
appBar: AppBar(
elevation: 0.0,
title: Text("Manage Sales"),
actions: <Widget>[
IconButton(
icon: Icon(FontAwesomeIcons.questionCircle),
onPressed: () {},
)
],
bottom: TabBar(
labelColor: Theme.of(context).accentColor,
unselectedLabelColor: Colors.grey,
tabs: <Widget>[
Tab(
text: "COMPLETED (${_completedOrders.length})",
),
Tab(
text: "CANCELLED (${_cancelledOrders.length})",
),
],
),
),
body: TabBarView(
children: <Widget>[
ListView.builder(
itemCount: _completedOrders.length,
itemBuilder: (context, int index) {
return Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
child: Card(
child: Padding(
padding: const EdgeInsets.only(top: 8.0, bottom: 8.0),
child: InkWell(
onTap: () {},
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
child: ListTile(
leading: Stack(
alignment: Alignment.bottomRight,
children: <Widget>[
CircleAvatar(
radius: 20.0,
backgroundImage: NetworkImage(
_completedOrders[index]['image']),
),
Container(
child: CircleAvatar(
radius: 5.0,
backgroundColor: _completedOrders[index]
['online']
? Colors.grey
: Color(0xFF1DBF73),
),
decoration: new BoxDecoration(
shape: BoxShape.circle,
color: const Color(0xFFFFFFFF),
// border color
border:
Border.all(color: Colors.white, width: 2),
),
),
],
),
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
_completedOrders[index]['username'],
style: TextStyle(
fontSize: 15.0,
),
),
Text(
_completedOrders[index]['date'],
style: TextStyle(
color: Colors.grey,
fontSize: 15.0,
),
),
],
),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
top: 8.0, bottom: 8.0),
child: Container(
height: 40.0,
child: Text(
_completedOrders[index]['gigTitle'],
style: TextStyle(
color: Colors.black,
fontSize: 16.0,
),
),
),
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
child: Container(
decoration: BoxDecoration(
border: Border.all(
width: 1.0, color: Colors.black38),
borderRadius: BorderRadius.all(
Radius.circular(5.0),
),
),
child: Center(
child: Padding(
padding: const EdgeInsets.all(4.0),
child: Text(
"COMPLETED",
style: TextStyle(
color: Colors.black38,
fontSize: 9.0,
fontWeight: FontWeight.bold,
),
),
),
),
),
),
Text(
_completedOrders[index]['price'],
style: TextStyle(
color: Theme.of(context).accentColor,
fontWeight: FontWeight.bold),
),
],
),
],
),
),
),
),
),
);
},
),
// ========= Cancelled Orders ===========
ListView.builder(
itemCount: _cancelledOrders.length,
itemBuilder: (context, int index) {
return Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
child: Card(
child: Padding(
padding: const EdgeInsets.only(top: 8.0, bottom: 8.0),
child: InkWell(
onTap: () {},
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
child: ListTile(
leading: Stack(
alignment: Alignment.bottomRight,
children: <Widget>[
CircleAvatar(
radius: 20.0,
backgroundImage: NetworkImage(
_cancelledOrders[index]['image']),
),
Container(
child: CircleAvatar(
radius: 5.0,
backgroundColor: Color(0xFF1DBF73),
),
decoration: new BoxDecoration(
shape: BoxShape.circle,
color: const Color(0xFFFFFFFF),
// border color
border:
Border.all(color: Colors.white, width: 2),
),
),
],
),
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
_cancelledOrders[index]['username'],
style: TextStyle(
fontSize: 15.0,
),
),
Text(
_cancelledOrders[index]['date'],
style: TextStyle(
color: Colors.grey,
fontSize: 15.0,
),
),
],
),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
top: 8.0, bottom: 8.0),
child: Container(
height: 40.0,
child: Text(
_cancelledOrders[index]['gigTitle'],
style: TextStyle(
color: Colors.black,
fontSize: 16.0,
),
),
),
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
child: Container(
decoration: BoxDecoration(
border: Border.all(
width: 1.0, color: Colors.black38),
borderRadius: BorderRadius.all(
Radius.circular(5.0),
),
),
child: Center(
child: Padding(
padding: const EdgeInsets.all(4.0),
child: Text(
"CANCELLED",
style: TextStyle(
color: Colors.black38,
fontSize: 9.0,
fontWeight: FontWeight.bold,
),
),
),
),
),
),
Text(
_cancelledOrders[index]['price'],
style: TextStyle(
color: Theme.of(context).accentColor,
fontWeight: FontWeight.bold),
),
],
),
],
),
),
),
),
),
);
},
),
],
),
),
);
}
}
| 0 |
mirrored_repositories/FiverrClone/lib | mirrored_repositories/FiverrClone/lib/pages/home.dart | import 'package:flutter/material.dart';
import 'dart:math';
import 'package:fiverr_clone/pages/earnings.dart';
import 'package:fiverr_clone/pages/profile/profile.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:flutter_circular_chart/flutter_circular_chart.dart';
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage>
with SingleTickerProviderStateMixin {
double _requirementsTapMinHeight = 60.0;
double _levelsHeight = 60.0;
double _levelsMaxHeight = 380.0;
double _defaultFontSize = 16.0;
AnimationController _controller;
final GlobalKey<AnimatedCircularChartState> _chartKeyResponse =
new GlobalKey<AnimatedCircularChartState>();
final GlobalKey<AnimatedCircularChartState> _chartKeyOrders =
new GlobalKey<AnimatedCircularChartState>();
final GlobalKey<AnimatedCircularChartState> _chartKeyDelivery =
new GlobalKey<AnimatedCircularChartState>();
final GlobalKey<AnimatedCircularChartState> _chartKeyRating =
new GlobalKey<AnimatedCircularChartState>();
final _chartSize = const Size(80.0, 80.0);
@override
void initState() {
super.initState();
this._controller = AnimationController(
duration: Duration(milliseconds: 500),
vsync: this,
);
}
@override
void dispose() {
super.dispose();
}
Future<void> _refreshHome() async {}
@override
Widget build(BuildContext context) {
final rotateAnimation = Tween(begin: 0.0, end: pi).animate(
CurvedAnimation(parent: this._controller, curve: Curves.easeInOut),
);
return Scaffold(
appBar: AppBar(
title: Text("bruce"),
actions: <Widget>[
InkWell(
onTap: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => ProfilePage()));
},
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
width: 36.0,
height: 36.0,
child: Stack(
alignment: Alignment.bottomRight,
children: <Widget>[
CircleAvatar(
radius: 14.0,
backgroundImage:
AssetImage("assets/images/fiverr_logo.png"),
),
Container(
child: CircleAvatar(
radius: 4.0,
backgroundColor: Color(0xFF1DBF73),
),
decoration: new BoxDecoration(
shape: BoxShape.circle,
color: const Color(0xFFFFFFFF), // border color
border: Border.all(color: Colors.white, width: 2),
),
),
],
),
),
),
),
],
),
body: RefreshIndicator(
color: Colors.black87,
onRefresh: _refreshHome,
child: ListView(
children: <Widget>[
Container(
height: 300.0,
color: Color(0xFF313131),
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Column(
children: <Widget>[
Padding(
padding:
const EdgeInsets.only(top: 25.0, bottom: 16.0),
child: Flex(
direction: Axis.horizontal,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"Standards to maintain",
style: TextStyle(
color: Colors.white,
fontSize: 20.0,
fontWeight: FontWeight.bold,
),
),
InkWell(
onTap: () {},
child: Icon(
FontAwesomeIcons.questionCircle,
color: Colors.white,
),
),
],
),
),
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Flex(
direction: Axis.horizontal,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"Seller level",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
Text(
"Level One",
style: TextStyle(
color: Colors.grey,
fontWeight: FontWeight.bold,
),
),
],
),
),
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Flex(
direction: Axis.horizontal,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"Next evaluation",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
Text(
"Feb 15, 2020",
style: TextStyle(
color: Colors.grey,
fontWeight: FontWeight.bold,
),
),
],
),
),
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Flex(
direction: Axis.horizontal,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"Response Time",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
Text(
"1 Hour",
style: TextStyle(
color: Theme.of(context).accentColor,
fontWeight: FontWeight.bold,
),
),
],
),
),
],
),
),
Padding(
padding:
const EdgeInsets.only(top: 25.0, left: 8.0, right: 8.0),
child: Flex(
direction: Axis.horizontal,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Column(
children: <Widget>[
Tooltip(
message:
"Respond to 90% of the inquiries\nyou received in the last 60 days",
textStyle: TextStyle(
color: Colors.black,
),
verticalOffset: 90.0,
padding: EdgeInsets.all(8.0),
margin: EdgeInsets.all(10.0),
decoration: BoxDecoration(
color: Colors.white,
),
child: AnimatedCircularChart(
key: _chartKeyResponse,
size: _chartSize,
initialChartData: <CircularStackEntry>[
new CircularStackEntry(
<CircularSegmentEntry>[
new CircularSegmentEntry(
100.0,
Theme.of(context).accentColor,
rankKey: 'completed',
),
new CircularSegmentEntry(
100.0,
Colors.white12,
rankKey: 'remaining',
),
],
rankKey: 'progress',
),
],
chartType: CircularChartType.Radial,
percentageValues: true,
holeLabel: "100%",
labelStyle: new TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 20.0,
),
),
),
Text(
"Response\nrate",
style: TextStyle(
color: Colors.white,
),
textAlign: TextAlign.center,
),
],
),
Column(
children: <Widget>[
Tooltip(
message:
"Complete 90% of your orders,\nover the course of 60 days",
textStyle: TextStyle(
color: Colors.black,
),
verticalOffset: 90.0,
padding: EdgeInsets.all(8.0),
margin: EdgeInsets.all(10.0),
decoration: BoxDecoration(
color: Colors.white,
),
child: AnimatedCircularChart(
key: _chartKeyOrders,
size: _chartSize,
initialChartData: <CircularStackEntry>[
new CircularStackEntry(
<CircularSegmentEntry>[
new CircularSegmentEntry(
100.0,
Theme.of(context).accentColor,
rankKey: 'completed',
),
new CircularSegmentEntry(
100.0,
Colors.white12,
rankKey: 'remaining',
),
],
rankKey: 'progress',
),
],
chartType: CircularChartType.Radial,
percentageValues: true,
holeLabel: "100%",
labelStyle: new TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 20.0,
),
),
),
Text(
"Order\ncompletion",
style: TextStyle(
color: Colors.white,
),
textAlign: TextAlign.center,
),
],
),
Column(
children: <Widget>[
Tooltip(
message:
"Deliver 90% of your orders on time,\nover the course of 60 days",
textStyle: TextStyle(
color: Colors.black,
),
verticalOffset: 90.0,
padding: EdgeInsets.all(8.0),
margin: EdgeInsets.all(10.0),
decoration: BoxDecoration(
color: Colors.white,
),
child: AnimatedCircularChart(
key: _chartKeyDelivery,
size: _chartSize,
initialChartData: <CircularStackEntry>[
new CircularStackEntry(
<CircularSegmentEntry>[
new CircularSegmentEntry(
100.0,
Theme.of(context).accentColor,
rankKey: 'completed',
),
new CircularSegmentEntry(
100.0,
Colors.white12,
rankKey: 'remaining',
),
],
rankKey: 'progress',
),
],
chartType: CircularChartType.Radial,
percentageValues: true,
holeLabel: "100%",
labelStyle: new TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 20.0,
),
),
),
Text(
"On-time\ndelivery",
style: TextStyle(
color: Colors.white,
),
textAlign: TextAlign.center,
),
],
),
Column(
children: <Widget>[
Tooltip(
message:
"Maintain a 4.7 star rating or above,\nover the course of 60 days",
textStyle: TextStyle(
color: Colors.black,
),
verticalOffset: 90.0,
padding: EdgeInsets.all(8.0),
margin: EdgeInsets.all(10.0),
decoration: BoxDecoration(
color: Colors.white,
),
child: AnimatedCircularChart(
key: _chartKeyRating,
size: _chartSize,
initialChartData: <CircularStackEntry>[
new CircularStackEntry(
<CircularSegmentEntry>[
new CircularSegmentEntry(
(5.0 / 5.0) * 100,
Theme.of(context).accentColor,
rankKey: 'completed',
),
new CircularSegmentEntry(
100.0,
Colors.white12,
rankKey: 'remaining',
),
],
rankKey: 'progress',
),
],
chartType: CircularChartType.Radial,
percentageValues: true,
holeLabel: "5.0",
labelStyle: new TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 20.0,
),
),
),
Text(
"Positive\nrating",
style: TextStyle(
color: Colors.white,
),
textAlign: TextAlign.center,
),
],
),
],
),
),
],
),
),
AnimatedContainer(
curve: Curves.easeInOut,
duration: Duration(milliseconds: 500),
height: this._levelsHeight,
decoration: BoxDecoration(
color: Color(0xFF313131),
),
child: Wrap(
children: <Widget>[
InkWell(
onTap: () {
setState(() {
// animate level requirements container
_levelsHeight =
_levelsHeight == _requirementsTapMinHeight
? _levelsMaxHeight
: _requirementsTapMinHeight;
// animate dropdown icon
_levelsHeight > _requirementsTapMinHeight
? _controller.forward()
: _controller.reverse();
});
},
child: Container(
height: _requirementsTapMinHeight,
decoration: BoxDecoration(
border: Border(
top: BorderSide(
color: Colors.white10,
width: 0.5,
),
),
),
child: ListTile(
title: Text(
"Next level requirements",
style: TextStyle(
color: Colors.white,
fontSize: 18.0,
fontWeight: FontWeight.w500,
),
),
trailing: AnimatedBuilder(
builder: (context, child) {
return Transform.rotate(
angle: rotateAnimation.value,
child: child,
);
},
animation: rotateAnimation,
child: Icon(
FontAwesomeIcons.angleDown,
color: Colors.grey,
),
),
),
),
),
AnimatedOpacity(
curve: Curves.easeInOut,
duration: Duration(milliseconds: 500),
opacity: _levelsHeight == _levelsMaxHeight ? 1.0 : 0.0,
child: Wrap(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 5.0),
child: ListTile(
title: Text(
"Selling Seniority",
style: TextStyle(
color: Colors.white,
fontSize: _defaultFontSize,
),
),
subtitle: Padding(
padding: const EdgeInsets.only(top: 5.0),
child: Text(
"Complete at least 120 days as a Level One Seller.",
style: TextStyle(
color: Colors.white30,
),
),
),
trailing: Text(
"120 / 120",
style: TextStyle(
color: Theme.of(context).accentColor,
fontSize: _defaultFontSize,
),
),
),
),
Divider(),
ListTile(
title: Text(
"Orders",
style: TextStyle(
color: Colors.white,
fontSize: _defaultFontSize),
),
subtitle: Padding(
padding: const EdgeInsets.only(top: 5.0),
child: Text(
"Receive and complete at least 50\norders (all time).",
style: TextStyle(color: Colors.white30),
),
),
trailing: Text(
"50 / 50",
style: TextStyle(
color: Theme.of(context).accentColor,
fontSize: _defaultFontSize,
),
),
),
Divider(),
ListTile(
title: Text(
"Earnings",
style: TextStyle(
color: Colors.white,
fontSize: _defaultFontSize),
),
subtitle: Padding(
padding: const EdgeInsets.only(top: 5.0),
child: Text(
"Earn at least \$2000 from completed orders (all time).",
style: TextStyle(color: Colors.white30),
),
),
trailing: Text(
"\$1,214 / \$2,000",
style: TextStyle(
color: Colors.white30,
fontSize: _defaultFontSize,
),
),
),
Divider(),
Padding(
padding: const EdgeInsets.only(top: 0.0),
child: ListTile(
title: Text(
"Days Without Warnings",
style: TextStyle(
color: Colors.white,
fontSize: _defaultFontSize),
),
subtitle: Padding(
padding: const EdgeInsets.only(top: 5.0),
child: Text(
"Avoid receiving warnings for TOS\nviolations over the course of 30 days.",
style: TextStyle(
color: Colors.white30,
),
),
),
trailing: Text(
"50 / 50",
style: TextStyle(
color: Theme.of(context).accentColor,
fontSize: _defaultFontSize,
),
),
),
),
],
),
),
],
),
),
Container(
height: 50.0,
child: ListTile(
title: Text(
"Earnings",
style: TextStyle(
color: Colors.black38,
),
),
trailing: InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => EarningsPage(),
),
);
},
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
child: Text(
"View Details",
style: TextStyle(
color: Theme.of(context).accentColor,
),
),
),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
child: Card(
elevation: 2,
child: Column(
children: <Widget>[
Container(
height: 50.0,
child: Flex(
mainAxisAlignment: MainAxisAlignment.start,
direction: Axis.horizontal,
children: <Widget>[
Expanded(
flex: 1,
child: ListTile(
dense: true,
contentPadding: EdgeInsets.only(left: 10.0),
title: Text(
"Personal balance",
style: TextStyle(
color: Colors.black87,
fontSize: 14.0,
),
),
subtitle: Text(
"US\$36.90",
style: TextStyle(
color: Theme.of(context).accentColor,
fontSize: 18.0,
fontWeight: FontWeight.bold),
),
),
),
Expanded(
flex: 1,
child: ListTile(
dense: true,
contentPadding: EdgeInsets.only(left: 10.0),
title: Text(
"Earning in January",
style: TextStyle(
color: Colors.black87,
fontSize: 14.0,
),
),
subtitle: Text(
"US\$8.07",
style: TextStyle(
color: Colors.black,
fontSize: 18.0,
fontWeight: FontWeight.normal,
),
),
),
),
],
),
),
Container(
height: 50.0,
child: Flex(
mainAxisAlignment: MainAxisAlignment.start,
direction: Axis.horizontal,
children: <Widget>[
Expanded(
flex: 1,
child: ListTile(
dense: true,
contentPadding: EdgeInsets.only(left: 10.0),
title: Text(
"Avg. selling price",
style: TextStyle(
color: Colors.black87,
fontSize: 14.0,
),
),
subtitle: Text(
"US\$17.80",
style: TextStyle(
color: Colors.black,
fontSize: 18.0,
fontWeight: FontWeight.normal,
),
),
),
),
Expanded(
flex: 1,
child: ListTile(
dense: true,
contentPadding: EdgeInsets.only(left: 10.0),
title: Text(
"Active orders",
style: TextStyle(
color: Colors.black87,
fontSize: 14.0,
),
),
subtitle: RichText(
text: TextSpan(
text: "1",
style: TextStyle(
color: Colors.black,
fontSize: 18.0,
fontWeight: FontWeight.normal),
children: <TextSpan>[
TextSpan(
text: " (US\$20)",
style: TextStyle(
color: Colors.grey,
fontSize: 18.0,
fontWeight: FontWeight.normal),
),
],
),
),
),
),
],
),
),
Container(
height: 70.0,
child: Flex(
mainAxisAlignment: MainAxisAlignment.start,
direction: Axis.horizontal,
children: <Widget>[
Expanded(
flex: 1,
child: ListTile(
dense: true,
contentPadding: EdgeInsets.only(left: 10.0),
title: Text(
"Pending clearance",
style: TextStyle(
color: Colors.black87,
fontSize: 14.0,
),
),
subtitle: Text(
"US\$26.85",
style: TextStyle(
color: Colors.black,
fontSize: 18.0,
fontWeight: FontWeight.normal,
),
),
),
),
Expanded(
flex: 1,
child: ListTile(
dense: true,
contentPadding: EdgeInsets.only(left: 10.0),
title: Text(
"Cancelled orders",
style: TextStyle(
color: Colors.black87,
fontSize: 14.0,
),
),
subtitle: RichText(
text: TextSpan(
text: "0",
style: TextStyle(
color: Colors.black,
fontSize: 18.0,
fontWeight: FontWeight.normal,
),
children: <TextSpan>[
TextSpan(
text: " (-US\$0)",
style: TextStyle(
color: Colors.grey,
fontSize: 18.0,
fontWeight: FontWeight.normal,
),
),
],
),
),
),
),
],
),
),
],
),
),
),
Container(
height: 40.0,
child: ListTile(
title: Text(
"To-Dos",
style: TextStyle(
color: Colors.black38,
),
),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
child: Card(
elevation: 2,
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 8.0, bottom: 8.0),
child: ListTile(
title: Text(
"No Unread Messages",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
subtitle: Text(
"Your response time is great!, keep up the good work"),
trailing: Container(
height: 30.0,
width: 50.0,
decoration: BoxDecoration(
border:
Border.all(width: 1.0, color: Colors.black38),
borderRadius: BorderRadius.all(
Radius.circular(20.0),
),
),
child: Center(
child: Text(
"0",
style: TextStyle(
color: Colors.black38,
fontWeight: FontWeight.bold,
),
),
),
),
),
),
Divider(),
Padding(
padding: const EdgeInsets.only(top: 0.0, bottom: 8.0),
child: ListTile(
title: Text(
"New Order",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
subtitle: Text("Start working and get things going!"),
trailing: Container(
height: 30.0,
width: 50.0,
decoration: BoxDecoration(
border:
Border.all(width: 1.0, color: Colors.black38),
borderRadius: BorderRadius.all(
Radius.circular(20.0),
),
),
child: Center(
child: Text(
"1",
style: TextStyle(
color: Colors.black38,
fontWeight: FontWeight.bold,
),
),
),
),
),
),
],
)),
),
Container(
height: 40.0,
child: ListTile(
title: Text(
"My Gigs",
style: TextStyle(
color: Colors.black38,
),
),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
child: Card(
elevation: 2,
child: Container(
height: 170,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Padding(
padding: const EdgeInsets.fromLTRB(8.0, 15.0, 8.0, 8.0),
child: Flex(
direction: Axis.horizontal,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"Overall statistics",
),
Text(
"Last 7 days",
style: TextStyle(
color: Colors.grey,
),
),
],
),
),
Padding(
padding: const EdgeInsets.fromLTRB(8.0, 0.0, 8.0, 8.0),
child: Flex(
direction: Axis.horizontal,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"Views",
),
Container(
alignment: Alignment.centerRight,
width: 100,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text(
"46",
style: TextStyle(
color: Colors.black87,
fontWeight: FontWeight.bold,
),
),
Padding(
padding: const EdgeInsets.only(left: 5.0),
child: Icon(
FontAwesomeIcons.arrowDown,
color: Colors.red,
size: 12,
),
),
],
),
),
],
),
),
Padding(
padding: const EdgeInsets.fromLTRB(8.0, 0.0, 8.0, 8.0),
child: Flex(
direction: Axis.horizontal,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"Impressions",
),
Container(
alignment: Alignment.centerRight,
width: 100,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text(
"574",
style: TextStyle(
color: Colors.black87,
fontWeight: FontWeight.bold,
),
),
Padding(
padding: const EdgeInsets.only(left: 5.0),
child: Icon(
FontAwesomeIcons.arrowDown,
color: Colors.red,
size: 12,
),
),
],
),
),
],
),
),
Padding(
padding: const EdgeInsets.fromLTRB(8.0, 0.0, 8.0, 8.0),
child: Flex(
direction: Axis.horizontal,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"Social Clicks",
),
Container(
alignment: Alignment.centerRight,
width: 100,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text(
"2",
style: TextStyle(
color: Colors.black87,
fontWeight: FontWeight.bold,
),
),
Padding(
padding: const EdgeInsets.only(left: 5.0),
child: Icon(
FontAwesomeIcons.minus,
color: Colors.grey,
size: 12,
),
),
],
),
),
],
),
),
Padding(
padding: const EdgeInsets.fromLTRB(8.0, 0.0, 8.0, 8.0),
child: Flex(
direction: Axis.horizontal,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"Clicks",
),
Container(
alignment: Alignment.centerRight,
width: 100,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text(
"18",
style: TextStyle(
color: Colors.black87,
fontWeight: FontWeight.bold,
),
),
Padding(
padding: const EdgeInsets.only(left: 5.0),
child: Icon(
FontAwesomeIcons.arrowUp,
color: Theme.of(context).accentColor,
size: 12,
),
),
],
),
),
],
),
),
Padding(
padding: const EdgeInsets.fromLTRB(8.0, 0.0, 8.0, 10.0),
child: Flex(
direction: Axis.horizontal,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"Conversion",
),
Container(
alignment: Alignment.centerRight,
width: 100,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text(
"0.95%",
style: TextStyle(
color: Colors.black87,
fontWeight: FontWeight.bold,
),
),
Padding(
padding: const EdgeInsets.only(left: 5.0),
child: Icon(
FontAwesomeIcons.arrowUp,
color: Theme.of(context).accentColor,
size: 12,
),
),
],
),
),
],
),
),
],
),
),
),
),
],
),
),
);
}
}
| 0 |
mirrored_repositories/FiverrClone/lib/pages | mirrored_repositories/FiverrClone/lib/pages/profile/profile_reviews.dart | import 'package:flutter/material.dart';
class ReviewsPage extends StatefulWidget {
@override
_ReviewsPageState createState() => _ReviewsPageState();
}
class _ReviewsPageState extends State<ReviewsPage> {
@override
void initState() {
super.initState();
}
var reviews = [
{
"image":
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2L-Zfe-iYizglLDH55UD3wXBJre7V98QwKfsBCfR_8YfvXPnN&s",
"username": "jaden",
"country": "United States",
"review":
"Lorem Ipsum is a lorem ipsum Lorem Ipsum is a lorem ipsum",
"portfolio": "https://semantic-ui.com/images/wireframe/image.png",
"rating": 5.0,
"date": "2 days ago"
},
{
"image":
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2L-Zfe-iYizglLDH55UD3wXBJre7V98QwKfsBCfR_8YfvXPnN&s",
"username": "subirotz",
"country": "Norway",
"review":
"Lorem Ipsum is a lorem ipsum Lorem Ipsum is a lorem ipsum",
"portfolio": "https://semantic-ui.com/images/wireframe/image.png",
"rating": 5.0,
"date": "1 week ago"
},
{
"image":
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2L-Zfe-iYizglLDH55UD3wXBJre7V98QwKfsBCfR_8YfvXPnN&s",
"username": "jademoz",
"country": "Germany",
"review":
"Lorem Ipsum is a lorem ipsum Lorem Ipsum is a lorem ipsum",
"portfolio": "https://semantic-ui.com/images/wireframe/image.png",
"rating": 5.0,
"date": "2 weeks ago"
},
{
"image":
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2L-Zfe-iYizglLDH55UD3wXBJre7V98QwKfsBCfR_8YfvXPnN&s",
"username": "alex",
"country": "United States",
"review":
"Lorem Ipsum is a lorem ipsum Lorem Ipsum is a lorem ipsum",
"portfolio": "https://semantic-ui.com/images/wireframe/image.png",
"rating": 5.0,
"date": "2 weeks ago"
},
{
"image":
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2L-Zfe-iYizglLDH55UD3wXBJre7V98QwKfsBCfR_8YfvXPnN&s",
"username": "eric",
"country": "Mexico",
"review":
"Lorem Ipsum is a lorem ipsum Lorem Ipsum is a lorem ipsum",
"portfolio": "https://semantic-ui.com/images/wireframe/image.png",
"rating": 5.0,
"date": "1 month ago"
},
{
"image":
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2L-Zfe-iYizglLDH55UD3wXBJre7V98QwKfsBCfR_8YfvXPnN&s",
"username": "kased",
"country": "United Kingdom",
"review":
"Lorem Ipsum is a lorem ipsum Lorem Ipsum is a lorem ipsum",
"portfolio": "https://semantic-ui.com/images/wireframe/image.png",
"rating": 5.0,
"date": "2 months ago"
},
];
@override
Widget build(BuildContext context) {
return ListView(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"Overall Rating",
style:
TextStyle(fontWeight: FontWeight.bold, fontSize: 18.0),
),
Row(
children: <Widget>[
Icon(
Icons.star,
size: 12.0,
color: Colors.amber,
),
Padding(
padding: const EdgeInsets.only(left: 4.0),
child: Text(
"4.9",
style: TextStyle(color: Colors.amber, fontSize: 14.0),
),
),
],
),
],
),
SizedBox(
height: 20.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text("Seller communication"),
Row(
children: <Widget>[
Icon(
Icons.star,
size: 12.0,
color: Colors.amber,
),
Padding(
padding: const EdgeInsets.only(left: 4.0),
child: Text(
"4.9",
style: TextStyle(color: Colors.amber, fontSize: 14.0),
),
),
],
),
],
),
SizedBox(
height: 20.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text("Service as described"),
Row(
children: <Widget>[
Icon(
Icons.star,
size: 12.0,
color: Colors.amber,
),
Padding(
padding: const EdgeInsets.only(left: 4.0),
child: Text(
"4.9",
style: TextStyle(color: Colors.amber, fontSize: 14.0),
),
),
],
),
],
),
SizedBox(
height: 20.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text("Would recommend"),
Row(
children: <Widget>[
Icon(
Icons.star,
size: 12.0,
color: Colors.amber,
),
Padding(
padding: const EdgeInsets.only(left: 4.0),
child: Text(
"4.9",
style: TextStyle(color: Colors.amber, fontSize: 14.0),
),
),
],
),
],
),
],
),
),
Divider(),
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"Sorted by most relevant",
style:
TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0),
),
Icon(
Icons.sort,
size: 24.0,
),
],
),
SizedBox(
height: 20.0,
),
Column(
children: new List.generate(
reviews.length,
(index) => Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
CircleAvatar(
radius: 15.0,
backgroundImage: NetworkImage(
reviews[index]["image"],
),
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
reviews[index]["username"],
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14.0,
),
),
SizedBox(height: 5.0),
Text(
reviews[index]["country"],
style: TextStyle(
color: Colors.grey,
fontSize: 12.0,
),
),
SizedBox(height: 5.0),
Container(
width: MediaQuery.of(context).size.width * 0.6,
child: Text(
reviews[index]["review"],
style: TextStyle(
fontSize: 14.0,
),
),
),
SizedBox(height: 10.0),
Container(
height: 30.0,
width: 60.0,
child: Image.network(
reviews[index]["portfolio"],
fit: BoxFit.cover,
),
),
],
),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Row(
children: <Widget>[
Icon(
Icons.star,
size: 12.0,
color: Colors.amber,
),
Padding(
padding: const EdgeInsets.only(left: 4.0),
child: Text(
reviews[index]["rating"].toString(),
style: TextStyle(
color: Colors.amber,
),
),
),
],
),
SizedBox(height: 5.0),
Text(
reviews[index]["date"],
style: TextStyle(
color: Colors.grey,
fontSize: 12.0,
),
),
],
),
],
),
),
),
).toList(),
),
],
),
),
],
);
}
}
| 0 |
mirrored_repositories/FiverrClone/lib/pages | mirrored_repositories/FiverrClone/lib/pages/profile/profile.dart | import 'package:flutter/material.dart';
import 'package:fiverr_clone/pages/profile/profile_about.dart';
import 'package:fiverr_clone/pages/profile/profile_gigs.dart';
import 'package:fiverr_clone/pages/profile/profile_reviews.dart';
class ProfilePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: 3,
initialIndex: 0,
child: Scaffold(
appBar: AppBar(
title: Text("bruce"),
bottom: TabBar(
labelColor: Theme.of(context).accentColor,
unselectedLabelColor: Colors.grey,
tabs: <Widget>[
Tab(
text: "ABOUT",
),
Tab(
text: "GIGS",
),
Tab(
text: "REVIEWS",
),
],
),
),
body: TabBarView(
children: <Widget>[AboutPage(), GigsPage(), ReviewsPage()],
),
),
);
}
}
| 0 |
mirrored_repositories/FiverrClone/lib/pages | mirrored_repositories/FiverrClone/lib/pages/profile/profile_gigs.dart | import 'package:flutter/material.dart';
class GigsPage extends StatefulWidget {
@override
_GigsPageState createState() => _GigsPageState();
}
class _GigsPageState extends State<GigsPage> {
@override
void initState() {
super.initState();
}
var gigs = [
{
"image": "https://semantic-ui.com/images/wireframe/image.png",
"title": "Create a react application",
"ratings": 5.0,
"reviewCount": 15,
"price": "\$30",
"isFavourite": true
},
{
"image": "https://semantic-ui.com/images/wireframe/image.png",
"title": "Create an amazing flutter app",
"ratings": 5.0,
"reviewCount": 11,
"price": "\$5",
"isFavourite": false
},
{
"image": "https://semantic-ui.com/images/wireframe/image.png",
"title": "Create a prototype with adobe xd",
"ratings": 5.0,
"reviewCount": 10,
"price": "\$15",
"isFavourite": true
},
{
"image": "https://semantic-ui.com/images/wireframe/image.png",
"title": "Create a nodejs rest api",
"ratings": 5.0,
"reviewCount": 20,
"price": "\$20",
"isFavourite": false
},
{
"image": "https://semantic-ui.com/images/wireframe/image.png",
"title": "Create a logo animation",
"ratings": 5.0,
"reviewCount": 15,
"price": "\$5",
"isFavourite": false
},
{
"image": "https://semantic-ui.com/images/wireframe/image.png",
"title": "Create a professional logo design",
"ratings": 5.0,
"reviewCount": 15,
"price": "\$5",
"isFavourite": true
},
];
@override
Widget build(BuildContext context) {
return ListView.builder(
itemCount: gigs.length,
itemBuilder: (context, int index) {
return Padding(
padding: const EdgeInsets.only(left: 5.0, top: 5.0, right: 5.0),
child: Card(
child: Container(
height: 120,
child: Row(
children: <Widget>[
Expanded(
flex: 1,
child: Container(
height: 120.0,
decoration: BoxDecoration(
color: Colors.grey,
image: DecorationImage(
image: NetworkImage(
gigs[index]['image'],
),
fit: BoxFit.cover,
),
),
),
),
Expanded(
flex: 1,
child: Container(
height: 120.0,
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 5.0,
horizontal: 10.0,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
children: <Widget>[
Icon(
Icons.star,
size: 12.0,
color: Colors.amber,
),
Padding(
padding:
const EdgeInsets.only(left: 4.0),
child: Text(
gigs[index]['ratings'].toString(),
style: TextStyle(
color: Colors.amber,
),
),
),
Padding(
padding:
const EdgeInsets.only(left: 4.0),
child: Text(
"(${gigs[index]['reviewCount']})",
style: TextStyle(
color: Colors.grey,
),
),
),
],
),
SizedBox(
height: 10.0,
),
Container(
width: MediaQuery.of(context).size.width *
0.35,
child: Text(
gigs[index]['title'],
),
),
],
),
gigs[index]['isFavourite']
? Icon(Icons.favorite, color: Colors.red)
: Icon(Icons.favorite_border)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text(
"From ",
style: TextStyle(
color: Theme.of(context).accentColor,
),
),
Text(
gigs[index]['price'],
style: TextStyle(
color: Theme.of(context).accentColor,
fontWeight: FontWeight.bold,
),
),
],
),
],
),
),
),
),
],
),
),
),
);
},
);
}
}
| 0 |
mirrored_repositories/FiverrClone/lib/pages | mirrored_repositories/FiverrClone/lib/pages/profile/profile_about.dart | import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
class AboutPage extends StatefulWidget {
@override
_AboutPageState createState() => _AboutPageState();
}
class _AboutPageState extends State<AboutPage> {
@override
Widget build(BuildContext context) {
return ListView(
children: <Widget>[
ListTile(
leading: CircleAvatar(
radius: 15.0,
backgroundImage: AssetImage("assets/images/fiverr_logo.png"),
),
title: Text(
"bruce",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14.0,
),
),
subtitle: Row(
children: <Widget>[
Icon(
Icons.star,
size: 12.0,
color: Colors.amber,
),
Padding(
padding: const EdgeInsets.only(left: 4.0),
child: Text(
"4.9",
style: TextStyle(
color: Colors.amber,
),
),
),
Padding(
padding: const EdgeInsets.only(left: 4.0),
child: Text(
"(56)",
style: TextStyle(
color: Colors.grey,
),
),
),
],
),
),
Padding(
padding: const EdgeInsets.only(left: 15.0),
child: Text(
"User information",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
),
ListTile(
leading: Icon(Icons.location_on),
title: Text(
"From",
style: TextStyle(
color: Colors.grey,
),
),
subtitle: Text(
"Sri Lanka (10:21 p.m.)",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
),
ListTile(
leading: Icon(FontAwesomeIcons.award),
title: Text(
"Seller level",
style: TextStyle(
color: Colors.grey,
),
),
subtitle: Text(
"Level 1 seller",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
),
ListTile(
leading: Icon(Icons.person),
title: Text(
"Member since",
style: TextStyle(
color: Colors.grey,
),
),
subtitle: Text(
"Jul 2018",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
),
ListTile(
leading: Icon(Icons.watch_later),
title: Text(
"Avg. response time",
style: TextStyle(
color: Colors.grey,
),
),
subtitle: Text(
"1 hour",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
),
ListTile(
leading: Icon(FontAwesomeIcons.solidPaperPlane),
title: Text(
"Recent delivery",
style: TextStyle(
color: Colors.grey,
),
),
subtitle: Text(
"About 2 days ago",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
),
ListTile(
leading: Icon(Icons.remove_red_eye),
title: Text(
"Last active",
style: TextStyle(
color: Colors.grey,
),
),
subtitle: Text(
"Online",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
),
Divider(),
Padding(
padding: const EdgeInsets.only(top: 15.0, left: 15.0),
child: Text(
"Languages",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
),
ListTile(
leading: Icon(FontAwesomeIcons.globeAsia),
title: Text(
"English",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
subtitle: Text(
"Fluent",
style: TextStyle(
color: Colors.black,
),
),
),
ListTile(
leading: Icon(FontAwesomeIcons.globeAsia),
title: Text(
"Sinhala, Sinhalese",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
subtitle: Text(
"Native/Bilingual",
style: TextStyle(
color: Colors.black,
),
),
),
Divider(),
ListTile(
title: Text(
"Description\n",
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
),
),
subtitle: Text(
"Hi. I'm Bruce, freelance developer and designer "
"working part time on Fiverr. I have over 9 years of experience in the "
"fields of computing. I will guarantee a 100% customer satisfaction. Drop me a "
"message I'll reply asap!",
style: TextStyle(
color: Colors.black,
),
),
),
Divider(),
ListTile(
title: Text(
"Skills\n",
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
),
),
subtitle: Flex(
direction: Axis.horizontal,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: InkWell(
onTap: () {},
child: Container(
height: 35.0,
decoration: BoxDecoration(
color: Colors.black12,
borderRadius: BorderRadius.all(
Radius.circular(20.0),
),
),
child: Padding(
padding: const EdgeInsets.only(left: 10.0, right: 10.0),
child: Center(
child: Text(
"programming",
style: TextStyle(color: Colors.black),
),
),
),
),
),
),
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: InkWell(
onTap: () {},
child: Container(
height: 35.0,
decoration: BoxDecoration(
color: Colors.black12,
borderRadius: BorderRadius.all(
Radius.circular(20.0),
),
),
child: Padding(
padding: const EdgeInsets.only(left: 10.0, right: 10.0),
child: Center(
child: Text(
"development",
style: TextStyle(color: Colors.black),
),
),
),
),
),
),
],
),
),
Divider(),
],
);
}
}
| 0 |
mirrored_repositories/triviait---open-source-trivia | mirrored_repositories/triviait---open-source-trivia/lib/main.dart | import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';
import 'package:get/get_navigation/src/root/get_material_app.dart';
import 'package:triviait/controllers/triviaController.dart';
import 'package:triviait/controllers/triviaCreationController.dart';
import 'package:triviait/screens/TriviaCreateScreen.dart';
import 'package:triviait/screens/TriviaListScreen.dart';
import 'package:triviait/screens/TriviaQuestionsAnswerScreen.dart';
import 'package:triviait/screens/TriviaQuestionsScreen.dart';
import 'env/env.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(options: FirebaseOptions(
apiKey: Env.apiKey, authDomain: Env.authDomain, storageBucket: Env.storageBucket,
appId: Env.appId, messagingSenderId: Env.messagingSenderId, projectId: Env.projectId,measurementId: Env.measurementId));
configLoading();
runApp(const MyApp());
}
void configLoading() {
EasyLoading.instance
..displayDuration = const Duration(milliseconds: 100)
..indicatorType = EasyLoadingIndicatorType.ring
..loadingStyle = EasyLoadingStyle.custom
..indicatorSize = 45.0
..boxShadow = <BoxShadow>[]
..radius = 10.0
..progressColor = Colors.blue
..backgroundColor = Colors.transparent
..indicatorColor = Colors.blue
..textColor = Colors.black
..maskColor = Colors.blue.withOpacity(0.5)
..userInteractions = false
..successWidget = const SizedBox.shrink()
..errorWidget = const SizedBox.shrink()
..dismissOnTap = false;
// ..customAnimation = CustomAnimation();
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
Get.lazyPut(() => TriviaController(),permanent: true);
Get.lazyPut(() => TriviaCreationController());
return GetMaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
initialRoute: "/",
getPages: [
GetPage(name: "/", page: ()=>const TriviaListScreen()),
GetPage(name: "/question", page: ()=>const TriviaQuestionsScreen()),
GetPage(name: "/question/answers", page: ()=>const TriviaQuestionsAnswerScreen()),
GetPage(name: "/trivia/creation", page: ()=>const TriviaCreateScreen()),
],
builder: EasyLoading.init(),
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blueAccent),
useMaterial3: true, checkboxTheme: CheckboxThemeData(
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) { return null; }
if (states.contains(MaterialState.selected)) { return Colors.green; }
return null;
}),
), radioTheme: RadioThemeData(
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) { return null; }
if (states.contains(MaterialState.selected)) { return Colors.green; }
return null;
}),
), switchTheme: SwitchThemeData(
thumbColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) { return null; }
if (states.contains(MaterialState.selected)) { return Colors.green; }
return null;
}),
trackColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) { return null; }
if (states.contains(MaterialState.selected)) { return Colors.green; }
return null;
}),
),
),
);
}
} | 0 |
mirrored_repositories/triviait---open-source-trivia/lib | mirrored_repositories/triviait---open-source-trivia/lib/controllers/triviaCreationController.dart |
import 'package:flutter/cupertino.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';
import 'package:triviait/firebase/firebaseQuery.dart';
class TriviaCreationController extends GetxController{
static TriviaCreationController get instance => Get.find();
TextEditingController authorET = TextEditingController();
TextEditingController nameET = TextEditingController();
TextEditingController correctAnswerWhyET = TextEditingController();
List<Map> listQuestions = [];
String correctAnswer = "";
uploadTrivia(){
EasyLoading.show(status: "LOADING");
if(listQuestions.isEmpty || nameET.text.trim().isEmpty || authorET.text.trim().isEmpty){
Get.snackbar("ERROR","Must complete all fields");
}else{
if (listQuestions.every((mapa) =>
mapa['question'] != null &&
mapa['question'] != '' &&
mapa['answer'] != null &&
mapa['answer'] != '' &&
mapa['options'] != null &&
mapa['options'] != '' &&
mapa['options'].length >= 2)) {
// Utilizando forEach para iterar sobre la lista de mapas
FirestoreFunctions().createTrivia(author: authorET.text, name: nameET.text, questionsList: listQuestions);
}
else{
Get.snackbar("ERROR","Must complete all questions");
}
}
}
newTriviaQuestion(){
listQuestions.add({
"question":"",
"answer":null,
"options":[],
"reason":"",
});
update(["triviaCreation"]);
}
removeTriviaQuestion({required int index}){
listQuestions.removeAt(index);
update(["triviaCreation"]);
}
removeTriviaOption({required int index, required int optionsIndex}){
if(listQuestions[index]["answer"]==listQuestions[index]["options"][optionsIndex]){
listQuestions[index]["answer"] = null;
}
listQuestions[index]["options"].removeAt(optionsIndex);
update(["triviaCreation"]);
}
}
| 0 |
mirrored_repositories/triviait---open-source-trivia/lib | mirrored_repositories/triviait---open-source-trivia/lib/controllers/triviaController.dart |
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';
import 'package:triviait/firebase/firebaseQuery.dart';
class TriviaController extends GetxController{
static TriviaController get instance => Get.find();
List<Map> questionAnswerList = [];
List choosedOption = [];
getQuestions({required String id}) async {
if(questionAnswerList.isEmpty){
questionAnswerList = await FirestoreFunctions().queryQuestions(id: Get.arguments[0]["id"]);
questionAnswerList.shuffle();
for (int i = 0; i < questionAnswerList.length; i++) {
choosedOption.add("");
}
update(["triviaDetailsScreen"]);
// print(cuteandfunny.first.options);
}
}
checkAnswers({required String id,required String name}){
EasyLoading.show(status: "Analizando respuestas");
bool todosLosElementosSonValidos = choosedOption.every((elemento) {
return elemento != null && elemento.isNotEmpty;
});
print(todosLosElementosSonValidos);
if (todosLosElementosSonValidos) {
Future.delayed(const Duration(seconds: 2), () {
// Here you can write your code
EasyLoading.showSuccess("");
print("Todos los elementos son válidos.");
Get.toNamed("/question/answers",arguments: [
{"id": id,
"name":name}
]);
});
} else {
Get.snackbar("ERROR","Check all questions");
EasyLoading.showError("");
}
}
leaveTrivia(){
questionAnswerList.clear();
choosedOption.clear();
Get.offAllNamed("/");
}
}
| 0 |
mirrored_repositories/triviait---open-source-trivia/lib | mirrored_repositories/triviait---open-source-trivia/lib/widgets/questionTextFormField.dart | import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
class QuestionTextFormField extends StatelessWidget {
const QuestionTextFormField({
super.key,
required this.width,
required this.controller,
required this.onChanged,
required this.title,
this.optional = false
});
final bool optional;
final void Function(String)? onChanged;
final double width;
final TextEditingController controller;
final String title;
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.all(8),
decoration: BoxDecoration(
border: Border.all(color: Colors.black,width: 0.5)
),
child: Column(
children: [
SizedBox(
width: width,
child: Text(title,textAlign: TextAlign.left,style: GoogleFonts.roboto(fontSize: 17,fontWeight: FontWeight.w600),)
),
SizedBox(
width: width,
child: TextFormField(
decoration: InputDecoration(
hintText: optional?"Optional":null,
),
controller: controller,
onChanged: onChanged,),
),
],
),
);
}
} | 0 |
mirrored_repositories/triviait---open-source-trivia/lib | mirrored_repositories/triviait---open-source-trivia/lib/widgets/appBarButton.dart | import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
class AppBarButton extends StatelessWidget {
final Color backgroundColor;
final void Function()? onPressed;
final Icon icon;
final String title;
const AppBarButton({
super.key, required this.backgroundColor, required this.onPressed, required this.icon, required this.title,
});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: ElevatedButton.icon(
style: ElevatedButton.styleFrom(
backgroundColor: backgroundColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12), // <-- Radius
side: const BorderSide(color: Colors.black)
),
),
onPressed: onPressed,
label: Text(title,style: GoogleFonts.roboto(color: Colors.black),),
icon: icon,),
);
}
} | 0 |
mirrored_repositories/triviait---open-source-trivia/lib | mirrored_repositories/triviait---open-source-trivia/lib/widgets/creationTextFormField.dart | import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
class CreationTextFormField extends StatelessWidget {
final String title;
final TextEditingController controller;
final int maxLength;
final double width;
final void Function(String)? onChanged;
const CreationTextFormField({
super.key, required this.title, this.maxLength = 15, required this.controller, this.width = 100, this.onChanged
});
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.grey,width: 2.0),
borderRadius: BorderRadius.circular(8),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
SizedBox(
width: width,
child: Text(title,style: GoogleFonts.roboto(fontSize: 23,fontWeight: FontWeight.w700),textAlign: TextAlign.left,)),
SizedBox(
width: width,
child: TextFormField(
onChanged: onChanged,
controller: controller,
maxLength: maxLength,
),
),
],
),
),
);
}
}
| 0 |
mirrored_repositories/triviait---open-source-trivia/lib | mirrored_repositories/triviait---open-source-trivia/lib/widgets/commonButton.dart | import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
class CommonButton extends StatelessWidget {
final void Function()? onPressed;
final String title;
const CommonButton({
super.key, required this.onPressed, required this.title,
});
@override
Widget build(BuildContext context) {
return OutlinedButton(
style: OutlinedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
onPressed:onPressed, child: Text(title,style: GoogleFonts.roboto(fontSize: 18,color: Colors.blue),));
}
} | 0 |
mirrored_repositories/triviait---open-source-trivia/lib | mirrored_repositories/triviait---open-source-trivia/lib/env/env.dart | import 'package:envied/envied.dart';
part 'env.g.dart';
@Envied(path: '.env')
abstract class Env {
// FIREBASE
@EnviedField(varName: 'apiKey', obfuscate: true)
static final String apiKey = _Env.apiKey;
@EnviedField(varName: 'authDomain', obfuscate: true)
static final String authDomain = _Env.authDomain;
@EnviedField(varName: 'storageBucket', obfuscate: true)
static final String storageBucket = _Env.storageBucket;
@EnviedField(varName: 'appId', obfuscate: true)
static final String appId = _Env.appId;
@EnviedField(varName: 'messagingSenderId', obfuscate: true)
static final String messagingSenderId = _Env.messagingSenderId;
@EnviedField(varName: 'projectId', obfuscate: true)
static final String projectId = _Env.projectId;
@EnviedField(varName: 'measurementId', obfuscate: true)
static final String measurementId = _Env.measurementId;
}
| 0 |
mirrored_repositories/triviait---open-source-trivia/lib | mirrored_repositories/triviait---open-source-trivia/lib/env/env.g.dart | // GENERATED CODE - DO NOT MODIFY BY HAND
part of 'env.dart';
// **************************************************************************
// EnviedGenerator
// **************************************************************************
// coverage:ignore-file
// ignore_for_file: type=lint
final class _Env {
static const List<int> _enviedkeyapiKey = <int>[
245585685,
2587687935,
3168791438,
1816724626,
1825704386,
1099312731,
745945878,
3375478230,
4150608812,
682272702,
2394855978,
354421914,
2862510427,
1373470047,
161994187,
1393177115,
2209178812,
230574596,
4200836174,
4165671909,
2273090003,
2598050220,
1332132351,
1704196969,
3081637611,
1913671418,
2452030640,
1298979156,
684660745,
3666987505,
1036437879,
2816371848,
2768975719,
951307146,
1794258997,
1648506725,
1653377773,
1447975427,
557815746,
];
static const List<int> _envieddataapiKey = <int>[
245585748,
2587687862,
3168791540,
1816724723,
1825704337,
1099312674,
745945941,
3375478206,
4150608874,
682272751,
2394856036,
354421962,
2862510381,
1373470008,
161994139,
1393177212,
2209178867,
230574668,
4200836109,
4165671859,
2273089977,
2598050269,
1332132284,
1704196910,
3081637521,
1913671336,
2452030690,
1298979073,
684660849,
3666987430,
1036437806,
2816371907,
2768975650,
951307221,
1794259027,
1648506642,
1653377674,
1447975534,
557815713,
];
static final String apiKey = String.fromCharCodes(List<int>.generate(
_envieddataapiKey.length,
(int i) => i,
growable: false,
).map((int i) => _envieddataapiKey[i] ^ _enviedkeyapiKey[i]));
static const List<int> _enviedkeyauthDomain = <int>[
1129080933,
1011711748,
762481279,
1772427068,
2255880850,
3040966196,
852026702,
3330420633,
3250417966,
1704054324,
540119234,
2434747378,
3410502636,
2546725091,
811761597,
3693047868,
984917381,
625984706,
864872920,
4114312779,
1979701981,
2213503170,
4185768719,
2154107336,
1397729957,
453296169,
2269784595,
3510452318,
];
static const List<int> _envieddataauthDomain = <int>[
1129080855,
1011711845,
762481164,
1772427080,
2255880934,
3040966214,
852026663,
3330420719,
3250417991,
1704054357,
540119211,
2434747270,
3410502594,
2546724997,
811761620,
3693047886,
984917472,
625984672,
864872889,
4114312760,
1979701944,
2213503139,
4185768831,
2154107320,
1397729931,
453296202,
2269784700,
3510452275,
];
static final String authDomain = String.fromCharCodes(List<int>.generate(
_envieddataauthDomain.length,
(int i) => i,
growable: false,
).map((int i) => _envieddataauthDomain[i] ^ _enviedkeyauthDomain[i]));
static const List<int> _enviedkeystorageBucket = <int>[
3766402364,
3795914921,
3893706141,
2948173570,
1327591,
2982287001,
2889373061,
2838540959,
484010056,
2833175221,
2123101622,
658250909,
3910397293,
3546937751,
3630101774,
4293920238,
1952562011,
2660704750,
647436507,
322970504,
877118382,
4109693148,
1976914019,
1692730911,
];
static const List<int> _envieddatastorageBucket = <int>[
3766402382,
3795914952,
3893706222,
2948173686,
1327507,
2982287083,
2889373164,
2838541033,
484010017,
2833175252,
2123101663,
658250985,
3910397251,
3546937846,
3630101886,
4293920158,
1952561960,
2660704670,
647436468,
322970620,
877118336,
4109693119,
1976913932,
1692730994,
];
static final String storageBucket = String.fromCharCodes(List<int>.generate(
_envieddatastorageBucket.length,
(int i) => i,
growable: false,
).map((int i) => _envieddatastorageBucket[i] ^ _enviedkeystorageBucket[i]));
static const List<int> _enviedkeyappId = <int>[
1639704405,
2692134945,
3580841351,
2106500676,
2084515380,
33883664,
1968779359,
3757061756,
2657231826,
3732539354,
1944997636,
3150385601,
1795194825,
46883255,
1938185569,
1360158362,
886089903,
1474864023,
3585067770,
2389806933,
1412641330,
1330855984,
106956855,
2569881980,
2233745764,
1703383116,
2290298040,
4169531510,
2308701047,
1494107978,
1430459477,
2825434365,
2253894520,
3818382050,
2557445830,
174884214,
2109188419,
2843020138,
222803586,
2978672515,
90385578,
];
static const List<int> _envieddataappId = <int>[
1639704420,
2692134939,
3580841396,
2106500722,
2084515331,
33883686,
1968779372,
3757061711,
2657231846,
3732539375,
1944997680,
3150385652,
1795194872,
46883203,
1938185563,
1360158445,
886089930,
1474864117,
3585067712,
2389806950,
1412641283,
1330856017,
106956806,
2569881933,
2233745750,
1703383163,
2290298076,
4169531463,
2308700946,
1494108019,
1430459491,
2825434316,
2253894464,
3818382034,
2557445796,
174884114,
2109188390,
2843020114,
222803634,
2978672610,
90385608,
];
static final String appId = String.fromCharCodes(List<int>.generate(
_envieddataappId.length,
(int i) => i,
growable: false,
).map((int i) => _envieddataappId[i] ^ _enviedkeyappId[i]));
static const List<int> _enviedkeymessagingSenderId = <int>[
2276569639,
3027356589,
986546160,
2581565123,
3034165456,
167547465,
4036056424,
3388367288,
3126148015,
1427233258,
1982745086,
1409121200,
];
static const List<int> _envieddatamessagingSenderId = <int>[
2276569620,
3027356571,
986546119,
2581565173,
3034165475,
167547514,
4036056412,
3388367245,
3126147995,
1427233247,
1982745039,
1409121156,
];
static final String messagingSenderId = String.fromCharCodes(
List<int>.generate(
_envieddatamessagingSenderId.length,
(int i) => i,
growable: false,
).map((int i) =>
_envieddatamessagingSenderId[i] ^ _enviedkeymessagingSenderId[i]));
static const List<int> _enviedkeyprojectId = <int>[
1274750027,
861815148,
2892455379,
3441945552,
14611358,
1677692859,
861768445,
3147613241,
1458273470,
886335846,
4271082467,
1357814403,
];
static const List<int> _envieddataprojectId = <int>[
1274750009,
861815053,
2892455328,
3441945508,
14611434,
1677692873,
861768340,
3147613263,
1458273495,
886335751,
4271082378,
1357814519,
];
static final String projectId = String.fromCharCodes(List<int>.generate(
_envieddataprojectId.length,
(int i) => i,
growable: false,
).map((int i) => _envieddataprojectId[i] ^ _enviedkeyprojectId[i]));
static const List<int> _enviedkeymeasurementId = <int>[
1292111698,
2447978961,
2134885055,
3989727203,
14262768,
3838362347,
3921889417,
2575921088,
1370346341,
2048186915,
1353108365,
2014754206,
];
static const List<int> _envieddatameasurementId = <int>[
1292111637,
2447979004,
2134885106,
3989727163,
14262712,
3838362335,
3921889499,
2575921041,
1370346301,
2048186994,
1353108419,
2014754244,
];
static final String measurementId = String.fromCharCodes(List<int>.generate(
_envieddatameasurementId.length,
(int i) => i,
growable: false,
).map((int i) => _envieddatameasurementId[i] ^ _enviedkeymeasurementId[i]));
}
| 0 |
mirrored_repositories/triviait---open-source-trivia/lib | mirrored_repositories/triviait---open-source-trivia/lib/utils/helpers.dart | import 'package:intl/intl.dart';
String parseTimestamp(String timestamp) { // convertir a texto la fecha
var dt = DateTime.fromMillisecondsSinceEpoch(int.parse(timestamp));
// DateTime parsedDateTime = DateTime.parse(timestamp);
String formattedDateTime = DateFormat('dd MMM yyyy').format(dt);
return formattedDateTime;
} | 0 |
mirrored_repositories/triviait---open-source-trivia/lib | mirrored_repositories/triviait---open-source-trivia/lib/utils/colors.dart |
import 'dart:ui';
Color greenBackground = const Color(0xFF26F130);
Color blueBackground = const Color(0xFF5796F1); | 0 |
mirrored_repositories/triviait---open-source-trivia/lib | mirrored_repositories/triviait---open-source-trivia/lib/screens/TriviaListScreen.dart | import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_pagination/firebase_pagination.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:url_launcher/url_launcher.dart';
import '../controllers/triviaController.dart';
import '../utils/colors.dart';
import '../utils/helpers.dart';
import '../widgets/appBarButton.dart';
class TriviaListScreen extends StatelessWidget {
const TriviaListScreen({super.key});
@override
Widget build(BuildContext context) {
TextEditingController filterET = TextEditingController();
Query<Map<String, dynamic>> query = FirebaseFirestore.instance.collection('trivias');
bool forsenIsWriting = true;
final size = MediaQuery.sizeOf(context);
return Scaffold(
appBar: AppBar(
title: Column(
children: [
const Text("Trivia IT!"),
GestureDetector(
onTap: () async {
await launchUrl(Uri.parse("https://github.com/URSFR"));
},
child: Text("Made by URSFR",style: GoogleFonts.adamina(fontSize: 11,color: Colors.black),)),
],
),
actions: [
AppBarButton(title: "New Trivia",icon: const Icon(Icons.add,color: Colors.black,),backgroundColor: greenBackground,onPressed: (){
Get.toNamed("/trivia/creation");
},),
],
backgroundColor: Colors.blue,
),
body: SingleChildScrollView(
child: GetBuilder<TriviaController>(
id: "triviaList",
builder: (controller)=>
Column(children: [
Padding(
padding: const EdgeInsets.all(16.0),
child: Container(
width: size.width,
child: TextFormField(
onChanged: (value){
if(value.trim().isEmpty||value.trim()==""){
forsenIsWriting=false;
controller.update(["triviaList"]);
Future.delayed(const Duration(milliseconds: 50), () {
query= FirebaseFirestore.instance.collection('trivias');
forsenIsWriting=true;
controller.update(["triviaList"]);
});
}
},
controller: filterET,
decoration: InputDecoration(
suffixIcon: IconButton(onPressed: (){
if(filterET.text.trim().isNotEmpty){
forsenIsWriting=false;
controller.update(["triviaList"]);
Future.delayed(const Duration(milliseconds: 50), () {
query= FirebaseFirestore.instance.collection('trivias').orderBy("name").where("name",isEqualTo: filterET.text);
forsenIsWriting=true;
controller.update(["triviaList"]);
});
}
}, icon: const Icon(Icons.search)),
hintText: "Filter by Trivia Name"
),)),
),
Padding(
padding: const EdgeInsets.all(13.0),
child: SizedBox(
width: size.width,
height: size.height,
child: Visibility(
visible: forsenIsWriting,
child: FirestorePagination(
physics: const NeverScrollableScrollPhysics(),
isLive: true,
query: query,
separatorBuilder: (context, index) {
return const Divider();
},
itemBuilder: (context, documentSnapshot, index) {
final data = documentSnapshot.data() as Map<String, dynamic>;
// print(documentSnapshot.id);
return InkWell(
onTap: (){
controller.questionAnswerList = [];
controller.choosedOption = [];
Future.delayed(const Duration(seconds: 1), () {
print(documentSnapshot.id);
Get.toNamed("/question",arguments: [{"id": documentSnapshot.id,"name":data["name"]}]);
});
},
child: Column(children: [
SizedBox(
width: size.width, child: Text("Trivia Name: ${data["name"]}",textAlign: TextAlign.left,style: GoogleFonts.roboto(fontSize: 18),)),
SizedBox(
width: size.width,
child: Text("Author: ${data["createdBy"]}",style: GoogleFonts.roboto(fontSize: 14))),
SizedBox(
width: size.width,
child: Text("Created at: ${parseTimestamp(data["createdAt"])}",style: GoogleFonts.roboto(fontSize: 14))),
],),
);
// Do something cool with the data
},
),
),
),
),
],),
),
),
);
}
}
| 0 |
mirrored_repositories/triviait---open-source-trivia/lib | mirrored_repositories/triviait---open-source-trivia/lib/screens/TriviaCreateScreen.dart | import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:triviait/controllers/triviaCreationController.dart';
import 'package:triviait/firebase/firebaseQuery.dart';
import 'package:triviait/utils/colors.dart';
import '../widgets/appBarButton.dart';
import '../widgets/creationTextFormField.dart';
import '../widgets/questionTextFormField.dart';
class TriviaCreateScreen extends StatelessWidget {
const TriviaCreateScreen({super.key});
@override
Widget build(BuildContext context) {
final size = MediaQuery.sizeOf(context);
return GetBuilder<TriviaCreationController>(
id: "triviaCreation",
builder: (controller)=> Scaffold(
appBar: AppBar(
backgroundColor: Colors.teal,
title: controller.nameET.text.isEmpty?const Text("New Trivia"):Text(controller.nameET.text),
actions: [
AppBarButton(title: "Publish Trivia",backgroundColor: blueBackground,onPressed: (){
controller.uploadTrivia();
}, icon: const Icon(Icons.check,color: Colors.green,shadows: [
Shadow(
color: Colors.black,
blurRadius: 1.0,
),
],),),
],
),
body: SizedBox(
width: size.width,
height: size.height,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: SingleChildScrollView(
child: Column(children: [
CreationTextFormField(width: size.width,title: 'Trivia Name', controller: controller.nameET,onChanged: (value){
controller.update(["triviaCreation"]);
},),
const SizedBox(height: 25,),
CreationTextFormField(width: size.width,title: 'Author Name', controller: controller.authorET),
const SizedBox(height: 10,),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(children: [
Text("Questions",style: GoogleFonts.roboto(fontSize: 23,fontWeight: FontWeight.w600),),
IconButton(onPressed: (){
controller.newTriviaQuestion();
}, icon: const Icon(Icons.add))
],),
),
const SizedBox(height: 5,),
ListView.separated(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, index){
TextEditingController questionET = TextEditingController();
TextEditingController reasonET = TextEditingController();
questionET.text = controller.listQuestions[index]["question"]??"";
reasonET.text = controller.listQuestions[index]["reason"];
return Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
border:Border.all(color: Colors.black,width: 1.5)
),
child: ExpansionTile(
subtitle: questionET.text.isEmpty||controller.listQuestions[index]["options"].contains("")||controller.listQuestions[index]["options"].contains(null)||controller.listQuestions[index]["options"].length<=1||controller.listQuestions[index]["answer"]==null||controller.listQuestions[index]["answer"]==""?
Text("Not Completed",style: GoogleFonts.roboto(color: Colors.red),):Text("Completed",style: GoogleFonts.roboto(color: Colors.green),),
title: Text("Question ${index+1}"),
trailing: IconButton(icon: const Icon(Icons.delete,color: Colors.red,),onPressed: (){
controller.removeTriviaQuestion(index: index);
},),
children: [
Column(children: [
const SizedBox(height: 5,),
QuestionTextFormField(title: "What is the question?",width: size.width, controller: questionET,onChanged: (value){
controller.listQuestions[index]["question"]=value;
},),
Container(
margin: const EdgeInsets.only(top: 10),
width: size.width,
child: Row(
children: [
Text("What are the options?",textAlign: TextAlign.left,style: GoogleFonts.roboto(fontSize: 17,fontWeight: FontWeight.w600)),
IconButton(onPressed: (){
controller.listQuestions[index]["options"].add("");
controller.update(["triviaCreation"]);
}, icon: const Icon(Icons.add))
],
),
),
Container(
margin: const EdgeInsets.only(top: 5),
width:size.width,
child: ListView.separated(
shrinkWrap: true,
itemBuilder: (context, optionsIndex){
TextEditingController optionET = TextEditingController();
optionET.text = controller.listQuestions[index]["options"][optionsIndex];
return Row(
children: [
Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.black,width: 1.0)
),
width: 200,
child: TextFormField(
controller: optionET,
onFieldSubmitted: (value){
controller.update(["triviaCreation"]);
},
onSaved: (value){
controller.update(["triviaCreation"]);
},
onTapOutside: (value){
controller.update(["triviaCreation"]);
},
onEditingComplete: (){
controller.update(["triviaCreation"]);
},
onChanged: (value){
controller.listQuestions[index]["options"][optionsIndex]=value;
},),
),
Checkbox(value: controller.listQuestions[index]["answer"]==controller.listQuestions[index]["options"][optionsIndex]?true:false, onChanged: (value){
if(controller.listQuestions[index]["options"][optionsIndex]==""){
controller.update(["triviaCreation"]);
}else{
controller.listQuestions[index]["answer"]=controller.listQuestions[index]["options"][optionsIndex];
controller.update(["triviaCreation"]);
}
}),
IconButton(onPressed: (){
controller.removeTriviaOption(index: index, optionsIndex: optionsIndex);
}, icon: const Icon(Icons.delete,color: Colors.red,))
],
);
},
separatorBuilder: (context, index){return const SizedBox(height: 5,);},
itemCount: controller.listQuestions[index]["options"].length),
),
const SizedBox(height: 10,),
QuestionTextFormField(optional: true,title: "What is the reason of the answer?",width: size.width, controller: reasonET,onChanged: (value){
controller.listQuestions[index]["reason"]=value;
},),
],
),]
),
);
}, separatorBuilder: (context, index){return const SizedBox(height: 5,);},
itemCount: controller.listQuestions.length),
],),
),
),
),
),
);
}
}
| 0 |
mirrored_repositories/triviait---open-source-trivia/lib | mirrored_repositories/triviait---open-source-trivia/lib/screens/TriviaQuestionsAnswerScreen.dart | import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart';
import '../controllers/triviaController.dart';
import '../widgets/commonButton.dart';
class TriviaQuestionsAnswerScreen extends StatelessWidget {
const TriviaQuestionsAnswerScreen({super.key});
@override
Widget build(BuildContext context) {
final size = MediaQuery.sizeOf(context);
return Scaffold(
appBar: AppBar(
title: Text(Get.arguments[0]["name"]),
backgroundColor: Colors.blue,
automaticallyImplyLeading: false,
),
body: GetBuilder<TriviaController>(
id: "triviaDetailsScreen",
builder: (controller) {
return SizedBox(
width: size.width,
height: size.height,
child: SingleChildScrollView(
child: Column(children: [
ConstrainedBox(
constraints: BoxConstraints(maxHeight: size.height, minHeight: 56.0),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: ListView.separated(
shrinkWrap: true,
itemCount: controller.questionAnswerList.length,
separatorBuilder: (context, index) {
return const Divider();
},
itemBuilder: (context, index){
return Container(
padding: const EdgeInsets.all(6),
decoration: BoxDecoration(
border: Border.all(color: Colors.blue,width: 1.5)
),
child: Column(
children: [
SizedBox(
width: size.width,
child: Text(controller.questionAnswerList[index]["question"],textAlign: TextAlign.left,style: GoogleFonts.roboto(fontSize: 20,fontWeight: FontWeight.w800),)),
const SizedBox(height: 5,),
ListView.separated(
shrinkWrap: true,
itemCount: controller.questionAnswerList[index]["options"].length,
separatorBuilder: (context, index) {
return const Divider();
},
itemBuilder: (context, indexInside){
return Column(
children: [
controller.questionAnswerList[index]["answer"] == controller.questionAnswerList[index]["options"][indexInside]?Container(
alignment: Alignment.centerLeft,
width: size.width,
child: controller.questionAnswerList[index]["reason"]!=null&&controller.questionAnswerList[index]["reason"]!=""?ExpansionTile(
shape: Border.all(color: Colors.transparent),
expandedAlignment: Alignment.centerLeft,
title: Text(controller.questionAnswerList[index]["answer"],style: GoogleFonts.roboto(color: Colors.green),)
,children: [Text(controller.questionAnswerList[index]["reason"],style: GoogleFonts.roboto(),)],
):Container(padding: EdgeInsets.all(10),width: size.width,child: Text("${controller.questionAnswerList[index]["options"][indexInside]}",textAlign: TextAlign.left,style: GoogleFonts.roboto(color: Colors.green,fontSize: 20),)),
):controller.choosedOption[index] == controller.questionAnswerList[index]["options"][indexInside] && controller.questionAnswerList[index]["answer"] != controller.questionAnswerList[index]["options"][indexInside]?
Container(padding: const EdgeInsets.all(10),width: size.width,child: Text("${controller.questionAnswerList[index]["options"][indexInside]}",textAlign: TextAlign.left,style: GoogleFonts.roboto(color: Colors.red,fontSize: 15),)):
Container(padding: const EdgeInsets.all(10),width: size.width, child: Text(controller.questionAnswerList[index]["options"][indexInside],textAlign: TextAlign.left,style: GoogleFonts.roboto(fontSize: 15)),
),
],
);
},
),
],
),
);
}),
),
),
CommonButton(
onPressed: (){
controller.leaveTrivia();
},
title: "Leave Trivia",
),
],),
),
);
},
),
);
}
}
| 0 |
mirrored_repositories/triviait---open-source-trivia/lib | mirrored_repositories/triviait---open-source-trivia/lib/screens/TriviaQuestionsScreen.dart | import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_pagination/firebase_pagination.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:triviait/controllers/triviaController.dart';
import 'package:triviait/firebase/firebaseQuery.dart';
import '../widgets/commonButton.dart';
class TriviaQuestionsScreen extends StatefulWidget {
const TriviaQuestionsScreen({super.key});
@override
State<TriviaQuestionsScreen> createState() => _TriviaQuestionsScreenState();
}
class _TriviaQuestionsScreenState extends State<TriviaQuestionsScreen> {
@override
Widget build(BuildContext context) {
final size = MediaQuery.sizeOf(context);
return Scaffold(
appBar: AppBar(
title: Text(Get.arguments[0]["name"]),
backgroundColor: Colors.blue,
),
body: GetBuilder<TriviaController>(
init: TriviaController(),
id: "triviaDetailsScreen",
builder: (controller) {
controller.getQuestions(id: Get.arguments[0]["id"]);
return controller.questionAnswerList.isNotEmpty?SizedBox(
width: size.width,
height: size.height,
child: SingleChildScrollView(
child: Column(children: [
ConstrainedBox(
constraints: BoxConstraints(maxHeight: size.height, minHeight: 56.0),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: ListView.separated(
shrinkWrap: true,
itemCount: controller.questionAnswerList.length,
separatorBuilder: (context, index) {
return const SizedBox(height: 15,);
},
itemBuilder: (context, index){
return Container(
padding: const EdgeInsets.all(6),
decoration: BoxDecoration(
border: Border.all(color: Colors.blue,width: 1.5)
),
child: Column(
children: [
SizedBox(
width: size.width,
child: Text(controller.questionAnswerList[index]["question"],textAlign: TextAlign.left,style: GoogleFonts.roboto(fontSize: 20,fontWeight: FontWeight.w800),)),
const SizedBox(height: 5,),
ListView.separated(
shrinkWrap: true,
itemCount: controller.questionAnswerList[index]["options"].length,
separatorBuilder: (context, index) {
return const Divider();
},
itemBuilder: (context, indexInside){
return Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
Text("${controller.questionAnswerList[index]["options"][indexInside]}",style: GoogleFonts.roboto(fontSize: 15),),
const SizedBox(width: 45,),
Checkbox(value: controller.choosedOption[index] == controller.questionAnswerList[index]["options"][indexInside]?true:false, onChanged: (value){
controller.choosedOption[index] = controller.questionAnswerList[index]["options"][indexInside];
controller.update(["triviaDetailsScreen"]);
}),
],
),
);
},
),
],
),
);
}),
),
),
CommonButton(
onPressed: (){
controller.checkAnswers(id: Get.arguments[0]["id"], name: Get.arguments[0]["name"]);
},
title: "Check Answers",
),
],),
),
):const Center(child: CircularProgressIndicator());
},
),
);
}
}
| 0 |
mirrored_repositories/triviait---open-source-trivia/lib | mirrored_repositories/triviait---open-source-trivia/lib/firebase/firebaseQuery.dart | import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';
import 'package:xid/xid.dart';
class FirestoreFunctions{
Future<List<Map<String, dynamic>>> queryQuestions({required String id}) async {
final querySnapshot = await FirebaseFirestore.instance
.collection('trivias')
.doc(id)
.collection("questions")
.get();
List<Map<String, dynamic>> result = [];
for (var i = 0; i < querySnapshot.docs.length; i++) {
Map<String, dynamic> data = querySnapshot.docs[i].data();
result.add(data);
}
return result;
}
createTrivia({required String author, required String name, required List<Map> questionsList}){
try{
var triviaID = Xid();
FirebaseFirestore.instance.collection("trivias").doc(triviaID.toString()).set({
"createdAt": DateTime.now().millisecondsSinceEpoch.toString(),
"createdBy": author,
"name": name
}).whenComplete(() {
uploadQuestions(documentList: questionsList, id: triviaID.toString()).whenComplete(() {
EasyLoading.showSuccess("SUCCESS").whenComplete(() {
Get.toNamed("/");
});
});
});
}catch(e){
return false;
}
}
Future<void> uploadQuestions(
{required List<Map> documentList, required String id}) async {
for (int i = 0; i < documentList.length; i++) {
Map document = documentList[i];
// Puedes agregar más lógica para manejar etiquetas u otros datos según tus necesidades
// Convertir el contenido del documento a bytes (puedes ajustar esto según el tipo de contenido que estés manejando)
try {
var questionID = Xid();
await FirebaseFirestore.instance
.collection('trivias').doc(id).collection("questions").doc(questionID.toString()).set({
"question":document["question"],
"answer":document["answer"],
"options":document["options"],
"reason":document["reason"],
});
} on FirebaseException catch (e) {
EasyLoading.showError("ERROR");
print("BIG PROBLEM ${e}");
}
}
}
}
| 0 |
mirrored_repositories/triviait---open-source-trivia | mirrored_repositories/triviait---open-source-trivia/test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility in the flutter_test package. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:triviait/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0 |
mirrored_repositories/TODO_app | mirrored_repositories/TODO_app/lib/main.dart | import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'TODO App',
theme: ThemeData(
primarySwatch: Colors.indigo,
),
home: TodoList(),
);
}
}
class TodoList extends StatefulWidget {
@override
_TodoListState createState() => _TodoListState();
}
class _TodoListState extends State<TodoList> {
List<Todo> todos = [];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Sukalaper Note'),
),
body: ReorderableListView(
onReorder: (oldIndex, newIndex) {
setState(() {
if (newIndex > oldIndex) {
newIndex -= 1;
}
final Todo item = todos.removeAt(oldIndex);
todos.insert(newIndex, item);
});
},
children: todos.map((todo) {
return buildTodoCard(todo);
}).toList(),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
showAddDialog();
},
child: Icon(Icons.add),
),
);
}
Widget buildTodoCard(Todo todo) {
return Card(
key: Key('${todo.title}'),
color: todo.isCompleted ? Color(0xFF7FC7D9) : const Color(0xFF647D87),
child: ListTile(
title: Text(
todo.title,
style: TextStyle(
color: todo.isCompleted ? Colors.white : Colors.white,
decoration: todo.isCompleted ? TextDecoration.lineThrough : null,
),
),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Isi Tugas:',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
for (String activity in todo.activities)
Text(
'- $activity',
style: TextStyle(
color: Colors.white,
decoration:
todo.isCompleted ? TextDecoration.lineThrough : null,
),
),
if (todo.deadline != null)
Row(
children: [
Text(
'Tenggat Waktu: ',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight
.bold,
),
),
Text(
DateFormat('dd-MM-yyyy').format(todo.deadline!),
style: TextStyle(
color: Colors.white,
),
),
],
),
],
),
onTap: () {
setState(() {
todo.isCompleted = !todo.isCompleted;
});
},
onLongPress: () {
editTodoDialog(todo);
},
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
IconButton(
icon: Icon(Icons.edit),
color: Colors.white,
onPressed: () {
editTodoDialog(todo);
},
),
IconButton(
icon: Icon(Icons.delete),
color: Colors.white,
onPressed: () {
deleteTodoDialog(todo);
},
),
],
),
),
);
}
void showAddDialog() {
TextEditingController titleController = TextEditingController();
TextEditingController activityController = TextEditingController();
List<String> activities = [];
DateTime selectedDate =
DateTime.now();
showDialog(
context: context,
builder: (BuildContext context) {
return buildAddDialog(
titleController, activityController, activities, selectedDate);
},
);
}
AlertDialog buildAddDialog(
TextEditingController titleController,
TextEditingController activityController,
List<String> activities,
DateTime selectedDate,
) {
return AlertDialog(
title: Text('Tambah TODO'),
contentPadding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
content: SizedBox(
height: MediaQuery.of(context).size.height *
0.6,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextField(
controller: titleController,
decoration: InputDecoration(labelText: 'Judul Tugas'),
),
TextField(
controller: activityController,
decoration: InputDecoration(labelText: 'Isi Tugas'),
keyboardType: TextInputType.multiline,
maxLines: null,
onChanged: (value) {
setState(() {
activities = value
.split('\n')
.where((element) => element.isNotEmpty)
.toList();
});
},
),
ListTile(
title: Text('Tenggat Waktu'),
subtitle: Text(DateFormat('dd-MM-yyyy').format(selectedDate)),
onTap: () async {
DateTime? pickedDate = await showDatePicker(
context: context,
initialDate: selectedDate,
firstDate: DateTime.now(),
lastDate: DateTime(2101),
);
if (pickedDate != null && pickedDate != selectedDate) {
setState(() {
selectedDate = pickedDate;
});
}
},
),
for (String activity in activities) Text('- $activity'),
],
),
),
actions: [
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: Text('Batal'),
),
TextButton(
onPressed: () {
if (titleController.text.isNotEmpty && activities.isNotEmpty) {
setState(() {
todos.add(
Todo(
title: titleController.text,
activities: List.from(activities),
deadline: selectedDate,
),
);
});
Navigator.pop(context);
}
},
child: Text('Simpan'),
),
],
);
}
void editTodoDialog(Todo todo) {
TextEditingController titleController =
TextEditingController(text: todo.title);
TextEditingController activityController =
TextEditingController(text: todo.activities.join('\n'));
showDialog(
context: context,
builder: (BuildContext context) {
return buildEditTodoDialog(todo, titleController, activityController);
},
);
}
AlertDialog buildEditTodoDialog(
Todo todo,
TextEditingController titleController,
TextEditingController activityController,
) {
return AlertDialog(
content: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text('Edit TODO'),
),
TextField(
controller: titleController,
decoration: InputDecoration(labelText: 'Judul Tugas'),
),
TextField(
controller: activityController,
decoration:
InputDecoration(labelText: 'Isi Tugas (pisahkan dengan baris)'),
maxLines: null,
),
],
),
actions: [
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: Text('Batal'),
),
TextButton(
onPressed: () {
if (titleController.text.isNotEmpty) {
setState(() {
List<String> updatedActivities =
activityController.text.split('\n');
todo.title = titleController.text;
todo.activities = updatedActivities;
});
Navigator.pop(context);
}
},
child: Text('Simpan'),
),
],
);
}
void deleteTodoDialog(Todo todo) {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text('Hapus TODO'),
content: Text('Apakah Anda yakin ingin menghapus "${todo.title}"?'),
actions: [
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: Text('Batal'),
),
TextButton(
onPressed: () {
setState(() {
todos.remove(todo);
});
Navigator.pop(context);
},
child: Text('Hapus'),
),
],
);
},
);
}
}
class Todo {
String title;
List<String> activities;
bool isCompleted;
DateTime?
deadline;
Todo({
required this.title,
required this.activities,
this.isCompleted = false,
this.deadline,
});
}
| 0 |
mirrored_repositories/TODO_app | mirrored_repositories/TODO_app/test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility in the flutter_test package. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:todo_apps/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0 |
mirrored_repositories/librum | mirrored_repositories/librum/lib/main.dart | import 'package:flutter/material.dart';
import 'package:librum/pages/loadingpage.dart';
void main() {
runApp(const MaterialApp(
title: "Librum",
home: LoadingPage(),
));
}
| 0 |
mirrored_repositories/librum/lib | mirrored_repositories/librum/lib/pages/donationpage.dart | import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
//Builds the Donate Page
class DonationPage extends StatelessWidget {
DonationPage({super.key});
_copyMoneroAddress(context) {
Clipboard.setData(ClipboardData(
text:
'86cQoPfKTJ2bRfGH5Ts2kzaXCRcVRiX8CUHKc9xmeUmQ8YM8Uzk9S97T5gQaqYu58C9wuFK7opDH7cM9EJyR4V5LAq9RGv4'));
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text("Verse copied to clipboard."),
duration: Duration(seconds: 2),
));
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: Colors.purple.shade700,
iconTheme: const IconThemeData(color: Colors.white),
title: Text("Donate", style: const TextStyle(color: Colors.white)),
),
backgroundColor: Colors.grey[50],
body: Center(
child: SingleChildScrollView(
child: Column(
children: [
Padding(
padding: EdgeInsets.all(9.0),
child: Text(
"Donate XMR to Support this App",
style: TextStyle(fontSize: 21),
),
),
Padding(
padding: EdgeInsets.all(9.0),
child: GestureDetector(
onTap: () => _copyMoneroAddress(context),
child: Card(
child: Padding(
padding: EdgeInsets.all(3.0),
child: Image.asset('assets/images/XMR.png'),
),
),
),
),
Padding(
padding: EdgeInsets.all(9.0),
child: Text(
"Tap the QR Code to get the XMR Wallet Address.",
style: TextStyle(fontSize: 15),
),
),
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/librum/lib | mirrored_repositories/librum/lib/pages/loadingpage.dart | import 'package:flutter/material.dart';
import 'package:librum/data/verses.dart';
import 'package:librum/pages/homepage.dart';
class LoadingPage extends StatefulWidget {
const LoadingPage({super.key});
@override
State<LoadingPage> createState() => _LoadingPageState();
}
class _LoadingPageState extends State<LoadingPage> {
late Verses verses;
late int randomVerseIndex;
_startup() {
Future.delayed(const Duration(seconds: 1), () async {
verses = Verses();
randomVerseIndex = verses.getRandom();
_goToHomePage();
});
}
_goToHomePage() {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => HomePage(
verses: verses,
randomVerseIndex: randomVerseIndex,
)));
}
@override
void initState() {
super.initState();
_startup();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.purple.shade700,
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: EdgeInsets.all(9.0),
child: Image.asset('assets/icons/librum.png')),
const Padding(
padding: EdgeInsets.all(9.0),
child: Text(
'Librum',
style: TextStyle(color: Colors.white, fontSize: 27.0),
),
)
],
)));
}
}
| 0 |
mirrored_repositories/librum/lib | mirrored_repositories/librum/lib/pages/versespage.dart | import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:librum/data/verses.dart';
class VersesPage extends StatefulWidget {
VersesPage({super.key, required this.title, required this.verses});
final String title;
final Verses verses;
@override
State<VersesPage> createState() => _VersesPageState();
}
class _VersesPageState extends State<VersesPage> {
late String title;
late Verses verses;
_copyVerse(index) {
Clipboard.setData(ClipboardData(
text:
'${widget.verses.get(widget.title)[index].text} - ${widget.verses.get(widget.title)[index].verse}'));
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text("Verse copied to clipboard."),
duration: Duration(seconds: 2),
));
}
@override
void initState() {
super.initState();
verses = widget.verses;
title = widget.title;
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: Colors.purple.shade700,
title: Text(widget.title, style: const TextStyle(color: Colors.white)),
),
backgroundColor: Colors.grey[50],
body: ListView.builder(
shrinkWrap: true,
itemCount: widget.verses.get(widget.title).length,
itemBuilder: (contex, index) {
return GestureDetector(
onTap: () {
_copyVerse(index);
},
child: Padding(
padding: EdgeInsets.all(9.0),
child: Card(
child: Column(mainAxisSize: MainAxisSize.min, children: [
Padding(
padding: EdgeInsets.all(9.0),
child: ListTile(
title: Text(
widget.verses.get(widget.title)[index].text,
style: TextStyle(fontSize: 18.0),
),
subtitle: Align(
alignment: Alignment.centerRight,
child: Padding(
padding: EdgeInsets.all(9.0),
child: Text(widget.verses
.get(widget.title)[index]
.verse))),
subtitleTextStyle: TextStyle(
fontWeight: FontWeight.bold,
wordSpacing: 2.0,
fontSize: 15.0)),
)
]),
),
),
);
},
),
);
}
}
| 0 |
mirrored_repositories/librum/lib | mirrored_repositories/librum/lib/pages/homepage.dart | import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:librum/data/categories.dart';
import 'package:librum/data/verses.dart';
import 'package:librum/pages/donationpage.dart';
import 'package:librum/pages/versespage.dart';
class HomePage extends StatefulWidget {
HomePage({super.key, required this.verses, required this.randomVerseIndex});
final Verses verses;
final int randomVerseIndex;
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
CategoryEntries categoryEntries = CategoryEntries();
late Verses verses;
late int randomVerse;
_copyRandomVerse() {
Clipboard.setData(ClipboardData(
text:
'${widget.verses.versesList[widget.randomVerseIndex].text} - ${widget.verses.versesList[widget.randomVerseIndex].verse}'));
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text("Verse copied to clipboard."),
duration: Duration(seconds: 2),
));
}
_categoryTapped(index) {
if (categoryEntries.categoryList[index].name != "Donate") {
_goToVersesPage(index);
} else {
_goToDonationPage();
}
}
_goToVersesPage(index) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => VersesPage(
title: categoryEntries.categoryList[index].name,
verses: widget.verses)));
}
_goToDonationPage() {
Navigator.push(
context, MaterialPageRoute(builder: (context) => DonationPage()));
}
@override
void initState() {
super.initState();
verses = widget.verses;
randomVerse = widget.randomVerseIndex;
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.purple.shade700,
centerTitle: true,
title: Text(
'Librum',
style: TextStyle(color: Colors.white),
),
),
backgroundColor: Colors.grey[50],
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
GestureDetector(
onTap: () => _copyRandomVerse(),
child: Padding(
padding: EdgeInsets.fromLTRB(9.0, 18.0, 9.0, 9.0),
child: Card(
child: Padding(
padding: EdgeInsets.all(9.0),
child: ListTile(
title: Text(
widget.verses.versesList[widget.randomVerseIndex].text,
style: TextStyle(fontSize: 18.0),
),
subtitle: Align(
alignment: Alignment.centerRight,
child: Padding(
padding: EdgeInsets.all(9.0),
child: Text(widget
.verses.versesList[widget.randomVerseIndex].verse)),
),
subtitleTextStyle: TextStyle(
fontWeight: FontWeight.bold,
wordSpacing: 2.0,
fontSize: 15.0),
),
)),
),
),
Padding(
padding: EdgeInsets.all(9.0),
child: Text(
"Tap a verse to copy to your clipboard.",
style: TextStyle(fontSize: 15),
textAlign: TextAlign.center,
),
),
Padding(
padding: EdgeInsets.fromLTRB(9.0, 18.0, 9.0, 9.0),
child: Align(
alignment: Alignment.centerLeft,
child: Text(
'Categories',
style: TextStyle(fontSize: 24.0),
))),
ListView.builder(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: categoryEntries.categoryList.length,
itemBuilder: (context, index) {
return Card(
child: ListTile(
leading: Icon(
categoryEntries.categoryList[index].icon,
color: Colors.deepPurple,
),
title: Text(categoryEntries.categoryList[index].name),
onTap: () => _categoryTapped(index),
),
);
})
],
)),
);
}
}
| 0 |
mirrored_repositories/librum/lib | mirrored_repositories/librum/lib/data/verses.dart | import 'dart:math';
class Verse {
String category;
String verse;
String text;
Verse({ required this.category, required this.verse, required this.text });
}
class Verses {
//Gives a list of verses depending on the value it gets
//All possible values can be found in date/drawerentries
List<Verse> get (title) {
List<Verse> filteredList = [];
for (var verse in versesList) {
if (verse.category == title) {
filteredList.add(verse);
}
}
return filteredList;
}
//Sends a random verse to the Home Screen by sending an index based on the Verses current count on this file below
int getRandom () {
Random random = Random();
return random.nextInt(versesList.length);
}
//Librum's list of verses
List<Verse> versesList = [
Verse(category: 'Charity', verse: "Luke 14:12-14", text: "Then Jesus said to his host, “When you give a luncheon or dinner, do not invite your friends, your brothers or sisters, your relatives, or your rich neighbors; if you do, they may invite you back and so you will be repaid. But when you give a banquet, invite the poor, the crippled, the lame, the blind, and you will be blessed. Although they cannot repay you, you will be repaid at the resurrection of the righteous.”"),
Verse(category: "Charity", verse: "Matthew 6:2-4", text: "“So when you give to the needy, do not announce it with trumpets, as the hypocrites do in the synagogues and on the streets, to be honored by others. Truly I tell you, they have received their reward in full. But when you give to the needy, do not let your left hand know what your right hand is doing, so that your giving may be in secret. Then your Father, who sees what is done in secret, will reward you."),
Verse(category: "Charity", verse: "Philippians 2:3-4", text: "Do nothing out of selfish ambition or vain conceit. Rather, in humility value others above yourselves, not looking to your own interests but each of you to the interests of the others."),
Verse(category: "Charity", verse: "Matthew 5:42", text: "Give to the one who asks you, and do not turn away from the one who wants to borrow from you."),
Verse(category: "Charity", verse: "Psalm 82:3-4", text: "Give justice to the weak and the fatherless; maintain the right of the afflicted and the destitute. Rescue the weak and the needy; deliver them from the hand of the wicked."),
Verse(category: "Charity", verse: "Proverbs 19:17", text: "Whoever is kind to the poor lends to the Lord, and he will reward them for what they have done."),
Verse(category: "Charity", verse: "Romans 12:13", text: "Share with the Lord’s people who are in need. Practice hospitality."),
Verse(category: "Charity", verse: "Proverbs 22:9", text: "The generous will themselves be blessed, for they share their food with the poor."),
Verse(category: "Enemies", verse: "Romans 12:20-21", text: "On the contrary: “If your enemy is hungry, feed him; if he is thirsty, give him something to drink. In doing this, you will heap burning coals on his head.” Do not be overcome by evil, but overcome evil with good."),
Verse(category: "Enemies", verse: "Luke 6:27-28", text: " “But to you who are listening I say: Love your enemies, do good to those who hate you, bless those who curse you, pray for those who mistreat you."),
Verse(category: "Enemies", verse: "Matthew 5:39", text: "But I tell you, do not resist an evil person. If anyone slaps you on the right cheek, turn to them the other cheek also."),
Verse(category: "Enemies", verse: "Proverbs 20:22", text: "Do not say, “I’ll pay you back for this wrong!” Wait for the Lord, and he will avenge you."),
Verse(category: "Enemies", verse: "Proverbs 24:17-18", text: "Do not gloat when your enemy falls; when they stumble, do not let your heart rejoice, or the Lord will see and disapprove and turn his wrath away from them."),
Verse(category: "Enemies", verse: "Exodus 23:4-5", text: "“If you come across your enemy’s ox or donkey wandering off, be sure to return it. If you see the donkey of someone who hates you fallen down under its load, do not leave it there; be sure you help them with it."),
Verse(category: "Enemies", verse: "Proverbs 16:7", text: "When the Lord takes pleasure in anyone’s way, he causes their enemies to make peace with them."),
Verse(category: "Faith", verse: "Mark 9:23", text: "“‘If you can’?” said Jesus. “Everything is possible for one who believes.”"),
Verse(category: "Faith", verse: "Matthew 8:26", text: "He replied, “You of little faith, why are you so afraid?” Then he got up and rebuked the winds and the waves, and it was completely calm."),
Verse(category: "Faith", verse: "Matthew 21:21-22", text: "Jesus replied, “Truly I tell you, if you have faith and do not doubt, not only can you do what was done to the fig tree, but also you can say to this mountain, ‘Go, throw yourself into the sea,’ and it will be done. If you believe, you will receive whatever you ask for in prayer.”"),
Verse(category: "Faith", verse: "John 11:40", text: "Then Jesus said, “Did I not tell you that if you believe, you will see the glory of God?”"),
Verse(category: "Faith", verse: "Proverbs 3:5-6", text: "Trust in the Lord with all your heart and lean not on your own understanding; in all your ways submit to him, and he will make your paths straight."),
Verse(category: "Faith", verse: "Hebrews 11:6", text: "And without faith it is impossible to please God, because anyone who comes to him must believe that he exists and that he rewards those who earnestly seek him."),
Verse(category: "Family", verse: "1 Timothy 5:8", text: "Anyone who does not provide for their relatives, and especially for their own household, has denied the faith and is worse than an unbeliever."),
Verse(category: "Family", verse: "Ephesians 6:4", text: "Fathers, do not exasperate your children; instead, bring them up in the training and instruction of the Lord."),
Verse(category: "Family", verse: "Colossians 3:20", text: "Children, obey your parents in everything, for this pleases the Lord."),
Verse(category: "Family", verse: "1 Corinthians 7:14", text: "For the unbelieving husband has been sanctified through his wife, and the unbelieving wife has been sanctified through her believing husband. Otherwise your children would be unclean, but as it is, they are holy."),
Verse(category: "Family", verse: "Colossians 3:21", text: "Fathers,do not embitter your children, or they will become discouraged."),
Verse(category: "Family", verse: "Mark 10:13-16", text: "People were bringing little children to Jesus for him to place his hands on them, but the disciples rebuked them. When Jesus saw this, he was indignant. He said to them, “Let the little children come to me, and do not hinder them, for the kingdom of God belongs to such as these. Truly I tell you, anyone who will not receive the kingdom of God like a little child will never enter it.” And he took the children in his arms, placed his hands on them and blessed them."),
Verse(category: "Family", verse: "Matthew 19:4-6", text: "“Haven’t you read,” he replied, “that at the beginning the Creator ‘made them male and female,’ and said, ‘For this reason a man will leave his father and mother and be united to his wife, and the two will become one flesh’? So they are no longer two, but one flesh. Therefore what God has joined together, let no one separate.”"),
Verse(category: "Family", verse: "1 Corinthians 7:10-11", text: "To the married I give this command (not I, but the Lord): A wife must not separate from her husband. But if she does, she must remain unmarried or else be reconciled to her husband. And a husband must not divorce his wife."),
Verse(category: "Family", verse: "Colossians 3:18-19", text: "Wives, submit yourselves to your husbands, as is fitting in the Lord. Husbands, love your wives and do not be harsh with them."),
Verse(category: "Family", verse: "Deuteronomy 6:6-7", text: "These commandments that I give you today are to be on your hearts. Impress them on your children. Talk about them when you sit at home and when you walk along the road, when you lie down and when you get up."),
Verse(category: "Family", verse: "Titus 2:6-7", text: "Similarly, encourage the young men to be self-controlled. In everything set them an example by doing what is good. In your teaching show integrity, seriousness"),
Verse(category: "Family", verse: "Proverbs 19:18", text: "Discipline your children, for in that there is hope; do not be a willing party to their death."),
Verse(category: "Family", verse: "Psalm 103:13", text: "As a father has compassion on his children, so the Lord has compassion on those who fear him;"),
Verse(category: "Family", verse: "Proverbs 13:24", text: "Whoever spares the rod hates their children, but the one who loves their children is careful to discipline them."),
Verse(category: "Family", verse: "Proverbs 29:15", text: "A rod and a reprimand impart wisdom, but a child left undisciplined disgraces its mother."),
Verse(category: "Family", verse: "Proverbs 22:6", text: "Start children off on the way they should go, and even when they are old they will not turn from it."),
Verse(category: "Fear", verse: "Luke 10:19", text: "I have given you authority to trample on snakes and scorpions and to overcome all the power of the enemy; nothing will harm you."),
Verse(category: "Fear", verse: "Matthew 10:29-31", text: "Are not two sparrows sold for a penny? Yet not one of them will fall to the ground outside your Father’s care. And even the very hairs of your head are all numbered. So don’t be afraid; you are worth more than many sparrows."),
Verse(category: "Fear", verse: "1 Peter 5:6-7", text: "Humble yourselves, therefore, under God’s mighty hand, that he may lift you up in due time. Cast all your anxiety on him because he cares for you."),
Verse(category: "Fear", verse: "Philippians 4:19", text: "And my God will meet all your needs according to the riches of his glory in Christ Jesus."),
Verse(category: "Fear", verse: "Isaiah 43:2", text: "When you pass through the waters, I will be with you; and when you pass through the rivers, they will not sweep over you. When you walk through the fire, you will not be burned; the flames will not set you ablaze."),
Verse(category: "Fear", verse: "Deuteronomy 31:6", text: "Be strong and courageous. Do not be afraid or terrified because of them, for the Lord your God goes with you; he will never leave you nor forsake you.”"),
Verse(category: "Fear", verse: "Isaiah 41:10", text: "So do not fear, for I am with you; do not be dismayed, for I am your God. I will strengthen you and help you; I will uphold you with my righteous right hand."),
Verse(category: "Fear", verse: "Psalm 34:7", text: "The angel of the Lord encamps around those who fear him, and he delivers them."),
Verse(category: "Fear", verse: "Isaiah 40:31", text: "but those who hope in the Lord will renew their strength. They will soar on wings like eagles; they will run and not grow weary, they will walk and not be faint."),
Verse(category: "Fear", verse: "Psalm 10:17", text: "You, Lord, hear the desire of the afflicted; you encourage them, and you listen to their cry,"),
Verse(category: "Fear", verse: "Psalm 56:3-4", text: "When I am afraid, I put my trust in you. In God, whose word I praise— in God I trust and am not afraid. What can mere mortals do to me?"),
Verse(category: "Fear", verse: "Joshua 1:9", text: "Have I not commanded you? Be strong and courageous. Do not be afraid; do not be discouraged, for the Lord your God will be with you wherever you go.”"),
Verse(category: "Forgiveness", verse: "Colossians 3:13", text: "Bear with each other and forgive one another if any of you has a grievance against someone. Forgive as the Lord forgave you."),
Verse(category: "Forgiveness", verse: "Mark 11:25", text: "And when you stand praying, if you hold anything against anyone, forgive them, so that your Father in heaven may forgive you your sins.”"),
Verse(category: "Forgiveness", verse: "Ephesians 4:32", text: "Be kind and compassionate to one another, forgiving each other, just as in Christ God forgave you."),
Verse(category: "Forgiveness", verse: "Hebrews 8:12", text: "For I will forgive their wickedness and will remember their sins no more.”"),
Verse(category: "Forgiveness", verse: "Hebrews 10:17", text: "“Their sins and lawless acts I will remember no more.”"),
Verse(category: "Forgiveness", verse: "Psalm 130:3-4", text: "If you, Lord, kept a record of sins, Lord, who could stand? But with you there is forgiveness, so that we can, with reverence, serve you."),
Verse(category: "Forgiveness", verse: "Proverbs 17:9", text: "Whoever would foster love covers over an offense, but whoever repeats the matter separates close friends."),
Verse(category: "Guidance", verse: "James 1:5", text: "If any of you lacks wisdom, you should ask God, who gives generously to all without finding fault, and it will be given to you."),
Verse(category: "Guidance", verse: "John 14:26", text: "But the Advocate, the Holy Spirit, whom the Father will send in my name, will teach you all things and will remind you of everything I have said to you."),
Verse(category: "Guidance", verse: "Psalms 32:8", text: "I will instruct you and teach you in the way you should go; I will counsel you with my loving eye on you."),
Verse(category: "Guidance", verse: "Psalm 48:14", text: "For this God is our God for ever and ever; he will be our guide even to the end."),
Verse(category: "Guidance", verse: "Isaiah 30:21", text: "Whether you turn to the right or to the left, your ears will hear a voice behind you, saying, “This is the way; walk in it.”"),
Verse(category: "Guidance", verse: "Isaiah 58:11", text: "The Lord will guide you always; he will satisfy your needs in a sun-scorched land and will strengthen your frame. You will be like a well-watered garden, like a spring whose waters never fail."),
Verse(category: "Guidance", verse: "Proverbs 16:33", text: "The lot is cast into the lap, but its every decision is from the Lord."),
Verse(category: "Pride", verse: "Matthew 23:12", text: "For those who exalt themselves will be humbled, and those who humble themselves will be exalted."),
Verse(category: "Pride", verse: "James 4:6", text: "But he gives us more grace. That is why Scripture says: “God opposes the proud but shows favor to the humble.”"),
Verse(category: "Pride", verse: "Proverbs 11:2", text: "When pride comes, then comes disgrace, but with humility comes wisdom."),
Verse(category: "Pride", verse: "Proverbs 15:33", text: "Wisdom’s instruction is to fear the Lord, and humility comes before honor."),
Verse(category: "Sacrifice", verse: "1 John 3:16", text: "This is how we know what love is: Jesus Christ laid down his life for us. And we ought to lay down our lives for our brothers and sisters."),
Verse(category: "Sacrifice", verse: "Mark 10:45", text: "For even the Son of Man did not come to be served, but to serve, and to give his life as a ransom for many.”"),
Verse(category: "Sacrifice", verse: "Matthew 16:24", text: "Then Jesus said to his disciples, “Whoever wants to be my disciple must deny themselves and take up their cross and follow me."),
Verse(category: "Sacrifice", verse: "1 Peter 2:21", text: "To this you were called, because Christ suffered for you, leaving you an example, that you should follow in his steps."),
Verse(category: "Sacrifice", verse: "Romans 12:1-2", text: "Therefore, I urge you, brothers and sisters, in view of God’s mercy, to offer your bodies as a living sacrifice, holy and pleasing to God—this is your true and proper worship. Do not conform to the pattern of this world, but be transformed by the renewing of your mind. Then you will be able to test and approve what God’s will is—his good, pleasing and perfect will."),
Verse(category: "Wealth", verse: "Luke 16:11", text: "So if you have not been trustworthy in handling worldly wealth, who will trust you with true riches?"),
Verse(category: "Wealth", verse: "Matthew 6:19-21", text: "“Do not store up for yourselves treasures on earth, where moths and vermin destroy, and where thieves break in and steal. But store up for yourselves treasures in heaven, where moths and vermin do not destroy, and where thieves do not break in and steal. For where your treasure is, there your heart will be also."),
Verse(category: "Wealth", verse: "1 Timothy 6:17", text: "Command those who are rich in this present world not to be arrogant nor to put their hope in wealth, which is so uncertain, but to put their hope in God, who richly provides us with everything for our enjoyment."),
Verse(category: "Wealth", verse: "1 Timothy 6:10", text: "For the love of money is a root of all kinds of evil. Some people, eager for money, have wandered from the faith and pierced themselves with many griefs."),
Verse(category: "Wealth", verse: "Proverbs 13:11", text: "Dishonest money dwindles away, but whoever gathers money little by little makes it grow."),
Verse(category: "Wealth", verse: "Proverbs 15:27", text: "The greedy bring ruin to their households, but the one who hates bribes will live."),
Verse(category: "Wealth", verse: "Ecclesiastes 11:2", text: "Invest in seven ventures, yes, in eight; you do not know what disaster may come upon the land."),
Verse(category: "Wealth", verse: "Proverbs 22:26-27", text: "Do not be one who shakes hands in pledge or puts up security for debts; if you lack the means to pay, your very bed will be snatched from under you."),
Verse(category: "Wealth", verse: "Proverbs 21:20", text: "The wise store up choice food and olive oil, but fools gulp theirs down."),
Verse(category: "Wealth", verse: "Proverbs 30:24-25", text: "“Four things on earth are small, yet they are extremely wise: Ants are creatures of little strength, yet they store up their food in the summer;"),
Verse(category: "Wealth", verse: "Ecclesiastes 5:10", text: "Whoever loves money never has enough; whoever loves wealth is never satisfied with their income. This too is meaningless."),
Verse(category: "Wealth", verse: "Proverbs 3:9-10", text: "Honor the Lord with your wealth, with the firstfruits of all your crops; then your barns will be filled to overflowing, and your vats will brim over with new wine."),
Verse(category: "Wealth", verse: "Nehemiah 10:35", text: "“We also assume responsibility for bringing to the house of the Lord each year the firstfruits of our crops and of every fruit tree."),
Verse(category: "Work", verse: "Hebrews 6:10-11", text: "God is not unjust; he will not forget your work and the love you have shown him as you have helped his people and continue to help them. We want each of you to show this same diligence to the very end, so that what you hope for may be fully realized."),
Verse(category: "Work", verse: "Colossians 3:23-24", text: "Whatever you do, work at it with all your heart, as working for the Lord, not for human masters, since you know that you will receive an inheritance from the Lord as a reward. It is the Lord Christ you are serving."),
Verse(category: "Work", verse: "Ephesians 4:28", text: "Anyone who has been stealing must steal no longer, but must work, doing something useful with their own hands, that they may have something to share with those in need."),
Verse(category: "Work", verse: "Psalm 128:2", text: "You will eat the fruit of your labor; blessings and prosperity will be yours."),
Verse(category: "Work", verse: "Proverbs 12:11", text: "Those who work their land will have abundant food, but those who chase fantasies have no sense."),
Verse(category: "Work", verse: "Proverbs 21:25", text: "The craving of a sluggard will be the death of him, because his hands refuse to work."),
Verse(category: "Work", verse: "Proverbs 6:6-8", text: "Go to the ant, you sluggard; consider its ways and be wise! It has no commander, no overseer or ruler, yet it stores its provisions in summer and gathers its food at harvest."),
Verse(category: "Work", verse: "Proverbs 27:23-24", text: "Be sure you know the condition of your flocks, give careful attention to your herds; for riches do not endure forever, and a crown is not secure for all generations."),
Verse(category: "Work", verse: "Genesis 2:15", text: "The Lord God took the man and put him in the Garden of Eden to work it and take care of it.")
];
} | 0 |
mirrored_repositories/librum/lib | mirrored_repositories/librum/lib/data/categories.dart | import 'package:flutter/material.dart';
class CategoryEntry {
String name;
IconData icon;
CategoryEntry({ required this.name, required this.icon });
}
class CategoryEntries {
List<CategoryEntry> categoryList = [
CategoryEntry(name: 'Charity', icon: Icons.volunteer_activism),
CategoryEntry(name: 'Enemies', icon: Icons.local_fire_department),
CategoryEntry(name: 'Faith', icon: Icons.church),
CategoryEntry(name: 'Family', icon: Icons.family_restroom),
CategoryEntry(name: 'Fear', icon: Icons.sentiment_very_dissatisfied),
CategoryEntry(name: 'Forgiveness', icon: Icons.handshake),
CategoryEntry(name: 'Guidance', icon: Icons.visibility),
CategoryEntry(name: 'Pride', icon: Icons.emoji_events),
CategoryEntry(name: 'Sacrifice', icon: Icons.favorite),
CategoryEntry(name: 'Wealth', icon: Icons.savings),
CategoryEntry(name: 'Work', icon: Icons.work),
CategoryEntry(name: "Donate", icon: Icons.person)
];
}
| 0 |
mirrored_repositories/librum | mirrored_repositories/librum/test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility in the flutter_test package. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
// import 'package:flutter/material.dart';
// import 'package:flutter_test/flutter_test.dart';
// import 'package:librum/main.dart';
void main() {
// testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// // Build our app and trigger a frame.
// await tester.pumpWidget(const MyApp());
// // Verify that our counter starts at 0.
// expect(find.text('0'), findsOneWidget);
// expect(find.text('1'), findsNothing);
// // Tap the '+' icon and trigger a frame.
// await tester.tap(find.byIcon(Icons.add));
// await tester.pump();
// // Verify that our counter has incremented.
// expect(find.text('0'), findsNothing);
// expect(find.text('1'), findsOneWidget);
// });
}
| 0 |
mirrored_repositories/star-chef | mirrored_repositories/star-chef/lib/main.dart | import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:star_chef/res/app_colors.dart';
import 'package:star_chef/services/star_chef_service.dart';
import 'package:star_chef/view/dishes_page.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
useMaterial3: true,
primaryColor: AppColors.primary,
colorScheme: const ColorScheme.light(
primary: AppColors.primary,
surfaceTint: AppColors.white,
),
fontFamily: 'OpenSans',
textTheme: const TextTheme(
headlineLarge: TextStyle(
fontSize: 32.0,
color: AppColors.textTitle,
fontWeight: FontWeight.w800,
),
headlineMedium: TextStyle(
fontSize: 22.0,
color: AppColors.textTitle,
fontWeight: FontWeight.w600,
letterSpacing: 0,
),
headlineSmall: TextStyle(
fontSize: 17.0,
color: AppColors.textTitle,
fontWeight: FontWeight.w500,
letterSpacing: 0.12,
),
bodySmall: TextStyle(
fontSize: 8.0,
color: AppColors.textTitle,
fontWeight: FontWeight.w500,
letterSpacing: 0.16,
),
bodyMedium: TextStyle(
fontSize: 12.0,
color: AppColors.textTitle,
fontWeight: FontWeight.w500,
),
bodyLarge: TextStyle(
fontSize: 17.0,
color: AppColors.textTitle,
fontWeight: FontWeight.w600,
),
),
appBarTheme: const AppBarTheme(
backgroundColor: Colors.transparent,
elevation: 0,
systemOverlayStyle: SystemUiOverlayStyle.dark,
),
),
debugShowCheckedModeBanner: false,
home: MultiRepositoryProvider(
providers: [
RepositoryProvider(
create: (context) => StarChefService(),
),
],
child: const DishesPage(),
),
);
}
}
| 0 |
mirrored_repositories/star-chef/lib | mirrored_repositories/star-chef/lib/view/ingredients_page.dart | import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:star_chef/blocs/ingredients_bloc/ingredients_bloc.dart';
import 'package:star_chef/models/ingredients_model.dart';
import 'package:star_chef/res/app_colors.dart';
import 'package:star_chef/view/widgets/ratings.dart';
class IngredientsPage extends StatefulWidget {
const IngredientsPage({Key? key}) : super(key: key);
@override
State<IngredientsPage> createState() => _IngredientsPageState();
}
class _IngredientsPageState extends State<IngredientsPage> {
final IngredientsBloc _ingredientsBloc = IngredientsBloc();
late IngredientsModel _ingredientsModel;
@override
void initState() {
_ingredientsBloc.add(LoadIngredientsBloc(context: context));
super.initState();
}
@override
void dispose() {
_ingredientsBloc.close();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.background,
appBar: AppBar(
leading: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Image.asset(
'assets/images/2x/Group [email protected]',
height: 16.0,
),
splashRadius: 20.0,
),
),
body: BlocProvider(
create: (context) => _ingredientsBloc,
child: BlocConsumer<IngredientsBloc, IngredientsState>(
builder: (context, state) {
if(state is IngredientsLoadingState) {
return const Center(
child: CircularProgressIndicator(),
);
} else if (state is IngredientsLoadedState) {
return SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
width: MediaQuery.of(context).size.width,
child: Stack(
children: [
Positioned(
right: -30,
bottom: 0,
child: Container(
width: 171,
height: 171,
decoration: BoxDecoration(
color: AppColors.lightOrange,
borderRadius: BorderRadius.circular(100.0),
),
),
),
const Positioned(
bottom: 21,
right: 0,
left: 0,
child: Divider(
color: AppColors.dividerLarge,
thickness: 3.0,
height: 0,
),
),
Positioned(
right: -80,
bottom: 0,
child: Stack(
children: [
Image.asset(
'assets/images/2x/Mask Group [email protected]',
height: 130,
),
Positioned(
right: 0,
child: Image.asset(
'assets/images/2x/pngtree-herbal-ingredients-transparent-image-png-image_3206949-removebg-preview@2x.png',
height: 130,
),
),
],
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
width: 300.0,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
_ingredientsModel.name!,
style: Theme.of(context).textTheme.headlineLarge!.copyWith(
fontSize: 25.0,
),
),
const SizedBox(width: 8.0,),
const Ratings(starCount: '4.2',),
],
),
const SizedBox(height: 4,),
Text(
'Mughlai Masala is a style of cookery developed in the Indian Subcontinent by the imperial kitchens of the Mughal Empire.',
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
fontSize: 10.0,
color: AppColors.textBody3,
),
),
const SizedBox(height: 25.0,),
Row(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset(
'assets/images/2x/Group [email protected]',
height: 13,
),
const SizedBox(width: 8.0,),
Text(
_ingredientsModel.timeToPrepare!,
style: Theme.of(context).textTheme.bodySmall!.copyWith(
fontSize: 14.0,
fontWeight: FontWeight.w600,
),
),
],
),
const SizedBox(height: 31.0,),
],
),
),
),
const SizedBox(height: 21.0,),
],
),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
RichText(
text: TextSpan(
text: 'Ingredients\n',
style: Theme.of(context).textTheme.headlineMedium!.copyWith(
fontSize: 20.0,
fontWeight: FontWeight.w700,
height: 2.0,
),
children: [
TextSpan(
text: 'For 2 people',
style: Theme.of(context).textTheme.bodySmall!.copyWith(
color: AppColors.textDisabled,
fontSize: 10.0,
)
),
],
),
),
const SizedBox(height: 16.0,),
const Divider(
color: AppColors.dividerSmall,
thickness: 0.7,
height: 0,
),
buildExpandableList(context, _ingredientsModel.ingredients!.vegetables!, 'Vegetables'),
buildExpandableList(context, _ingredientsModel.ingredients!.spices!, 'Spices'),
Text(
'Appliances',
style: Theme.of(context).textTheme.headlineMedium!.copyWith(
fontSize: 20.0,
fontWeight: FontWeight.w700,
height: 2.0,
),
),
const SizedBox(height: 16.0,),
SizedBox(
height: 95.0,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: _ingredientsModel.ingredients!.appliances!.length,
itemBuilder: (context, index) {
return Container(
width: 72.0,
margin: const EdgeInsets.only(right: 21.0),
decoration: BoxDecoration(
color: AppColors.greyBackground,
borderRadius: BorderRadius.circular(7.0),
),
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
_ingredientsModel.ingredients!.appliances![index].name! == 'Stove'
? 'assets/images/1x/stove.png' : _ingredientsModel.ingredients!.appliances![index].name! == 'Microwave'
? 'assets/images/1x/microwave-alt.png' : 'assets/images/2x/Mask Group [email protected]',
height: 50.0,
),
const SizedBox(height: 2.0,),
Text(
_ingredientsModel.ingredients!.appliances![index].name!,
style: Theme.of(context).textTheme.bodySmall!.copyWith(
fontSize: 10.0,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
);
},
),
),
],
),
),
],
),
);
} else {
return Placeholder(
child: Text(
'Oops Something went wrong!',
style: Theme.of(context).textTheme.headlineMedium,
),
);
}
},
listener: (context, state) {
if (state is IngredientsLoadedState) {
setState(() {
_ingredientsModel = state.ingredientsModel;
});
}
},
),
),
);
}
Theme buildExpandableList(BuildContext context, List<dynamic> list, String title) {
return Theme(
data: Theme.of(context).copyWith(dividerColor: Colors.transparent),
child: ExpansionTile(
initiallyExpanded: true,
childrenPadding: EdgeInsets.zero,
tilePadding: EdgeInsets.zero,
trailing: const SizedBox(),
title: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
'$title (0${list.length})',
style: Theme.of(context).textTheme.headlineMedium!.copyWith(
fontSize: 17.0,
fontWeight: FontWeight.w700,
),
),
const SizedBox(width: 10.0,),
Image.asset(
'assets/images/2x/Path [email protected]',
height: 7.0,
),
],
),
children: List.generate(list.length, (index) {
return Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Row(
children: [
Text(
list[index].name!,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
fontSize: 14.0,
),
),
const Spacer(),
Text(
list[index].quantity!,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
fontSize: 14.0,
),
),
],
),
);
}),
),
);
}
}
| 0 |
mirrored_repositories/star-chef/lib | mirrored_repositories/star-chef/lib/view/dishes_page.dart | import 'package:flutter/material.dart';
import 'package:star_chef/blocs/all_details_bloc/all_details_bloc.dart';
import 'package:star_chef/models/all_details_model.dart';
import 'package:star_chef/res/app_colors.dart';
import 'package:star_chef/view/ingredients_page.dart';
import 'package:star_chef/view/widgets/date_time.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:intl/intl.dart';
import 'package:star_chef/view/widgets/popular_list_shimmer.dart';
import 'package:star_chef/view/widgets/ratings.dart';
import 'package:star_chef/view/widgets/recommended_list_shimmer.dart';
class DishesPage extends StatefulWidget {
const DishesPage({Key? key}) : super(key: key);
@override
State<DishesPage> createState() => _DishesPageState();
}
class _DishesPageState extends State<DishesPage> {
late AllDetailsModel _allDetailsModel = AllDetailsModel(popularDishes: [], dishes: []);
int _selectedRegion = 0;
bool _loading = false;
final AllDetailsBloc _allDetailsBloc = AllDetailsBloc();
DateTime _selectedDate = DateTime.now();
String _date = DateFormat('dd MMM yyyy').format(DateTime.now());
String _startTime = DateFormat('hh:mm a').format(DateTime.now());
String _endTime = DateFormat('hh:mm a').format(DateTime.now().add(const Duration(hours: 1)));
@override
void initState() {
_allDetailsBloc.add(LoadAllDetailsBloc(context: context));
super.initState();
}
@override
void dispose() {
_allDetailsBloc.close();
super.dispose();
}
Future<void> _selectDate(BuildContext context) async {
final DateTime? picked = await showDatePicker(
context: context,
initialDate: _selectedDate,
firstDate: DateTime(1998, 1),
lastDate: DateTime(DateTime.now().year + 5));
if (picked != null) {
setState(() {
_selectedDate = picked;
_date = DateFormat('dd MMM yyyy').format(picked);
});
}
}
Future<void> _selectTime(BuildContext context) async {
final TimeOfDay? picked = await showTimePicker(
context: context,
initialTime: TimeOfDay.fromDateTime(_selectedDate),);
if (picked != null) {
setState(() {
_selectedDate = DateTime(_selectedDate.year, _selectedDate.month, _selectedDate.day, picked.hour, picked.minute);
_startTime = DateFormat('hh:mm a').format(_selectedDate);
_endTime = DateFormat('hh:mm a').format(_selectedDate.add(const Duration(hours: 1)));
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.background,
appBar: AppBar(
leading: IconButton(
onPressed: () {},
icon: Image.asset(
'assets/images/2x/Group [email protected]',
height: 16.0,
),
splashRadius: 20.0,
),
title: Text(
'Select Dishes',
style: Theme.of(context).textTheme.headlineMedium,
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
floatingActionButton: Padding(
padding: const EdgeInsets.symmetric(horizontal: 61),
child: TextButton(
onPressed: () {},
style: ButtonStyle(
padding: MaterialStateProperty.all<EdgeInsetsGeometry?>(const EdgeInsets.symmetric(vertical: 11.5, horizontal: 16.0)),
shape: MaterialStateProperty.all<OutlinedBorder?>(RoundedRectangleBorder(
borderRadius: BorderRadius.circular(7.0),
)),
backgroundColor: MaterialStateProperty.all<Color?>(AppColors.textBody1),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset(
'assets/images/2x/Group [email protected]',
height: 18.0,
),
const SizedBox(width: 9.0),
Text(
'3 food items selected',
style: Theme.of(context).textTheme.bodyLarge!.copyWith(
color: AppColors.white,
),
),
const Spacer(),
const Icon(
Icons.arrow_forward,
color: AppColors.white,
),
],
),
),
),
body: BlocConsumer<AllDetailsBloc, AllDetailsState>(
bloc: _allDetailsBloc,
builder: (context, state) {
return SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
buildDateTime(context),
buildRegionList(),
const SizedBox(
height: 21.0,
),
Padding(
padding: const EdgeInsets.only(left: 23.0),
child: Text(
'Popular Dishes',
style: Theme.of(context).textTheme.bodyLarge!.copyWith(
fontSize: 17.0,
letterSpacing: 0.14,
fontWeight: FontWeight.w700,
),
),
),
const SizedBox(
height: 12.0,
),
buildPopularDishesList(),
const Divider(
color: AppColors.dividerLarge,
thickness: 3.0,
height: 55.0,
),
buildRecommended(context),
const SizedBox(height: 80.0,),
],
),
);
},
listener: (context, state) {
if(state is AllDetailsLoadingState) {
setState(() {
_loading = true;
});
} else if (state is AllDetailsLoadedState) {
setState(() {
_allDetailsModel = state.allDetailsModel;
_loading = false;
});
} else if (state is AllDetailsErrorState) {
setState(() {
_loading = false;
});
} else {
setState(() {
_loading = false;
});
}
},
),
);
}
Widget buildRecommended(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 23.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Theme(
data: Theme.of(context).copyWith(dividerColor: Colors.transparent),
child: ExpansionTile(
initiallyExpanded: true,
childrenPadding: EdgeInsets.zero,
tilePadding: EdgeInsets.zero,
trailing: SizedBox(
height: 28.0,
child: ElevatedButton(
onPressed: () {},
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color?>(AppColors.textBody1),
shadowColor: MaterialStateProperty.all<Color?>(AppColors.buttonShadow),
shape: MaterialStateProperty.all<OutlinedBorder?>(RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6.0),
),),
elevation: MaterialStateProperty.all<double?>(5.0),
padding: MaterialStateProperty.all<EdgeInsetsGeometry?>(const EdgeInsets.symmetric(horizontal: 16.0)),
),
child: Text(
'Menu',
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: AppColors.white,
),
),
),
),
title: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
'Recommended',
style: Theme.of(context).textTheme.headlineMedium!.copyWith(
fontSize: 20.0,
fontWeight: FontWeight.w700,
),
),
const SizedBox(width: 10.0,),
Image.asset(
'assets/images/2x/Path [email protected]',
height: 7.0,
),
],
),
children: [
_loading ? const RecommendedListShimmer() : Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: List.generate(_allDetailsModel.dishes!.length, (index) {
return Container(
padding: const EdgeInsets.only(top: 22.0, bottom: 20.0),
decoration: const BoxDecoration(
border: Border(
bottom: BorderSide(
color: AppColors.dividerSmall,
width: 0.7,
),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
_allDetailsModel.dishes![index].name!,
style: Theme.of(context).textTheme.headlineSmall!.copyWith(
fontWeight: FontWeight.w600,
),
),
const SizedBox(width: 6.0,),
Image.asset(
'assets/images/2x/Group [email protected]',
height: 10.0,
),
const SizedBox(width: 10.0,),
Ratings(starCount: _allDetailsModel.dishes![index].rating!.toString()),
],
),
const SizedBox(height: 8.0,),
Row(
children: [
Container(
decoration: const BoxDecoration(
border: Border(
right: BorderSide(
width: 0.5,
color: AppColors.dividerSmall,
),
),
),
child: Row(
children: List.generate(_allDetailsModel.dishes![index].equipments!.length, (ind) {
return Container(
margin: const EdgeInsets.only(right: 8.5),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset(
_allDetailsModel.dishes![index].equipments![ind] == 'Microwave'
? 'assets/images/1x/microwave.png' : 'assets/images/2x/Group [email protected]',
height: 15.0,
),
const SizedBox(height: 2.0,),
Text(
_allDetailsModel.dishes![index].equipments![ind],
style: Theme.of(context).textTheme.bodySmall!.copyWith(
fontSize: 6.0,
height: 0,
),
),
],
),
);
}),
),
),
const SizedBox(width: 15.5,),
GestureDetector(
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => const IngredientsPage()));
},
child: Container(
color: Colors.transparent,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Ingredients',
style: Theme.of(context).textTheme.bodySmall!.copyWith(
fontWeight: FontWeight.w700,
),
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
'View list ',
style: Theme.of(context).textTheme.bodySmall!.copyWith(
color: AppColors.textOrange,
fontWeight: FontWeight.w600,
),
),
const Icon(
Icons.arrow_forward_ios,
color: AppColors.textOrange,
size: 7.0,
),
],
),
],
),
),
),
],
),
const SizedBox(height: 8.0,),
SizedBox(
width: 230.0,
child: Text(
_allDetailsModel.dishes![index].description!,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: AppColors.textBody2,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
],
),
Stack(
alignment: Alignment.center,
children: [
Container(
margin: const EdgeInsets.only(bottom: 10.0),
child: ClipRRect(
borderRadius: BorderRadius.circular(10.0),
child: Container(
height: 68.0,
width: 94.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15.0),
),
child: Image.network(
_allDetailsModel.dishes![index].image!,
fit: BoxFit.cover,
),
),
),
),
Positioned(
bottom: 0,
child: SizedBox(
height: 25.0,
child: Stack(
children: [
ElevatedButton(
onPressed: () {},
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color?>(AppColors.background),
shadowColor: MaterialStateProperty.all<Color?>(AppColors.buttonShadow),
shape: MaterialStateProperty.all<OutlinedBorder?>(RoundedRectangleBorder(
borderRadius: BorderRadius.circular(3.0),
side: const BorderSide(
color: AppColors.btnBorderOrange,
width: 0.5,
),
),),
elevation: MaterialStateProperty.all<double?>(5),
padding: MaterialStateProperty.all<EdgeInsetsGeometry?>(const EdgeInsets.symmetric(horizontal: 19.0, vertical: 0)),
),
child: Text(
'Add',
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: AppColors.textOrange,
fontWeight: FontWeight.w600,
fontSize: 15.0,
),
),
),
const Positioned(
top: 2,
right: 4,
child: Icon(
Icons.add,
color: AppColors.textOrange,
size: 10.0,
),
),
],
),
),
),
],
),
],
),
);
}),
)
],
),
),
],
),
);
}
Widget buildRegionList() {
return SizedBox(
height: 28.0,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: 10,
padding: const EdgeInsets.only(left: 23.0),
itemBuilder: (context, index) {
return Container(
margin: const EdgeInsets.only(right: 18.0),
child: TextButton(
onPressed: () {
setState(() {
_selectedRegion = index;
});
},
style: ButtonStyle(
padding: MaterialStateProperty.all<EdgeInsetsGeometry?>(const EdgeInsets.symmetric(vertical: 0, horizontal: 23.0)),
shape: MaterialStateProperty.all<OutlinedBorder?>(RoundedRectangleBorder(
borderRadius: BorderRadius.circular(17.0),
side: BorderSide(
color: _selectedRegion == index ? AppColors.primary : AppColors.border,
width: 0.5,
),
)),
backgroundColor: MaterialStateProperty.all<Color?>(_selectedRegion == index ? AppColors.lightOrange : Colors.transparent),
),
child: Text(
'Indian',
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
fontSize: 14.0,
color: _selectedRegion == index ? AppColors.textOrange : AppColors.textDisabled,
letterSpacing: 0.1,
fontWeight: _selectedRegion == index ? FontWeight.w700 : FontWeight.w500,
),
),
),
);
},
),
);
}
Stack buildDateTime(BuildContext context) {
return Stack(
children: [
Container(
height: 42.0,
margin: const EdgeInsets.only(bottom: 70.0),
width: MediaQuery.of(context).size.width,
color: AppColors.textBody1,
),
Positioned(
top: 20.0,
left: 23.0,
right: 23.0,
child: Card(
color: AppColors.background,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(9.0),
),
shadowColor: AppColors.shadow,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 18.0, vertical: 22.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
CustomDateTime(
onTap: () {
_selectDate(context);
},
title: _date,
icon: 'assets/images/2x/[email protected]',
),
Container(
height: 26.0,
width: 1.0,
color: AppColors.dividerSmall,
),
CustomDateTime(
onTap: () {
_selectTime(context);
},
title: '$_startTime-$_endTime',
icon: 'assets/images/2x/[email protected]',
),
],
),
),
),
),
],
);
}
Widget buildPopularDishesList() {
return _loading ? const PopularListShimmer() : SizedBox(
height: 68.0,
child: ListView.builder(
scrollDirection: Axis.horizontal,
physics: const BouncingScrollPhysics(),
itemCount: _allDetailsModel.popularDishes!.length,
padding: const EdgeInsets.only(left: 23.0),
itemBuilder: (context, index) {
return Container(
margin: const EdgeInsets.only(right: 8.0),
child: Container(
width: 68.0,
padding: const EdgeInsets.all(2.0),
decoration: BoxDecoration(
border: Border.all(
color: AppColors.primary,
),
borderRadius: BorderRadius.circular(100.0),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(100.0),
child: Stack(
children: [
Positioned.fill(
child: Image.network(
_allDetailsModel.popularDishes![index].image!,
fit: BoxFit.cover,
),
),
Positioned.fill(
child: Container(
color: AppColors.textBody1.withOpacity(0.4),
alignment: Alignment.center,
padding: const EdgeInsets.symmetric(horizontal: 5.0),
child: Text(
_allDetailsModel.popularDishes![index].name!,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
fontSize: 12.0,
fontWeight: FontWeight.w500,
color: AppColors.white,
),
textAlign: TextAlign.center,
),
),
),
],
),
),
),
);
},
),
);
}
}
| 0 |
mirrored_repositories/star-chef/lib/view | mirrored_repositories/star-chef/lib/view/widgets/popular_list_shimmer.dart | import 'package:flutter/material.dart';
import 'package:shimmer/shimmer.dart';
class PopularListShimmer extends StatelessWidget {
const PopularListShimmer({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: List.generate(4, (index) {
return Shimmer.fromColors(
baseColor: Colors.grey[400]!,
highlightColor: Colors.grey[300]!,
child: Container(
height: 68.0,
width: 68.0,
margin: EdgeInsets.only(right: 10.0, left: index == 0 ? 23.0 : 0),
decoration: BoxDecoration(
color: Colors.grey,
borderRadius: BorderRadius.circular(100),
),
),
);
}),
);
}
}
| 0 |
mirrored_repositories/star-chef/lib/view | mirrored_repositories/star-chef/lib/view/widgets/recommended_list_shimmer.dart | import 'package:flutter/material.dart';
import 'package:shimmer/shimmer.dart';
class RecommendedListShimmer extends StatelessWidget {
const RecommendedListShimmer({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: List.generate(2, (index) {
return Shimmer.fromColors(
baseColor: Colors.grey[400]!,
highlightColor: Colors.grey[300]!,
child: Container(
margin: const EdgeInsets.symmetric(vertical: 20.0),
child: Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: 180,
height: 10.0,
color: Colors.grey,
),
const SizedBox(height: 10.0,),
Container(
width: 130,
height: 10.0,
color: Colors.grey,
),
],
),
const Spacer(),
Container(
width: 94.0,
height: 68.0,
decoration: BoxDecoration(
color: Colors.grey,
borderRadius: BorderRadius.circular(15.0),
),
),
],
),
),
);
}),
);
}
}
| 0 |
mirrored_repositories/star-chef/lib/view | mirrored_repositories/star-chef/lib/view/widgets/ratings.dart | import 'package:flutter/material.dart';
import 'package:star_chef/res/app_colors.dart';
class Ratings extends StatelessWidget {
final String starCount;
const Ratings({Key? key, required this.starCount}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
color: AppColors.vegGreen,
borderRadius: BorderRadius.circular(2.0),
),
padding: const EdgeInsets.symmetric(horizontal: 4.0, vertical: 1.0),
child: Row(
children: [
Text(
starCount,
style: Theme.of(context).textTheme.bodySmall!.copyWith(
color: AppColors.white,
),
),
const SizedBox(width: 3,),
Image.asset(
'assets/images/2x/[email protected]',
height: 6.0,
)
],
),
);
}
}
| 0 |
mirrored_repositories/star-chef/lib/view | mirrored_repositories/star-chef/lib/view/widgets/date_time.dart | import 'package:flutter/material.dart';
class CustomDateTime extends StatefulWidget {
final void Function() onTap;
final String title;
final String icon;
const CustomDateTime({Key? key, required this.onTap, required this.title, required this.icon}) : super(key: key);
@override
State<CustomDateTime> createState() => _CustomDateTimeState();
}
class _CustomDateTimeState extends State<CustomDateTime> {
@override
Widget build(BuildContext context) {
return InkWell(
onTap: widget.onTap,
child: Container(
color: Colors.transparent,
child: Row(
children: [
Image.asset(
widget.icon,
height: 18.0,
),
const SizedBox(
width: 8.1,
),
Text(
widget.title,
style: Theme.of(context).textTheme.headlineSmall!.copyWith(
fontWeight: FontWeight.w700,
fontSize: 15.0
),
),
],
),
),
);
}
}
| 0 |
mirrored_repositories/star-chef/lib | mirrored_repositories/star-chef/lib/res/app_colors.dart | import 'package:flutter/material.dart';
class AppColors {
static const Color white = Colors.white;
static const Color background = Colors.white;
static const Color greyBackground = Color(0xffF5F5F5);
static const Color textTitle = Color(0xff242424);
static const Color textBody1 = Color(0xff1C1C1C);
static const Color textBody2 = Color(0xff707070);
static const Color textBody3 = Color(0xffA3A3A3);
static const Color textDisabled = Color(0xff8A8A8A);
static const Color primary = Color(0xffFF941A);
static const Color lightOrange = Color(0xffFFF9F2);
static const Color textOrange = Color(0xffFF8800);
static const Color btnBorderOrange = Color(0xffFF9A26);
static const Color dividerLarge = Color(0xffF2F2F2);
static const Color dividerSmall = Color(0xD6D6D6CE);
static const Color border = Color(0xffBDBDBD);
static const Color vegGreen = Color(0xff51C452);
static const Color shadow = Color(0xD6D6D69E);
static const Color buttonShadow = Color(0x00000029);
} | 0 |
mirrored_repositories/star-chef/lib/blocs | mirrored_repositories/star-chef/lib/blocs/ingredients_bloc/ingredients_event.dart | part of 'ingredients_bloc.dart';
abstract class IngredientsEvent extends Equatable {
const IngredientsEvent();
}
class LoadIngredientsBloc extends IngredientsEvent {
final BuildContext context;
const LoadIngredientsBloc({required this.context});
@override
List<Object?> get props => [context];
} | 0 |
mirrored_repositories/star-chef/lib/blocs | mirrored_repositories/star-chef/lib/blocs/ingredients_bloc/ingredients_bloc.dart | import 'dart:convert';
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
import 'package:star_chef/models/ingredients_model.dart';
import 'package:star_chef/services/star_chef_service.dart';
part 'ingredients_event.dart';
part 'ingredients_state.dart';
class IngredientsBloc extends Bloc<IngredientsEvent, IngredientsState> {
IngredientsBloc() : super(IngredientsInitial()) {
on<IngredientsEvent>((event, emit) async {
if(event is LoadIngredientsBloc) {
emit(IngredientsLoadingState());
try {
var ingredientsResponse = await StarChefService().getIngredients();
var data = json.decode(ingredientsResponse.body);
if(ingredientsResponse.statusCode == 200) {
IngredientsModel ingredients = IngredientsModel.fromJson(data);
emit(IngredientsLoadedState(ingredientsModel: ingredients));
} else {
ScaffoldMessenger.of(event.context).showSnackBar(
const SnackBar(
content: Text(
'Oops Something went wrong!',
),
behavior: SnackBarBehavior.floating,
duration: Duration(seconds: 3),
),
);
emit(IngredientsErrorState(error: ingredientsResponse.statusCode.toString()));
}
} catch (_) {
ScaffoldMessenger.of(event.context).showSnackBar(
const SnackBar(
content: Text(
'Oops Something went wrong!',
),
behavior: SnackBarBehavior.floating,
duration: Duration(seconds: 3),
),
);
emit(IngredientsErrorState(error: 'Oops Something went wrong!'));
}
}
});
}
}
| 0 |
mirrored_repositories/star-chef/lib/blocs | mirrored_repositories/star-chef/lib/blocs/ingredients_bloc/ingredients_state.dart | // ignore_for_file: must_be_immutable
part of 'ingredients_bloc.dart';
abstract class IngredientsState extends Equatable {
const IngredientsState();
}
class IngredientsInitial extends IngredientsState {
@override
List<Object> get props => [];
}
class IngredientsLoadingState extends IngredientsState {
@override
List<Object> get props => [];
}
class IngredientsLoadedState extends IngredientsState {
IngredientsModel ingredientsModel;
IngredientsLoadedState({required this.ingredientsModel});
@override
List<Object?> get props => [IngredientsState];
}
class IngredientsErrorState extends IngredientsState {
String error;
IngredientsErrorState({required this.error});
@override
List<Object?> get props => [error];
}
| 0 |
mirrored_repositories/star-chef/lib/blocs | mirrored_repositories/star-chef/lib/blocs/all_details_bloc/all_details_event.dart | part of 'all_details_bloc.dart';
abstract class AllDetailsEvent extends Equatable {
const AllDetailsEvent();
}
class LoadAllDetailsBloc extends AllDetailsEvent {
final BuildContext context;
const LoadAllDetailsBloc({required this.context});
@override
List<Object?> get props => [context];
} | 0 |
mirrored_repositories/star-chef/lib/blocs | mirrored_repositories/star-chef/lib/blocs/all_details_bloc/all_details_state.dart | // ignore_for_file: must_be_immutable
part of 'all_details_bloc.dart';
abstract class AllDetailsState extends Equatable {
const AllDetailsState();
}
class AllDetailsInitial extends AllDetailsState {
@override
List<Object> get props => [];
}
class AllDetailsLoadingState extends AllDetailsState {
@override
List<Object> get props => [];
}
class AllDetailsLoadedState extends AllDetailsState {
AllDetailsModel allDetailsModel;
AllDetailsLoadedState({required this.allDetailsModel});
@override
List<Object?> get props => [AllDetailsModel];
}
class AllDetailsErrorState extends AllDetailsState {
String error;
AllDetailsErrorState({required this.error});
@override
List<Object?> get props => [error];
} | 0 |
mirrored_repositories/star-chef/lib/blocs | mirrored_repositories/star-chef/lib/blocs/all_details_bloc/all_details_bloc.dart | import 'dart:async';
import 'dart:convert';
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
import 'package:star_chef/models/all_details_model.dart';
import 'package:star_chef/services/star_chef_service.dart';
part 'all_details_event.dart';
part 'all_details_state.dart';
class AllDetailsBloc extends Bloc<AllDetailsEvent, AllDetailsState> {
AllDetailsBloc() : super(AllDetailsInitial()) {
on<AllDetailsEvent>((event, emit) async {
if(event is LoadAllDetailsBloc) {
emit(AllDetailsLoadingState());
try {
var allDetailsResponse = await StarChefService().getAllDetails();
var data = json.decode(allDetailsResponse.body);
if(allDetailsResponse.statusCode == 200) {
AllDetailsModel allDetails = AllDetailsModel.fromJson(data);
emit(AllDetailsLoadedState(allDetailsModel: allDetails));
} else {
ScaffoldMessenger.of(event.context).showSnackBar(
const SnackBar(
content: Text(
'Oops Something went wrong!',
),
behavior: SnackBarBehavior.floating,
duration: Duration(seconds: 3),
),
);
emit(AllDetailsErrorState(error: allDetailsResponse.statusCode.toString()));
}
} catch (_) {
ScaffoldMessenger.of(event.context).showSnackBar(
const SnackBar(
content: Text(
'Oops Something went wrong!',
),
behavior: SnackBarBehavior.floating,
duration: Duration(seconds: 3),
),
);
emit(AllDetailsErrorState(error: 'Oops Something went wrong!'));
}
}
});
}
}
| 0 |
mirrored_repositories/star-chef/lib | mirrored_repositories/star-chef/lib/models/ingredients_model.dart |
class IngredientsModel {
String? name;
int? id;
String? timeToPrepare;
Ingredients? ingredients;
IngredientsModel({this.name, this.id, this.timeToPrepare, this.ingredients});
IngredientsModel.fromJson(Map<String, dynamic> json) {
name = json['name'];
id = json['id'];
timeToPrepare = json['timeToPrepare'];
ingredients = json['ingredients'] != null
? Ingredients.fromJson(json['ingredients'])
: null;
}
}
class Ingredients {
List<Vegetables>? vegetables;
List<Spices>? spices;
List<Appliances>? appliances;
Ingredients({this.vegetables, this.spices, this.appliances});
Ingredients.fromJson(Map<String, dynamic> json) {
if (json['vegetables'] != null) {
vegetables = <Vegetables>[];
json['vegetables'].forEach((v) {
vegetables!.add(Vegetables.fromJson(v));
});
}
if (json['spices'] != null) {
spices = <Spices>[];
json['spices'].forEach((v) {
spices!.add(Spices.fromJson(v));
});
}
if (json['appliances'] != null) {
appliances = <Appliances>[];
json['appliances'].forEach((v) {
appliances!.add(Appliances.fromJson(v));
});
}
}
}
class Vegetables {
String? name;
String? quantity;
Vegetables({this.name, this.quantity});
Vegetables.fromJson(Map<String, dynamic> json) {
name = json['name'];
quantity = json['quantity'];
}
}
class Appliances {
String? name;
String? image;
Appliances({this.name, this.image});
Appliances.fromJson(Map<String, dynamic> json) {
name = json['name'];
image = json['image'];
}
}
class Spices {
String? name;
String? quantity;
Spices({this.name, this.quantity});
Spices.fromJson(Map<String, dynamic> json) {
name = json['name'];
quantity = json['quantity'];
}
}
| 0 |
mirrored_repositories/star-chef/lib | mirrored_repositories/star-chef/lib/models/all_details_model.dart |
class AllDetailsModel {
List<Dishes>? dishes;
List<PopularDishes>? popularDishes;
AllDetailsModel({this.dishes, this.popularDishes});
AllDetailsModel.fromJson(Map<String, dynamic> json) {
if (json['dishes'] != null) {
dishes = <Dishes>[];
json['dishes'].forEach((v) {
dishes!.add(Dishes.fromJson(v));
});
}
if (json['popularDishes'] != null) {
popularDishes = <PopularDishes>[];
json['popularDishes'].forEach((v) {
popularDishes!.add(PopularDishes.fromJson(v));
});
}
}
}
class Dishes {
String? name;
double? rating;
String? description;
List<String>? equipments;
String? image;
int? id;
Dishes(
{this.name,
this.rating,
this.description,
this.equipments,
this.image,
this.id});
Dishes.fromJson(Map<String, dynamic> json) {
name = json['name'];
rating = json['rating'];
description = json['description'];
equipments = json['equipments'].cast<String>();
image = json['image'];
id = json['id'];
}
}
class PopularDishes {
String? name;
String? image;
int? id;
PopularDishes({this.name, this.image, this.id});
PopularDishes.fromJson(Map<String, dynamic> json) {
name = json['name'];
image = json['image'];
id = json['id'];
}
}
| 0 |
mirrored_repositories/star-chef/lib | mirrored_repositories/star-chef/lib/services/star_chef_service.dart | import 'package:http/http.dart';
class StarChefService {
String baseUrl = 'https://8b648f3c-b624-4ceb-9e7b-8028b7df0ad0.mock.pstmn.io/dishes/v1/';
Future<Response> getAllDetails() async {
final response = await get(Uri.parse(baseUrl),);
return response;
}
Future<Response> getIngredients() async {
final response = await get(Uri.parse('${baseUrl}1'),);
return response;
}
} | 0 |
mirrored_repositories/star-chef | mirrored_repositories/star-chef/test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility in the flutter_test package. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:star_chef/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0 |
mirrored_repositories/BooklyApp | mirrored_repositories/BooklyApp/lib/bloc_observer.dart | import 'package:flutter/foundation.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class MyBlocObserver extends BlocObserver {
@override
void onCreate(BlocBase bloc) {
super.onCreate(bloc);
if (kDebugMode) {
print('onCreate -- ${bloc.runtimeType}');
}
}
@override
void onChange(BlocBase bloc, Change change) {
super.onChange(bloc, change);
if (kDebugMode) {
print('onChange -- ${bloc.runtimeType}, $change');
}
}
@override
void onError(BlocBase bloc, Object error, StackTrace stackTrace) {
if (kDebugMode) {
print('onError -- ${bloc.runtimeType}, $error');
}
super.onError(bloc, error, stackTrace);
}
@override
void onClose(BlocBase bloc) {
super.onClose(bloc);
if (kDebugMode) {
print('onClose -- ${bloc.runtimeType}');
}
}
}
| 0 |
mirrored_repositories/BooklyApp | mirrored_repositories/BooklyApp/lib/constants.dart | import 'package:flutter/material.dart';
const kPrimaryColor = Color(0xff100B20);
const kTransitionDuration = Duration(milliseconds: 250);
const kFeaturedBox = 'featured_box';
const kNewestBox = 'newest_box';
const kSimilarBox = 'similar_box';
const kGtSectraFine = 'GT Sectra Fine';
const kLogo = 'assets/images/Logo.png';
const kSplashView = '/';
const kHomeView = '/HomeView';
const kSearchView = '/SearchView';
const kBookDetailsView = '/bookDetailsView';
| 0 |
mirrored_repositories/BooklyApp | mirrored_repositories/BooklyApp/lib/main.dart | import 'dart:io';
import 'package:flutter/material.dart';
import 'package:bookly/constants.dart';
import 'package:flutter/cupertino.dart';
import 'package:bookly/bloc_observer.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:bookly/core/utils/app_router.dart';
import 'package:bookly/core/utils/service_locator.dart';
import 'core/functions/set_system_ui_overlay_style.dart';
import 'package:bookly/core/functions/setup_hive_db.dart';
import 'features/home/domain/use_cases/fetch_newest_books_use_case.dart';
import 'features/home/domain/use_cases/fetch_featured_books_use_case.dart';
import 'package:bookly/features/home/presentation/cubits/newest_books_cubit/newest_books_cubit.dart';
import 'package:bookly/features/home/presentation/cubits/featured_books_cubit/featured_books_cubit.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
setSystemUIOverlayStyle();
await setupHiveDB();
setupServiceLocator();
Bloc.observer = MyBlocObserver();
runApp(const Bookly());
}
class Bookly extends StatelessWidget {
const Bookly({super.key});
@override
Widget build(BuildContext context) {
return MultiBlocProvider(
providers: [
BlocProvider(
create: (context) =>
FeaturedBooksCubit(getIt.get<FetchFeaturedBooksUseCase>())
..fetchFeaturedBooks()),
BlocProvider(
create: (context) =>
NewestBooksCubit(getIt.get<FetchNewestBooksUseCase>())
..fetchNewestBooks()),
],
child: Platform.isAndroid
? MaterialApp.router(
routerConfig: AppRouter.router,
debugShowCheckedModeBanner: false,
theme: ThemeData.dark().copyWith(
useMaterial3: true,
scaffoldBackgroundColor: kPrimaryColor,
textTheme:
GoogleFonts.montserratTextTheme(ThemeData.dark().textTheme),
),
)
: CupertinoApp.router(
routerConfig: AppRouter.router,
debugShowCheckedModeBanner: false,
theme: CupertinoThemeData(
primaryColor: kPrimaryColor,
scaffoldBackgroundColor: kPrimaryColor,
textTheme: CupertinoTextThemeData(
textStyle: GoogleFonts.montserratTextTheme(
ThemeData.dark().textTheme)
.bodyLarge,
),
),
),
);
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/data | mirrored_repositories/BooklyApp/lib/features/home/data/repos/home_repo_impl.dart | import 'package:dartz/dartz.dart';
import 'package:bookly/core/errors/failure.dart';
import 'package:bookly/core/errors/server_failure.dart';
import 'package:bookly/features/home/domain/repos/home_repo.dart';
import 'package:bookly/core/entities/book_entity.dart';
import 'package:bookly/features/home/data/data_sources/home_local_data_source/home_local_data_source.dart';
import 'package:bookly/features/home/data/data_sources/home_remote_data_source/home_remote_data_source.dart';
import 'package:dio/dio.dart';
class HomeRepoImpl implements HomeRepo {
final HomeRemoteDataSource homeRemoteDataSource;
final HomeLocalDataSource homeLocalDataSource;
HomeRepoImpl({
required this.homeRemoteDataSource,
required this.homeLocalDataSource,
});
@override
Future<Either<Failure, List<BookEntity>>> fetchFeaturedBooks({int page = 0}) async {
try {
List<BookEntity> booksList;
booksList = homeLocalDataSource.fetchFeaturedBooks(page: page);
if (booksList.isNotEmpty) {
return right(booksList);
}
booksList = await homeRemoteDataSource.fetchFeaturedBooks(page: page);
return right(booksList);
} on Exception catch (e) {
if (e is DioException) {
return left(ServerFailure.fromDioError(e));
}
return left(ServerFailure(errMessage: e.toString()));
}
}
@override
Future<Either<Failure, List<BookEntity>>> fetchNewestBooks() async {
try {
List<BookEntity> booksList;
booksList = homeLocalDataSource.fetchNewestBooks();
if (booksList.isNotEmpty) {
return right(booksList);
}
booksList = await homeRemoteDataSource.fetchNewestBooks();
return right(booksList);
} on Exception catch (e) {
if (e is DioException) {
return left(ServerFailure.fromDioError(e));
}
return left(ServerFailure(errMessage: e.toString()));
}
}
@override
Future<Either<Failure, List<BookEntity>>> fetchSimilarBooks() async {
try {
List<BookEntity> booksList;
booksList = homeLocalDataSource.fetchNewestBooks();
if (booksList.isNotEmpty) {
return right(booksList);
}
booksList = await homeRemoteDataSource.fetchSimilarBooks();
return right(booksList);
} on Exception catch (e) {
if (e is DioException) {
return left(ServerFailure.fromDioError(e));
}
return left(ServerFailure(errMessage: e.toString()));
}
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/data/data_sources | mirrored_repositories/BooklyApp/lib/features/home/data/data_sources/home_local_data_source/home_local_data_source_impl.dart | import 'home_local_data_source.dart';
import 'package:bookly/constants.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:bookly/core/entities/book_entity.dart';
class HomeLocalDataSourceImpl implements HomeLocalDataSource {
@override
List<BookEntity> fetchFeaturedBooks({int page = 0}) {
int startIndex = page * 10;
int endIndex = (page + 1) * 10;
var box = Hive.box<BookEntity>(kFeaturedBox);
int length = box.values.length;
if (startIndex >= length || endIndex > length) {
return [];
}
return box.values.toList().sublist(startIndex, endIndex);
}
@override
List<BookEntity> fetchNewestBooks() {
var box = Hive.box<BookEntity>(kNewestBox);
return box.values.toList();
}
@override
List<BookEntity> fetchSimilarBooks() {
var box = Hive.box<BookEntity>(kSimilarBox);
return box.values.toList();
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/data/data_sources | mirrored_repositories/BooklyApp/lib/features/home/data/data_sources/home_local_data_source/home_local_data_source.dart | import 'package:bookly/core/entities/book_entity.dart';
abstract class HomeLocalDataSource {
List<BookEntity> fetchFeaturedBooks({int page = 0});
List<BookEntity> fetchNewestBooks();
List<BookEntity> fetchSimilarBooks();
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/data/data_sources | mirrored_repositories/BooklyApp/lib/features/home/data/data_sources/home_remote_data_source/home_remote_data_source_impl.dart | import 'package:bookly/constants.dart';
import 'home_remote_data_source.dart';
import 'package:bookly/core/utils/api_service.dart';
import 'package:bookly/core/functions/get_books_list.dart';
import 'package:bookly/core/functions/cache_books_list.dart';
import 'package:bookly/core/entities/book_entity.dart';
class HomeRemoteDataSourceImpl implements HomeRemoteDataSource {
final ApiService _apiService;
HomeRemoteDataSourceImpl(this._apiService);
@override
Future<List<BookEntity>> fetchFeaturedBooks({int page = 0}) async {
var data = await _apiService.get(
endpoint:
'volumes?Filtering=free-ebooks&q=subject:Programming&startIndex=${page * 10}');
List<BookEntity> books = getBooksList(data);
cacheBooksList(books, kFeaturedBox);
return books;
}
@override
Future<List<BookEntity>> fetchNewestBooks() async {
var data = await _apiService.get(
endpoint:
'volumes?Filtering=free-ebooks&Sorting=newest&q=subject:Programming');
List<BookEntity> books = getBooksList(data);
cacheBooksList(books, kNewestBox);
return books;
}
@override
Future<List<BookEntity>> fetchSimilarBooks() async {
var data = await _apiService.get(
endpoint:
'volumes?Filtering=free-ebooks&Sorting=relevance&q=subject:Programming');
List<BookEntity> books = getBooksList(data);
cacheBooksList(books, kSimilarBox);
return books;
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/data/data_sources | mirrored_repositories/BooklyApp/lib/features/home/data/data_sources/home_remote_data_source/home_remote_data_source.dart | import 'package:bookly/core/entities/book_entity.dart';
abstract class HomeRemoteDataSource {
Future<List<BookEntity>> fetchFeaturedBooks({int page = 0});
Future<List<BookEntity>> fetchNewestBooks();
Future<List<BookEntity>> fetchSimilarBooks();
} | 0 |
mirrored_repositories/BooklyApp/lib/features/home/presentation/views | mirrored_repositories/BooklyApp/lib/features/home/presentation/views/book_details_view/book_details_view.dart | import 'package:flutter/material.dart';
import 'package:bookly/core/entities/book_entity.dart';
import 'package:bookly/features/home/presentation/views/book_details_view/widgets/book_details_view_body.dart';
class BookDetailsView extends StatelessWidget {
const BookDetailsView({Key? key, required this.book}) : super(key: key);
final BookEntity book;
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: WillPopScope(
onWillPop: () async {
Navigator.pop(context);
return true;
},
child: BookDetailsViewBody(
book: book,
),
),
),
);
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/presentation/views/book_details_view | mirrored_repositories/BooklyApp/lib/features/home/presentation/views/book_details_view/widgets/book_details_section.dart | import 'package:bookly/core/utils/styles.dart';
import 'package:bookly/core/entities/book_entity.dart';
import 'package:bookly/features/home/presentation/views/home_view/widgets/book_rating.dart';
import 'package:bookly/features/home/presentation/views/home_view/widgets/custom_book_image.dart';
import 'package:flutter/material.dart';
import 'books_action.dart';
class BookDetailsSection extends StatelessWidget {
const BookDetailsSection({Key? key, required this.book}) : super(key: key);
final BookEntity book;
@override
Widget build(BuildContext context) {
double bookImagePadding = MediaQuery.of(context).size.width * 0.2;
return Column(
children: [
Padding(
padding: EdgeInsets.symmetric(
horizontal: bookImagePadding,
),
child: Center(
child: CustomBookImage(
book: book,
),
),
),
const SizedBox(height: 30),
Text(
book.title,
style: Styles.textStyle30,
textAlign: TextAlign.center,
),
const SizedBox(height: 6),
Opacity(
opacity: 0.7,
child: Text(
book.authorName!,
style: Styles.textStyle18.copyWith(
fontWeight: FontWeight.w500, fontStyle: FontStyle.italic),
),
),
const SizedBox(height: 18),
BookRating(
mainAxisAlignment: MainAxisAlignment.center,
rating: book.rating!,
ratesCount: book.ratingsCount ?? 0,
),
const SizedBox(
height: 30,
),
BooksAction(
book: book,
),
],
);
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/presentation/views/book_details_view | mirrored_repositories/BooklyApp/lib/features/home/presentation/views/book_details_view/widgets/book_details_view_app_bar.dart | import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
class BookDetailsViewAppBar extends StatelessWidget {
const BookDetailsViewAppBar({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
onPressed: () {
GoRouter.of(context).pop(context);
},
icon: const Icon(
Icons.close_outlined,
size: 25,
)),
IconButton(
onPressed: () {},
icon: const Icon(
Icons.shopping_cart_outlined,
size: 25,
)),
],
);
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/presentation/views/book_details_view | mirrored_repositories/BooklyApp/lib/features/home/presentation/views/book_details_view/widgets/similar_books_section.dart | import 'package:bookly/core/utils/styles.dart';
import 'package:bookly/features/home/presentation/views/book_details_view/widgets/similar_books_list_view.dart';
import 'package:flutter/material.dart';
class SimilarBooksSection extends StatelessWidget {
const SimilarBooksSection({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('You can also like',
style: Styles.textStyle14
.copyWith(fontWeight: FontWeight.w600, color: Colors.white)),
const SizedBox(
height: 20,
),
const SimilarBooksListView(),
],
);
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/presentation/views/book_details_view | mirrored_repositories/BooklyApp/lib/features/home/presentation/views/book_details_view/widgets/books_action.dart | import 'package:flutter/material.dart';
import 'package:bookly/core/utils/url_launcher.dart';
import 'package:bookly/core/entities/book_entity.dart';
import 'package:bookly/core/widgets/custom_button.dart';
class BooksAction extends StatelessWidget {
const BooksAction({Key? key, required this.book}) : super(key: key);
final BookEntity book;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Row(
children: [
const Expanded(
child: CustomButton(
text: 'Free',
backGroundColor: Colors.white,
textColor: Colors.black,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(12),
bottomLeft: Radius.circular(12),
),
),
),
Expanded(
child: CustomButton(
text: book.previewLink == null ? 'Not Available' : 'Free Preview',
onPressed: () async {
if (book.previewLink != null) {
await launchMyUrl(context, book.previewLink);
}
},
fontSize: 16,
backGroundColor: const Color(0xffEF8262),
textColor: Colors.white,
borderRadius: const BorderRadius.only(
topRight: Radius.circular(12),
bottomRight: Radius.circular(12),
),
),
),
],
),
);
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/presentation/views/book_details_view | mirrored_repositories/BooklyApp/lib/features/home/presentation/views/book_details_view/widgets/book_details_view_body.dart | import 'book_details_section.dart';
import 'package:flutter/material.dart';
import 'book_details_view_app_bar.dart';
import 'package:bookly/core/entities/book_entity.dart';
import 'package:bookly/features/home/presentation/views/book_details_view/widgets/similar_books_section.dart';
class BookDetailsViewBody extends StatelessWidget {
const BookDetailsViewBody({Key? key, required this.book}) : super(key: key);
final BookEntity book;
@override
Widget build(BuildContext context) {
return CustomScrollView(
physics: const BouncingScrollPhysics(),
slivers: [
SliverFillRemaining(
hasScrollBody: false,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 30),
child: Column(
children: [
const SizedBox(height: 20),
const BookDetailsViewAppBar(),
BookDetailsSection(book: book),
const Expanded(child: SizedBox(height: 50)),
const SimilarBooksSection(),
const SizedBox(height: 20),
],
),
),
),
],
);
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/presentation/views/book_details_view | mirrored_repositories/BooklyApp/lib/features/home/presentation/views/book_details_view/widgets/similar_books_list_view.dart | import 'package:bookly/constants.dart';
import 'package:bookly/core/widgets/custom_error.dart';
import 'package:bookly/core/widgets/custom_loading_indicator.dart';
import 'package:bookly/features/home/presentation/cubits/similar_books_cubit/similar_book_cubit.dart';
import 'package:bookly/features/home/presentation/views/home_view/widgets/custom_book_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
class SimilarBooksListView extends StatelessWidget {
const SimilarBooksListView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
double height = MediaQuery.of(context).size.height * 0.2;
return BlocBuilder<SimilarBooksCubit, SimilarBooksState>(
builder: (context, state) {
if (state is SimilarBooksSuccess) {
return SizedBox(
height: height,
child: ListView.builder(
physics: const BouncingScrollPhysics(),
itemCount: state.books.length,
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 5.0),
child: CustomBookImage(
book: state.books[index],
onTap: () {
GoRouter.of(context)
.push(kBookDetailsView, extra: state.books[index]);
},
),
);
},
),
);
} else if (state is SimilarBooksFailure) {
return CustomError(errMessage: state.errMessage);
} else {
return const CustomLoadingIndicator();
}
});
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/presentation/views | mirrored_repositories/BooklyApp/lib/features/home/presentation/views/home_view/home_view.dart | import 'package:bookly/features/home/presentation/views/home_view/widgets/home_view_body.dart';
import 'package:flutter/material.dart';
class HomeView extends StatelessWidget {
const HomeView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const SafeArea(
child: Scaffold(
body: HomeViewBody(),
),
);
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/presentation/views/home_view | mirrored_repositories/BooklyApp/lib/features/home/presentation/views/home_view/widgets/home_view_body.dart | import 'home_view_app_bar.dart';
import 'package:flutter/material.dart';
import 'package:bookly/core/utils/styles.dart';
import 'package:bookly/features/home/presentation/views/home_view/widgets/newest_books_list_view_bloc_builder.dart';
import 'package:bookly/features/home/presentation/views/home_view/widgets/featured_books_list_view_bloc_consumer.dart';
class HomeViewBody extends StatelessWidget {
const HomeViewBody({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const CustomScrollView(
slivers: [
SliverToBoxAdapter (
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 30),
child: HomeViewAppBar(),
),
FeaturedBooksListViewBLocConsumer(),
SizedBox(height: 30),
Padding(
padding: EdgeInsets.symmetric(horizontal: 20),
child: Text('Newest Books', style: Styles.textStyle18),
),
SizedBox(height: 10),
],
),
),
SliverToBoxAdapter(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
child: NewestBooksListViewBlocBuilder(),
),
),
],
);
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/presentation/views/home_view | mirrored_repositories/BooklyApp/lib/features/home/presentation/views/home_view/widgets/book_list_view_item.dart | import 'book_rating.dart';
import 'package:bookly/constants.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:bookly/core/utils/styles.dart';
import 'package:bookly/core/entities/book_entity.dart';
import 'package:bookly/features/home/presentation/views/home_view/widgets/custom_book_image.dart';
class BookListViewItem extends StatelessWidget {
const BookListViewItem({Key? key, required this.book}) : super(key: key);
final BookEntity book;
@override
Widget build(BuildContext context) {
double bookDetailsWidth = MediaQuery.of(context).size.width * 0.5;
return SizedBox(
height: 125,
child: Row(
children: [
CustomBookImage(
book: book,
onTap: () {
GoRouter.of(context).push(kBookDetailsView, extra: book);
}
),
const SizedBox(width: 15.0),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
width: bookDetailsWidth,
child: Text(
book.title,
style: Styles.textStyle20
.copyWith(fontFamily: kGtSectraFine),
maxLines: 2,
overflow: TextOverflow.ellipsis,
)),
const SizedBox(height: 3.0),
Text(book.authorName ?? 'Unknown',
style: Styles.textStyle14
.copyWith(fontWeight: FontWeight.w500)),
const SizedBox(height: 3.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('Free',
style: Styles.textStyle20
.copyWith(fontWeight: FontWeight.bold)),
BookRating(
rating: book.rating ?? 'Not Rated',
ratesCount: book.ratingsCount ?? 0,
),
],
),
],
),
),
],
),
);
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/presentation/views/home_view | mirrored_repositories/BooklyApp/lib/features/home/presentation/views/home_view/widgets/featured_books_list_view_loading_indicator.dart | import 'package:flutter/material.dart';
import 'custom_book_image_loading_indicator.dart';
import 'package:bookly/core/widgets/custom_fading_widget.dart';
class FeaturedBooksListViewLoadingIndicator extends StatelessWidget {
const FeaturedBooksListViewLoadingIndicator({super.key});
@override
Widget build(BuildContext context) {
final listViewHeight = MediaQuery.of(context).size.height * 0.3;
return CustomFadingWidget(
child: SizedBox(
height: listViewHeight,
child: ListView.builder(
scrollDirection: Axis.horizontal,
physics: const BouncingScrollPhysics(),
itemCount: 15,
itemBuilder: (context, index) {
return const Padding(
padding: EdgeInsets.symmetric(horizontal: 8.0),
child: CustomBookImageLoadingIndicator(),
);
},
),
),
);
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/presentation/views/home_view | mirrored_repositories/BooklyApp/lib/features/home/presentation/views/home_view/widgets/newest_books_list_view.dart | import 'book_list_view_item.dart';
import 'package:flutter/material.dart';
import 'package:bookly/core/entities/book_entity.dart';
class NewestBooksListView extends StatelessWidget {
const NewestBooksListView({Key? key, required this.books}) : super(key: key);
final List<BookEntity> books;
@override
Widget build(BuildContext context) {
return ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
padding: EdgeInsets.zero,
itemCount: books.length,
itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: BookListViewItem(book: books[index]),
);
},
);
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/presentation/views/home_view | mirrored_repositories/BooklyApp/lib/features/home/presentation/views/home_view/widgets/custom_book_image_loading_indicator.dart | import 'package:flutter/material.dart';
class CustomBookImageLoadingIndicator extends StatelessWidget {
const CustomBookImageLoadingIndicator({super.key});
@override
Widget build(BuildContext context) {
return ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(20)),
child: AspectRatio(
aspectRatio: 2.6 / 4,
child: Container(
color: Colors.grey[200],
),
),
);
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/presentation/views/home_view | mirrored_repositories/BooklyApp/lib/features/home/presentation/views/home_view/widgets/book_rating.dart | import 'package:bookly/core/utils/styles.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
class BookRating extends StatelessWidget {
const BookRating(
{Key? key,
this.mainAxisAlignment = MainAxisAlignment.start,
required this.rating,
required this.ratesCount})
: super(key: key);
final MainAxisAlignment mainAxisAlignment;
final dynamic rating;
final num ratesCount;
@override
Widget build(BuildContext context) {
return Row(mainAxisAlignment: mainAxisAlignment, children: [
const Icon(FontAwesomeIcons.solidStar,
color: Color(0xffFFDD4F), size: 15),
const SizedBox(width: 7.0),
Text('$rating', style: Styles.textStyle16),
const SizedBox(width: 7.0),
Text('($ratesCount)', style: Styles.textStyle14),
]);
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/presentation/views/home_view | mirrored_repositories/BooklyApp/lib/features/home/presentation/views/home_view/widgets/featured_books_list_view_bloc_consumer.dart | import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:bookly/core/entities/book_entity.dart';
import 'package:bookly/core/widgets/custom_error.dart';
import 'featured_books_list_view_loading_indicator.dart';
import 'package:bookly/core/functions/show_custom_snack_bar.dart';
import 'package:bookly/features/home/presentation/views/home_view/widgets/featured_books_list_view.dart';
import 'package:bookly/features/home/presentation/cubits/featured_books_cubit/featured_books_cubit.dart';
class FeaturedBooksListViewBLocConsumer extends StatelessWidget {
const FeaturedBooksListViewBLocConsumer({super.key});
@override
Widget build(BuildContext context) {
List<BookEntity> books = [];
return BlocConsumer<FeaturedBooksCubit, FeaturedBooksState>(
listener: (context, state) {
if (state is FetchFeaturedBooksSuccess) {
books.addAll(state.books);
} else if (state is FetchFeaturedBooksPaginationFailure) {
showCustomSnackBar(context, state.errMessage);
}
},
builder: (context, state) {
if (state is FetchFeaturedBooksSuccess ||
state is FetchFeaturedBooksPaginationLoading ||
state is FetchFeaturedBooksPaginationFailure) {
return FeaturedBooksListView(books: books);
} else if (state is FetchFeaturedBooksFailure) {
return Center(child: CustomError(errMessage: state.errMessage));
} else {
return const FeaturedBooksListViewLoadingIndicator();
}
},
);
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/presentation/views/home_view | mirrored_repositories/BooklyApp/lib/features/home/presentation/views/home_view/widgets/home_view_app_bar.dart | import 'package:bookly/constants.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
class HomeViewAppBar extends StatelessWidget {
const HomeViewAppBar({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(bottom: 20),
child: Row(
children: [
Image.asset(kLogo, height: 20),
const Spacer(),
IconButton(
onPressed: () {
GoRouter.of(context).push(kSearchView);
},
icon: const Icon(
FontAwesomeIcons.magnifyingGlass,
size: 25,
),
)
],
),
);
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/presentation/views/home_view | mirrored_repositories/BooklyApp/lib/features/home/presentation/views/home_view/widgets/custom_book_image.dart | import 'package:flutter/material.dart';
import 'package:bookly/core/entities/book_entity.dart';
import 'package:fancy_shimmer_image/fancy_shimmer_image.dart';
class CustomBookImage extends StatelessWidget {
const CustomBookImage({Key? key, required this.book, this.onTap}) : super(key: key);
final BookEntity book;
final void Function()? onTap;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap ?? (){},
child: ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(20)),
child: AspectRatio(
aspectRatio: 2.6 / 4,
child: FancyShimmerImage(
errorWidget: const Icon(Icons.error, size: 30),
imageUrl: book.imageUrl ?? '',
shimmerBaseColor: Colors.grey[500]!,
shimmerDuration: const Duration(seconds: 1),
shimmerHighlightColor: Colors.grey[100]!,
),
),
),
);
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/presentation/views/home_view | mirrored_repositories/BooklyApp/lib/features/home/presentation/views/home_view/widgets/featured_books_list_view.dart | import 'custom_book_image.dart';
import 'package:bookly/constants.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:bookly/core/entities/book_entity.dart';
import 'package:bookly/features/home/presentation/cubits/featured_books_cubit/featured_books_cubit.dart';
class FeaturedBooksListView extends StatefulWidget {
const FeaturedBooksListView({
Key? key,
required this.books,
}) : super(key: key);
final List<BookEntity> books;
@override
FeaturedBooksListViewState createState() => FeaturedBooksListViewState();
}
class FeaturedBooksListViewState extends State<FeaturedBooksListView> {
int nextPage = 1;
bool isLoading = false;
late final ScrollController _scrollController;
@override
void initState() {
super.initState();
_scrollController = ScrollController()..addListener(_checkScrollThreshold);
}
@override
void dispose() {
_scrollController.removeListener(_checkScrollThreshold);
_scrollController.dispose();
super.dispose();
}
void _checkScrollThreshold() {
final double currentPosition = _scrollController.position.pixels;
final double maxScroll = _scrollController.position.maxScrollExtent;
final double scrollThreshold = maxScroll * 0.7;
if (currentPosition >= scrollThreshold) {
if (!isLoading) {
isLoading = true;
if (nextPage == 10) {
return;
}
BlocProvider.of<FeaturedBooksCubit>(context).fetchFeaturedBooks(page: nextPage++);
isLoading = false;
}
}
}
@override
Widget build(BuildContext context) {
final listViewHeight = MediaQuery.of(context).size.height * 0.3;
return SizedBox(
height: listViewHeight,
child: ListView.builder(
controller: _scrollController,
scrollDirection: Axis.horizontal,
physics: const BouncingScrollPhysics(),
itemCount: widget.books.length,
itemBuilder: (context, index) {
final book = widget.books[index];
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: CustomBookImage(
book: book,
onTap: () {
GoRouter.of(context).push(kBookDetailsView, extra: widget.books[index]);
},
),
);
},
),
);
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/presentation/views/home_view | mirrored_repositories/BooklyApp/lib/features/home/presentation/views/home_view/widgets/newest_books_list_view_bloc_builder.dart | import 'newest_books_list_view.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:bookly/core/widgets/custom_error.dart';
import 'package:bookly/core/widgets/custom_loading_indicator.dart';
import 'package:bookly/features/home/presentation/cubits/newest_books_cubit/newest_books_cubit.dart';
class NewestBooksListViewBlocBuilder extends StatelessWidget {
const NewestBooksListViewBlocBuilder({super.key});
@override
Widget build(BuildContext context) {
return BlocBuilder<NewestBooksCubit, NewestBookState>(
builder: (context, state) {
if (state is FetchNewestBooksSuccess){
return NewestBooksListView(books: state.books);
} else if (state is FetchNewestBooksFailure) {
return CustomError(errMessage: state.errMessage);
} else {
return const CustomLoadingIndicator();
}
},
);
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/presentation/cubits | mirrored_repositories/BooklyApp/lib/features/home/presentation/cubits/similar_books_cubit/similar_book_cubit.dart | import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:bookly/core/entities/book_entity.dart';
import 'package:bookly/features/home/domain/use_cases/fetch_similar_books_use_case.dart';
part 'similar_book_state.dart';
class SimilarBooksCubit extends Cubit<SimilarBooksState> {
SimilarBooksCubit(this._fetchUseCase) : super(SimilarBooksInitial());
final FetchSimilarBooksUseCase _fetchUseCase;
Future<void> fetchSimilarBooks() async {
emit(SimilarBooksLoading());
var result = await _fetchUseCase.call();
result.fold((failure) {
emit(SimilarBooksFailure(failure.errMessage));
}, (books) {
emit(SimilarBooksSuccess(books));
});
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/presentation/cubits | mirrored_repositories/BooklyApp/lib/features/home/presentation/cubits/similar_books_cubit/similar_book_state.dart | part of 'similar_book_cubit.dart';
@immutable
abstract class SimilarBooksState {}
class SimilarBooksInitial extends SimilarBooksState {}
class SimilarBooksLoading extends SimilarBooksState {}
class SimilarBooksSuccess extends SimilarBooksState {
final List<BookEntity> books;
SimilarBooksSuccess(this.books);
}
class SimilarBooksFailure extends SimilarBooksState {
final String errMessage;
SimilarBooksFailure(this.errMessage);
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/presentation/cubits | mirrored_repositories/BooklyApp/lib/features/home/presentation/cubits/newest_books_cubit/newest_books_state.dart | part of 'newest_books_cubit.dart';
@immutable
abstract class NewestBookState {}
class NewestBooksInitial extends NewestBookState {}
class FetchNewestBooksLoading extends NewestBookState {}
class FetchNewestBooksSuccess extends NewestBookState {
final List<BookEntity> books;
FetchNewestBooksSuccess(this.books);
}
class FetchNewestBooksFailure extends NewestBookState {
final String errMessage;
FetchNewestBooksFailure(this.errMessage);
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/presentation/cubits | mirrored_repositories/BooklyApp/lib/features/home/presentation/cubits/newest_books_cubit/newest_books_cubit.dart | import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:bookly/core/entities/book_entity.dart';
import 'package:bookly/features/home/domain/use_cases/fetch_newest_books_use_case.dart';
part 'newest_books_state.dart';
class NewestBooksCubit extends Cubit<NewestBookState> {
NewestBooksCubit(this._fetchUseCase) : super(NewestBooksInitial());
final FetchNewestBooksUseCase _fetchUseCase;
Future<void> fetchNewestBooks() async {
emit(FetchNewestBooksLoading());
var result = await _fetchUseCase.call();
result.fold((failure) {
emit(FetchNewestBooksFailure(failure.errMessage));
}, (books) {
emit(FetchNewestBooksSuccess(books));
});
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/presentation/cubits | mirrored_repositories/BooklyApp/lib/features/home/presentation/cubits/featured_books_cubit/featured_books_state.dart | part of 'featured_books_cubit.dart';
@immutable
abstract class FeaturedBooksState {}
class FeaturedBooksInitial extends FeaturedBooksState {}
class FetchFeaturedBooksLoading extends FeaturedBooksState {}
class FetchFeaturedBooksSuccess extends FeaturedBooksState {
final List<BookEntity> books;
FetchFeaturedBooksSuccess(this.books);
}
class FetchFeaturedBooksFailure extends FeaturedBooksState {
final String errMessage;
FetchFeaturedBooksFailure(this.errMessage);
}
class FetchFeaturedBooksPaginationLoading extends FeaturedBooksState {}
class FetchFeaturedBooksPaginationSuccess extends FeaturedBooksState {
final List<BookEntity> books;
FetchFeaturedBooksPaginationSuccess(this.books);
}
class FetchFeaturedBooksPaginationFailure extends FeaturedBooksState {
final String errMessage;
FetchFeaturedBooksPaginationFailure(this.errMessage);
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/presentation/cubits | mirrored_repositories/BooklyApp/lib/features/home/presentation/cubits/featured_books_cubit/featured_books_cubit.dart | import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:bookly/core/entities/book_entity.dart';
import 'package:bookly/features/home/domain/use_cases/fetch_featured_books_use_case.dart';
part 'featured_books_state.dart';
class FeaturedBooksCubit extends Cubit<FeaturedBooksState> {
FeaturedBooksCubit(this._fetchUseCase) : super(FeaturedBooksInitial());
final FetchFeaturedBooksUseCase _fetchUseCase;
Future<void> fetchFeaturedBooks({int page = 0}) async {
if (page == 0) {
emit(FetchFeaturedBooksLoading());
} else {
emit(FetchFeaturedBooksPaginationLoading());
}
var result = await _fetchUseCase.call(page: page);
result.fold((failure) {
if (page == 0) {
emit(FetchFeaturedBooksFailure(failure.errMessage));
} else {
emit(FetchFeaturedBooksPaginationFailure(failure.errMessage));
}
}, (books) {
emit(FetchFeaturedBooksSuccess(books));
});
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/domain | mirrored_repositories/BooklyApp/lib/features/home/domain/use_cases/fetch_featured_books_use_case.dart | import 'package:dartz/dartz.dart';
import 'package:bookly/core/errors/failure.dart';
import 'package:bookly/core/entities/book_entity.dart';
import 'package:bookly/core/use_cases/no_param_use_case.dart';
import 'package:bookly/features/home/domain/repos/home_repo.dart';
class FetchFeaturedBooksUseCase extends UseCase<List<BookEntity>> {
final HomeRepo _homeRepo;
FetchFeaturedBooksUseCase(this._homeRepo);
@override
Future<Either<Failure, List<BookEntity>>> call({int page = 0}) async {
return await _homeRepo.fetchFeaturedBooks(page: page);
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/domain | mirrored_repositories/BooklyApp/lib/features/home/domain/use_cases/fetch_similar_books_use_case.dart | import 'package:dartz/dartz.dart';
import 'package:bookly/core/errors/failure.dart';
import 'package:bookly/core/use_cases/no_param_use_case.dart';
import 'package:bookly/features/home/domain/repos/home_repo.dart';
import 'package:bookly/core/entities/book_entity.dart';
class FetchSimilarBooksUseCase extends UseCase<List<BookEntity>> {
final HomeRepo _homeRepo;
FetchSimilarBooksUseCase(this._homeRepo);
@override
Future<Either<Failure, List<BookEntity>>> call() async {
return await _homeRepo.fetchSimilarBooks();
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/domain | mirrored_repositories/BooklyApp/lib/features/home/domain/use_cases/fetch_newest_books_use_case.dart | import 'package:dartz/dartz.dart';
import 'package:bookly/core/errors/failure.dart';
import 'package:bookly/core/use_cases/no_param_use_case.dart';
import 'package:bookly/features/home/domain/repos/home_repo.dart';
import 'package:bookly/core/entities/book_entity.dart';
class FetchNewestBooksUseCase extends UseCase<List<BookEntity>> {
final HomeRepo _homeRepo;
FetchNewestBooksUseCase(this._homeRepo);
@override
Future<Either<Failure, List<BookEntity>>> call() async {
return await _homeRepo.fetchNewestBooks();
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/home/domain | mirrored_repositories/BooklyApp/lib/features/home/domain/repos/home_repo.dart | import 'package:dartz/dartz.dart';
import 'package:bookly/core/errors/failure.dart';
import 'package:bookly/core/entities/book_entity.dart';
abstract class HomeRepo {
Future<Either<Failure, List<BookEntity>>> fetchFeaturedBooks({int page = 0});
Future<Either<Failure, List<BookEntity>>> fetchNewestBooks();
Future<Either<Failure, List<BookEntity>>> fetchSimilarBooks();
} | 0 |
mirrored_repositories/BooklyApp/lib/features/splash/presentation | mirrored_repositories/BooklyApp/lib/features/splash/presentation/views/splash_view.dart | import 'package:bookly/features/splash/presentation/views/widgets/splash_view_body.dart';
import 'package:flutter/material.dart';
class SplashView extends StatelessWidget {
const SplashView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const Scaffold(
body: SplashViewBody(),
);
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/splash/presentation/views | mirrored_repositories/BooklyApp/lib/features/splash/presentation/views/widgets/splash_view_body.dart | import 'package:bookly/constants.dart';
import 'package:bookly/features/splash/presentation/views/widgets/sliding_text.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
class SplashViewBody extends StatefulWidget {
const SplashViewBody({Key? key}) : super(key: key);
@override
State<SplashViewBody> createState() => _SplashViewBodyState();
}
class _SplashViewBodyState extends State<SplashViewBody>
with SingleTickerProviderStateMixin {
late AnimationController animationController;
late Animation<Offset> slidingAnimation;
@override
void initState() {
// ignore: todo
// TODO: implement initState
super.initState();
initSlidingText();
navigateToHome();
}
@override
void dispose() {
// ignore: todo
// TODO: implement dispose
super.dispose();
animationController.dispose();
}
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Image.asset(kLogo),
const SizedBox(
height: 5,
),
SlidingText(slidingAnimation: slidingAnimation)
],
);
}
void initSlidingText() {
animationController = AnimationController(
vsync: this, duration: const Duration(milliseconds: 1500));
slidingAnimation =
Tween<Offset>(begin: const Offset(0, 10), end: Offset.zero)
.animate(animationController);
animationController.forward();
}
void navigateToHome() {
Future.delayed(
const Duration(seconds: 3),
() {
GoRouter.of(context).pushReplacement(kHomeView);
},
);
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/splash/presentation/views | mirrored_repositories/BooklyApp/lib/features/splash/presentation/views/widgets/sliding_text.dart | import 'package:flutter/material.dart';
class SlidingText extends StatelessWidget {
const SlidingText({
super.key,
required this.slidingAnimation,
});
final Animation<Offset> slidingAnimation;
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: slidingAnimation,
builder: (context, _) {
return SlideTransition(
position: slidingAnimation,
child: const Text(
'Read Books For Free',
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
),
);
});
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/search/data | mirrored_repositories/BooklyApp/lib/features/search/data/repos/search_repo_impl.dart | import 'package:dio/dio.dart';
import 'package:dartz/dartz.dart';
import 'package:bookly/core/errors/failure.dart';
import 'package:bookly/core/utils/api_service.dart';
import 'package:bookly/core/errors/server_failure.dart';
import 'package:bookly/core/models/book_model/book_model.dart';
import 'package:bookly/features/search/domain/repos/search_repo.dart';
class SearchRepoImpl implements SearchRepo {
final ApiService _apiService;
SearchRepoImpl(this._apiService);
@override
Future<Either<Failure, List<BookModel>>> fetchSearchedBooks({
required String query,
required int page,
}) async {
try {
var data = await _apiService.get(
endpoint: 'volumes?Filtering=free-ebooks&q=$query&startIndex=${page * 10}');
List<BookModel> books = [];
for (var item in data['items']) {
books.add(BookModel.fromJson(item));
}
return Right(books);
} on Exception catch (e) {
if (e is DioException) {
return Left(ServerFailure.fromDioError(e));
} else {
return Left(ServerFailure(errMessage: e.toString()));
}
}
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/search/presentation | mirrored_repositories/BooklyApp/lib/features/search/presentation/views/search_view.dart | import 'package:flutter/material.dart';
import 'package:bookly/features/search/presentation/views/widgets/search_view_body.dart';
class SearchView extends StatelessWidget {
const SearchView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return SafeArea(
child: WillPopScope(
onWillPop: () async {
Navigator.pop(context);
return true;
},
child: const Scaffold(
body: SearchViewBody(),
),
),
);
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/search/presentation/views | mirrored_repositories/BooklyApp/lib/features/search/presentation/views/widgets/search_results_list_view.dart | import 'package:bookly/core/widgets/custom_error.dart';
import 'package:bookly/core/widgets/custom_loading_indicator.dart';
import 'package:bookly/features/home/presentation/views/home_view/widgets/book_list_view_item.dart';
import 'package:bookly/features/search/presentation/cubits/searched_books_cubit/searched_books_cubit.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
class SearchResultListView extends StatefulWidget {
const SearchResultListView({Key? key}) : super(key: key);
@override
State<SearchResultListView> createState() => _SearchResultListViewState();
}
class _SearchResultListViewState extends State<SearchResultListView> {
int nextPage = 1;
late final ScrollController _scrollController;
@override
void initState() {
super.initState();
_scrollController = ScrollController()..addListener(_checkScrollThreshold);
}
@override
void dispose() {
_scrollController.removeListener(_checkScrollThreshold);
_scrollController.dispose();
super.dispose();
}
void _checkScrollThreshold() {
final double currentPosition = _scrollController.position.pixels;
final double maxScroll = _scrollController.position.maxScrollExtent;
final double scrollThreshold = maxScroll * 0.7;
SearchedBooksCubit cubit = BlocProvider.of<SearchedBooksCubit>(context);
if (currentPosition >= scrollThreshold) {
cubit.fetchSearchedBooks(query: cubit.searchController.text, page: nextPage++);
}
}
@override
Widget build(BuildContext context) {
return BlocBuilder<SearchedBooksCubit, SearchedBooksState>(
builder: (context, state) {
if (state is SearchedBooksSuccess) {
return ListView.builder(
controller: _scrollController,
physics: const BouncingScrollPhysics(),
padding: EdgeInsets.zero,
itemCount: state.books.length,
itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 5.0),
child: BookListViewItem(
book: state.books[index],
),
);
},
);
} else if (state is SearchedBooksInitial) {
return const Center(
child: Icon(
FontAwesomeIcons.magnifyingGlass,
size: 25,
),
);
} else if (state is SearchedBooksFailure) {
return CustomError(errMessage: state.errMessage);
} else {
return const CustomLoadingIndicator();
}
},
);
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/search/presentation/views | mirrored_repositories/BooklyApp/lib/features/search/presentation/views/widgets/custom_search_text_field.dart | import 'package:bookly/core/utils/styles.dart';
import 'package:bookly/features/search/presentation/cubits/searched_books_cubit/searched_books_cubit.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
class CustomSearchTextField extends StatelessWidget {
const CustomSearchTextField({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return TextField(
controller: BlocProvider.of<SearchedBooksCubit>(context).searchController,
onSubmitted: (String query) {
BlocProvider.of<SearchedBooksCubit>(context)
.fetchSearchedBooks(query: query, page: 0);
},
decoration: InputDecoration(
hintText: 'Search',
hintStyle: Styles.textStyle18,
suffixIcon: const Opacity(
opacity: 0.5,
child: Icon(
FontAwesomeIcons.magnifyingGlass,
size: 22,
),
),
enabledBorder: outlineInputBorder,
focusedBorder: outlineInputBorder,
border: outlineInputBorder,
),
);
}
}
OutlineInputBorder outlineInputBorder = OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: const BorderSide(
color: Color(0xff707070),
),
);
| 0 |
mirrored_repositories/BooklyApp/lib/features/search/presentation/views | mirrored_repositories/BooklyApp/lib/features/search/presentation/views/widgets/search_view_body.dart | import 'package:flutter/material.dart';
import 'custom_search_text_field.dart';
import 'package:bookly/core/utils/styles.dart';
import 'package:bookly/features/search/presentation/views/widgets/search_results_list_view.dart';
class SearchViewBody extends StatelessWidget {
const SearchViewBody({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const CustomScrollView(
physics: BouncingScrollPhysics(),
slivers: [
SliverToBoxAdapter(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 25.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 20.0),
CustomSearchTextField(),
SizedBox(height: 20.0),
Text('Search Results', style: Styles.textStyle18),
SizedBox(height: 20.0),
],
),
),
),
SliverFillRemaining(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 25.0),
child: SearchResultListView(),
),
),
], // slivers
);
}
}
| 0 |
mirrored_repositories/BooklyApp/lib/features/search/presentation/cubits | mirrored_repositories/BooklyApp/lib/features/search/presentation/cubits/searched_books_cubit/searched_books_state.dart | part of 'searched_books_cubit.dart';
@immutable
abstract class SearchedBooksState {}
class SearchedBooksInitial extends SearchedBooksState {}
class SearchedBooksSuccess extends SearchedBooksState {
final List<BookEntity> books;
SearchedBooksSuccess(this.books);
}
class SearchedBooksFailure extends SearchedBooksState {
final String errMessage;
SearchedBooksFailure(this.errMessage);
}
class SearchedBooksLoading extends SearchedBooksState {}
| 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.