repo_id
stringlengths 21
168
| file_path
stringlengths 36
210
| content
stringlengths 1
9.98M
| __index_level_0__
int64 0
0
|
|---|---|---|---|
mirrored_repositories/News_App_In_Flutter/lib
|
mirrored_repositories/News_App_In_Flutter/lib/components/profile_change.dart
|
// ignore_for_file: unnecessary_new, avoid_print, library_private_types_in_public_api, unnecessary_const, camel_case_types
import 'package:flutter/material.dart';
import 'dart:io';
import 'package:flutter/services.dart';
// ignore: depend_on_referenced_packages
import 'package:image_picker/image_picker.dart';
import 'package:rk_news/bottom_tab/page3.dart';
import 'package:rk_news/components/mytopic.dart';
void main() => runApp(Profile_change());
/// This Widget is the main application widget.
// ignore: use_key_in_widget_constructors
class Profile_change extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
debugShowCheckedModeBanner: false,
home: MyNavigationBar(),
);
}
}
class MyNavigationBar extends StatefulWidget {
const MyNavigationBar({super.key});
@override
_MyNavigationBarState createState() => _MyNavigationBarState();
}
class _MyNavigationBarState extends State<MyNavigationBar> {
File? image;
Future pickImage() async {
try {
final image = await ImagePicker().pickImage(source: ImageSource.gallery);
if (image == null) return;
final imageTemp = File(image.path);
setState(() => this.image = imageTemp);
// ignore: use_build_context_synchronously
Navigator.pop(context);
} on PlatformException {
// print('Failed to pick image: $e');
}
}
Future pickImageC() async {
try {
final image = await ImagePicker().pickImage(source: ImageSource.camera);
if (image == null) return;
// final imageTemp = File(image.path);
setState(() => this.image = File(image.path));
// ignore: empty_catches
} on PlatformException {}
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFFF5F5F5),
body: Center(
child: ListView(children: <Widget>[
Row(
children: <Widget>[
Container(
margin: const EdgeInsets.only(top: 10, left: 5),
alignment: Alignment.centerLeft,
child: IconButton(
icon: const Icon(
// <-- Icon
Icons.arrow_back_ios,
color: Color.fromARGB(255, 204, 192, 192),
size: 18.0,
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Page3()),
);
},
),
),
Container(
margin: const EdgeInsets.only(top: 7),
child: const Text(
'BACK',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w800,
),
),
),
],
),
Center(
child: Container(
margin: const EdgeInsets.only(top: 5, bottom: 12),
width: 80.0,
height: 80.0,
decoration: const BoxDecoration(
shape: BoxShape.circle,
),
child: ClipOval(
child: image != null
? Image.file(
image!,
width: 100,
height: 100,
fit: BoxFit.cover,
)
: Image.asset(
'assets/images/user.png',
width: 100,
height: 100,
fit: BoxFit.cover,
),
),
),
),
Container(
margin: const EdgeInsets.only(top: 10),
alignment: Alignment.center,
child: const Text(
'JOHN SMITH',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
fontFamily: "PlayfairDisplay"),
),
),
Container(
margin: const EdgeInsets.only(top: 5),
alignment: Alignment.center,
child: const Text(
'MEMBER SINCE 5 MAY 2022',
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w700,
color: Color.fromARGB(255, 204, 192, 192)),
),
),
Container(
height: 35,
margin: const EdgeInsets.only(
top: 10.0,
),
padding: const EdgeInsets.fromLTRB(135, 0, 135, 0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
side: const BorderSide(color: Colors.black),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0)),
backgroundColor: Colors.white, // Background color
),
child: const Text(
'EDIT PROFILE',
style: TextStyle(
fontSize: 10,
fontWeight: FontWeight.w500,
color: Colors.black),
),
onPressed: () {
showModalBottomSheet(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (context) => Container(
height: MediaQuery.of(context).size.height * 0.85,
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(25.0),
topRight: Radius.circular(25.0),
),
),
child: ListView(children: <Widget>[
Row(
children: <Widget>[
Container(
margin: const EdgeInsets.only(top: 25, left: 20),
child: GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: ClipRRect(
borderRadius: BorderRadius.circular(20.0),
child: Image.network(
'https://icons.veryicon.com/png/o/miscellaneous/student/false.png',
width: 16.0,
height: 16.0),
),
),
),
Container(
margin: const EdgeInsets.only(top: 25, left: 120),
alignment: Alignment.topCenter,
child: const Text(
'Edit Profile',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
fontFamily: "PlayfairDisplay"),
),
),
Container(
margin:
const EdgeInsets.only(top: 25, left: 80),
alignment: Alignment.topRight,
child: SizedBox(
width: 60, // <-- Your width
height: 25, // <-- Your height
child: ElevatedButton(
style: ElevatedButton.styleFrom(
side: const BorderSide(
color: Colors.black),
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(5.0)),
backgroundColor:
Colors.white, // Background color
),
child: const Text(
'SAVE',
style: TextStyle(
fontSize: 7,
fontWeight: FontWeight.w500,
color: Colors.black),
),
onPressed: () {},
))),
],
),
Container(
margin: const EdgeInsets.only(
top: 10,
),
width: 100.0,
height: 1.0,
color: Colors.black,
),
Center(
child: Container(
margin: const EdgeInsets.only(top: 40, bottom: 12),
width: 70.0,
height: 70.0,
decoration: const BoxDecoration(
shape: BoxShape.circle,
),
child: ClipOval(
child: image != null
? Image.file(
image!,
width: 100,
height: 100,
fit: BoxFit.cover,
)
: Image.asset(
'assets/images/user.png',
width: 100,
height: 100,
fit: BoxFit.cover,
),
),
),
),
InkWell(
child: const Text(
'CHANGE PROFILE PHOTO',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 10,
fontWeight: FontWeight.w700,
),
),
onTap: () {
pickImage();
}),
Container(
margin: const EdgeInsets.only(top: 40, left: 35.0),
child: const Text(
'NAME',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w400,
fontFamily: "PlayfairDisplay"),
),
),
Container(
margin: const EdgeInsets.only(left: 35.0, right: 35),
child: const TextField(
textAlign: TextAlign.start,
),
)
])),
);
},
)),
Container(
margin: const EdgeInsets.only(top: 40, left: 35.0),
child: const Text(
'SUPPORT',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w400,
fontFamily: "PlayfairDisplay"),
),
),
Container(
height: 50,
margin: const EdgeInsets.only(top: 20.0, left: 30.0),
padding: const EdgeInsets.fromLTRB(0, 0, 15, 0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
side: const BorderSide(color: Colors.black),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topRight: Radius.circular(10),
topLeft: Radius.circular(10),
),
),
backgroundColor: Colors.white, // Background color
),
child: const Align(
alignment: Alignment.centerLeft,
child: Text(
'Privacy Policy',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
color: Colors.black),
),
),
onPressed: () {},
)),
Container(
height: 50,
margin: const EdgeInsets.only(left: 30.0),
padding: const EdgeInsets.fromLTRB(0, 0, 15, 0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
side: const BorderSide(color: Colors.black),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0.0)),
backgroundColor: Colors.white, // Background color
),
child: const Align(
alignment: Alignment.centerLeft,
child: Text(
'Send us Feedback',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
color: Colors.black),
),
),
onPressed: () {},
)),
Container(
height: 50,
margin: const EdgeInsets.only(left: 30.0),
padding: const EdgeInsets.fromLTRB(0, 0, 15, 0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
side: const BorderSide(color: Colors.black),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(10),
bottomRight: Radius.circular(10),
),
),
backgroundColor: Colors.white, // Background color
),
child: const Align(
alignment: Alignment.centerLeft,
child: Text(
'Terms and Services',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
color: Colors.black),
),
),
onPressed: () {},
)),
Container(
margin: const EdgeInsets.only(top: 40, left: 35.0),
child: const Text(
'Account',
style: TextStyle(
fontSize: 21,
fontWeight: FontWeight.w300,
fontFamily: "PlayfairDisplay"),
),
),
Container(
height: 50,
margin: const EdgeInsets.only(top: 10.0, left: 30.0),
padding: const EdgeInsets.fromLTRB(0, 0, 15, 0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
side: const BorderSide(color: Colors.black),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topRight: Radius.circular(6),
topLeft: Radius.circular(6),
bottomLeft: Radius.circular(6),
bottomRight: Radius.circular(6),
),
),
backgroundColor: Colors.white, // Background color
),
child: const Align(
alignment: Alignment.centerLeft,
child: Text(
'Manage Subscribed Topics',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
color: Colors.black),
),
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const Mytopic()),
);
},
)),
Container(
height: 40,
margin: const EdgeInsets.only(left: 30.0, top: 30),
padding: const EdgeInsets.fromLTRB(0, 0, 15, 0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0.0)),
backgroundColor: const Color(0xFFD9534F), // Background color
),
child: const Align(
alignment: Alignment.centerLeft,
child: Text(
'Send us Feedback',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
color: Colors.white),
),
),
onPressed: () {},
)),
Container(
height: 40,
margin: const EdgeInsets.only(left: 30.0, top: 30, bottom: 30),
padding: const EdgeInsets.fromLTRB(0, 0, 15, 0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
side: const BorderSide(color: Colors.red),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0.0)),
backgroundColor: const Color(0xFFF5F5F5),
),
child: const Align(
alignment: Alignment.centerLeft,
child: Text(
'Terms and Services',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
color: Colors.black),
),
),
onPressed: () {},
)),
])),
);
}
}
| 0
|
mirrored_repositories/News_App_In_Flutter/lib
|
mirrored_repositories/News_App_In_Flutter/lib/components/topic.dart
|
// ignore_for_file: library_private_types_in_public_api, file_names, depend_on_referenced_packages, camel_case_types
import 'dart:convert';
// ignore: unused_import
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
class Topic extends StatefulWidget {
const Topic({super.key});
@override
_IndexPageState createState() => _IndexPageState();
}
class _IndexPageState extends State<Topic> {
List users = [];
bool isLoading = false;
@override
void initState() {
// ignore: todo
// TODO: implement initState
super.initState();
// ignore: unnecessary_this
this.fetchUser();
}
fetchUser() async {
setState(() {
isLoading = true;
});
var request = http.Request(
'GET',
Uri.parse(
'https://newsapi.org/v2/top-headlines?country=us&category=business&apiKey=7269b488b8f84ff1ac8575ba0ac4df67'));
// http.StreamedResponse response = await request.send();
http.StreamedResponse response = await request.send();
var res = await http.Response.fromStream(response);
// var url = "https://randomuser.me/api/?results=50";
// var response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
var items = json.decode(res.body)["articles"];
// if (kDebugMode) {
// print(items);
// }
setState(() {
users = items;
isLoading = false;
});
} else {
users = [];
isLoading = false;
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: const Color(0xFFF5F5F5),
toolbarHeight: 80.10, //set your height
flexibleSpace: SafeArea(
child: Container(
margin: const EdgeInsets.only(
top: 30.0,
),
color: const Color(0xFFF5F5F5), // set your color
child: Column(
children: [
Row(
children: <Widget>[
Container(
margin: const EdgeInsets.only(left: 20.0, bottom: 3.0),
alignment: Alignment.center,
),
SizedBox(
width: 90.0,
height: 30.0,
child: ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
// Background color
),
child: Row(
mainAxisSize: MainAxisSize.min,
// ignore: prefer_const_literals_to_create_immutables
children: [
const Text('COVID-19',
style: TextStyle(
fontSize: 7,
fontWeight: FontWeight.w700,
color: Colors.white,
)), // <-- Text
],
),
),
),
Container(
margin: const EdgeInsets.only(
left: 20.0,
),
alignment: Alignment.center,
),
SizedBox(
width: 95.0,
height: 30.0,
child: ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFFA1A1A1),
),
child: Row(
mainAxisSize: MainAxisSize.min,
// ignore: prefer_const_literals_to_create_immutables
children: [
const Text('FUTURE OF FOOD',
style: TextStyle(
fontSize: 7,
fontWeight: FontWeight.w700,
color: Colors.white,
)), // <-- Text
],
),
),
),
Container(
margin: const EdgeInsets.only(
left: 10.0,
),
alignment: Alignment.center,
),
Container(
margin: const EdgeInsets.only(left: 10.0, bottom: 3.0),
alignment: Alignment.center,
),
SizedBox(
width: 95.0,
height: 30.0,
child: ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFFA1A1A1),
// Background color
),
child: Row(
mainAxisSize: MainAxisSize.min,
// ignore: prefer_const_literals_to_create_immutables
children: [
const Text('MENTAL HEALTH',
style: TextStyle(
fontSize: 7,
fontWeight: FontWeight.w700,
color: Colors.white,
)), // <-- Text
],
),
),
),
],
),
// set an icon or image
// set your search bar setting
],
),
),
),
),
backgroundColor: const Color(0xFFF5F5F5),
body: getBody(),
);
}
Widget getBody() {
// ignore: prefer_is_empty
if (users.contains(null) || users.length < 0 || isLoading) {
return const Center(child: CircularProgressIndicator());
}
return ListView.builder(
itemCount: users.length,
itemBuilder: (BuildContext ctx, index) {
// return ListTile(
// leading: Image.network(
// users[index]["urlToImage"],
// width: 150,
// fit: BoxFit.cover,
// ),
// title: Text(users[index]['title']),
// subtitle: Text(users[index]["author"]));
return SizedBox(
height: 340,
width: 200,
child: Card(
margin: const EdgeInsets.all(20),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
margin: const EdgeInsets.only(top: 10),
alignment: Alignment.center,
child: ClipRRect(
borderRadius:
BorderRadius.circular(6), // Image border
// Image radius
child: Image.network(
users[index]["urlToImage"] ??
'https://images.indianexpress.com/2022/10/liz-truss-6.jpg?w=475',
cacheHeight: 140,
cacheWidth: 300,
alignment: Alignment.topCenter,
),
)),
Container(
margin: const EdgeInsets.only(top: 10.0, left: 11),
width: 130,
height: 15,
child: Text(
users[index]["source"]["name"] ?? 'CNN',
style: const TextStyle(
fontSize: 13,
fontWeight: FontWeight.w700,
),
),
),
Container(
margin: const EdgeInsets.only(top: 10),
child: Row(
children: [
Container(
margin: const EdgeInsets.only(left: 11),
width: 40,
height: 15,
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10.0),
bottomLeft: Radius.circular(10.0),
topRight: Radius.circular(10.0),
bottomRight: Radius.circular(10.0)),
color: Color.fromARGB(255, 8, 87, 151),
),
child: Text(
users[index]["author"] ?? 'CNN',
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 13,
fontWeight: FontWeight.w400,
color: Colors.white),
),
),
Container(
margin: const EdgeInsets.only(left: 11),
width: 130,
height: 18,
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10.0),
bottomLeft: Radius.circular(10.0),
topRight: Radius.circular(10.0),
bottomRight: Radius.circular(10.0)),
color: Colors.black,
),
// ignore: sort_child_properties_last
child: Text(
users[index]['title'] ?? 'CNN',
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 13,
fontWeight: FontWeight.w400,
color: Colors.white),
),
),
],
),
),
Container(
margin: const EdgeInsets.only(left: 11, top: 20),
alignment: Alignment.center,
width: 250,
height: 40,
child: Text(
users[index]["description"] ??
'Liz Truss Resigns Live Updates: British Prime Minister Liz Truss today dramatically announced her resignation just six weeks after taking office.',
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
),
),
),
// Container(
// width: 250,
// height: 40,
// decoration: const BoxDecoration(
// borderRadius: BorderRadius.only(
// topLeft: Radius.circular(10.0),
// bottomLeft: Radius.circular(10.0),
// topRight: Radius.circular(10.0),
// bottomRight: Radius.circular(10.0)),
// color: Colors.green,
// ),
// child: const Text(
// 'This is a Container',
// textScaleFactor: 2,
// style: TextStyle(color: Colors.black),
// )),
],
),
],
),
),
),
);
});
}
}
| 0
|
mirrored_repositories/News_App_In_Flutter/lib
|
mirrored_repositories/News_App_In_Flutter/lib/components/Bias.dart
|
// ignore_for_file: file_names, library_private_types_in_public_api, unrelated_type_equality_checks
import 'package:flutter/material.dart';
import 'package:rk_news/bargraph.dart';
import 'package:rk_news/bottom_tab/page3.dart';
void main() => runApp(Bias());
/// This Widget is the main application widget.
// ignore: use_key_in_widget_constructors
class Bias extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
debugShowCheckedModeBanner: false,
home: MyNavigationBar(),
);
}
}
class MyNavigationBar extends StatefulWidget {
const MyNavigationBar({super.key});
@override
_MyNavigationBarState createState() => _MyNavigationBarState();
}
class _MyNavigationBarState extends State<MyNavigationBar> {
@override
void initState() {
super.initState();
pp();
}
String a = "";
void pp() {
setState(() {
a = "D";
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFFF5F5F5),
body: Center(
child: ListView(children: <Widget>[
Row(
children: <Widget>[
Container(
margin: const EdgeInsets.only(top: 10, left: 5),
alignment: Alignment.centerLeft,
child: IconButton(
icon: const Icon(
// <-- Icon
Icons.arrow_back_ios,
color: Color.fromARGB(255, 204, 192, 192),
size: 15.0,
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Page3()),
);
},
),
),
Container(
margin: const EdgeInsets.only(top: 7),
child: const Text(
'BACK',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 8,
fontWeight: FontWeight.w800,
),
),
),
],
),
Container(
margin: const EdgeInsets.only(),
child: const Text(
'Bias Dashboard',
textAlign: TextAlign.center,
style: TextStyle(fontSize: 20, fontFamily: "PlayfairDisplay"),
),
),
SizedBox(
height: 350,
width: 200,
child: Card(
elevation: 15,
color: Colors.white,
margin: const EdgeInsets.all(20),
child: Padding(
padding: const EdgeInsetsDirectional.fromSTEB(16, 0, 16, 8),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Container(
margin: const EdgeInsets.only(top: 20.0),
height: 20,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
boxShadow: const [
BoxShadow(
color: Color(0xFFE5E5E5),
),
],
),
child: Row(
children: [
Container(
margin: const EdgeInsets.only(
left: 10.0,
),
alignment: Alignment.center,
),
SizedBox(
child: ElevatedButton(
onPressed: () {
setState(() {
a = "D";
});
},
style: ElevatedButton.styleFrom(
elevation: 0,
foregroundColor: Colors.black,
backgroundColor: a == "D"
? const Color(0xFFEA7432)
: const Color(0xFFE5E5E5),
shadowColor: Colors.greenAccent,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(32.0)),
minimumSize: const Size(30, 20), //////// HERE
),
child: Text(
'D',
style: TextStyle(
color:
a == "D" ? Colors.white : Colors.black),
),
),
),
Container(
margin: const EdgeInsets.only(
left: 10.0,
),
alignment: Alignment.center,
),
SizedBox(
child: ElevatedButton(
onPressed: () {
setState(() {
a = "M";
});
},
style: ElevatedButton.styleFrom(
foregroundColor: Colors.black,
backgroundColor: a == "M"
? const Color(0xFFEA7432)
: const Color(0xFFE5E5E5),
shadowColor: Colors.greenAccent,
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(32.0)),
minimumSize: const Size(30, 20), //////// HERE
),
child: Text(
'M',
style: TextStyle(
color:
a == "M" ? Colors.white : Colors.black),
),
),
),
Container(
margin: const EdgeInsets.only(
left: 10.0,
),
alignment: Alignment.center,
),
SizedBox(
child: ElevatedButton(
onPressed: () {
setState(() {
a = "3M";
});
},
style: ElevatedButton.styleFrom(
foregroundColor: Colors.black,
backgroundColor: a == "3M"
? const Color(0xFFEA7432)
: const Color(0xFFE5E5E5),
shadowColor: Colors.greenAccent,
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(32.0)),
minimumSize: const Size(30, 20), //////// HERE
),
child: Text(
'3M',
style: TextStyle(
color: a == "3M"
? Colors.white
: Colors.black),
),
),
),
Container(
margin: const EdgeInsets.only(
left: 10.0,
),
alignment: Alignment.center,
),
SizedBox(
child: ElevatedButton(
onPressed: () {
setState(() {
a = "6M";
});
},
style: ElevatedButton.styleFrom(
foregroundColor: Colors.black,
backgroundColor: a == "6M"
? const Color(0xFFEA7432)
: const Color(0xFFE5E5E5),
shadowColor: Colors.greenAccent,
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(32.0)),
minimumSize: const Size(30, 20), //////// HERE
),
child: Text(
'6M',
style: TextStyle(
color: a == "6M"
? Colors.white
: Colors.black),
),
),
),
Container(
margin: const EdgeInsets.only(
left: 10.0,
),
alignment: Alignment.center,
),
SizedBox(
child: ElevatedButton(
onPressed: () {
setState(() {
a = "Y";
});
},
style: ElevatedButton.styleFrom(
foregroundColor: Colors.black,
backgroundColor: a == "Y"
? const Color(0xFFEA7432)
: const Color(0xFFE5E5E5),
shadowColor: Colors.greenAccent,
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(32.0)),
minimumSize: const Size(30, 20), //////// HERE
),
child: Text(
'Y',
style: TextStyle(
color:
a == "Y" ? Colors.white : Colors.black),
),
),
),
],
)),
Container(
margin: const EdgeInsets.only(
bottom: 20.0,
),
alignment: Alignment.center,
),
Expanded(
child: (a == "D")
? (const Bargraph(
left: 150.00, right: 10.00, center: 50.00))
: (a == 'M')
? (const Bargraph(
left: 50.00, right: 110.00, center: 150.00))
: (a == '3M')
? (const Bargraph(
left: 20.00,
right: 10.00,
center: 150.00))
: (a == '6M')
? (const Bargraph(
left: 120.00,
right: 80.00,
center: 150.00))
: (a == 'Y')
? (const Bargraph(
left: 60.00,
right: 10.00,
center: 140.00))
: (const Bargraph(
left: 180.00,
right: 150.00,
center: 10.00)))
],
),
),
),
),
Row(
children: <Widget>[
//
Card(
elevation: 20,
margin: const EdgeInsets.only(left: 30.0, top: 20, bottom: 20),
child: Container(
height: 110,
width: 155,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
),
child: Column(
children: <Widget>[
Container(
margin: const EdgeInsets.only(),
child: const Text(
'100',
style: TextStyle(
fontSize: 50,
fontWeight: FontWeight.w600,
fontFamily: "PlayfairDisplay"),
),
),
Container(
margin: const EdgeInsets.only(),
child: const Text(
'Total Read',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
),
),
),
],
),
),
),
Card(
elevation: 20,
margin: const EdgeInsets.only(left: 20.0, top: 20, bottom: 20),
child: Container(
height: 110,
width: 155,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
),
child: Column(
children: <Widget>[
Container(
margin: const EdgeInsets.only(),
child: const Text(
'5',
style: TextStyle(
fontSize: 50,
fontWeight: FontWeight.w600,
fontFamily: "PlayfairDisplay"),
),
),
Container(
margin: const EdgeInsets.only(),
child: const Text(
'MinimunTime Spend',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
),
),
),
Container(
margin: const EdgeInsets.only(),
child: const Text(
'(mins) per Article',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
),
),
),
],
),
),
),
],
),
Row(
children: <Widget>[
//
Card(
elevation: 20,
margin: const EdgeInsets.only(left: 30.0, top: 4, bottom: 20),
child: Container(
height: 110,
width: 155,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
),
child: Column(
children: <Widget>[
Container(
margin: const EdgeInsets.only(),
child: const Text(
'10',
style: TextStyle(
fontSize: 50,
fontWeight: FontWeight.w600,
fontFamily: "PlayfairDisplay"),
),
),
Container(
margin: const EdgeInsets.only(),
child: const Text(
'MaximunTime Spend',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
),
),
),
Container(
margin: const EdgeInsets.only(),
child: const Text(
'(mins) per Article',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
),
),
),
],
),
),
),
Card(
elevation: 20,
margin: const EdgeInsets.only(left: 20.0, top: 4, bottom: 20),
child: Container(
height: 110,
width: 155,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
),
child: Column(
children: <Widget>[
Container(
margin: const EdgeInsets.only(),
child: const Text(
'1.5',
style: TextStyle(
fontSize: 50,
fontWeight: FontWeight.w600,
fontFamily: "PlayfairDisplay"),
),
),
Container(
margin: const EdgeInsets.only(),
child: const Text(
'Average Total Time',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
),
),
),
Container(
margin: const EdgeInsets.only(),
child: const Text(
'Spend (Hrs',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
),
),
),
],
),
),
),
],
),
])),
);
}
}
| 0
|
mirrored_repositories/News_App_In_Flutter/lib
|
mirrored_repositories/News_App_In_Flutter/lib/components/image.dart
|
// ignore_for_file: depend_on_referenced_packages, unused_import, use_build_context_synchronously
import 'dart:io';
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:image_picker/image_picker.dart';
void main() {
runApp(const Imagee());
}
class Imagee extends StatelessWidget {
const Imagee({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
canvasColor: Colors.white,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
File? image;
Future pickImage() async {
try {
final image = await ImagePicker().pickImage(source: ImageSource.gallery);
if (image == null) return;
final imageTemp = File(image.path);
setState(() => this.image = imageTemp);
Navigator.pop(context);
} on PlatformException {
// ignore: avoid_print
// print('Failed to pick image: $e');
}
}
Future pickImageC() async {
try {
final image = await ImagePicker().pickImage(source: ImageSource.camera);
if (image == null) return;
final imageTemp = File(image.path);
setState(() => this.image = imageTemp);
// ignore: empty_catches
} on PlatformException {}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Image Picker Example"),
),
body: Center(
child: Column(
children: [
MaterialButton(
color: Colors.blue,
child: const Text("Pick Image from Gallery",
style: TextStyle(
color: Colors.white70, fontWeight: FontWeight.bold)),
onPressed: () {
pickImage();
}),
MaterialButton(
color: Colors.blue,
child: const Text("Pick Image from Camera",
style: TextStyle(
color: Colors.white70, fontWeight: FontWeight.bold)),
onPressed: () {
pickImageC();
}),
Container(
height: 70, width: 70,
margin: const EdgeInsets.only(top: 20, left: 20),
// Border width
decoration: const BoxDecoration(
color: Colors.black, shape: BoxShape.circle),
child: ClipOval(
child: image != null
? Image.file(
image!,
width: 100,
height: 100,
fit: BoxFit.cover,
)
: Image.asset(
'assets/images/user.png',
width: 100,
height: 100,
fit: BoxFit.cover,
),
),
),
Container(
height: 35,
margin: const EdgeInsets.only(top: 10.0, left: 30.0),
padding: const EdgeInsets.fromLTRB(125, 0, 125, 0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
side: const BorderSide(color: Colors.black),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0)),
backgroundColor: Colors.white, // Background color
),
child: const Text(
'EDIT PROFILE',
style: TextStyle(
fontSize: 10,
fontWeight: FontWeight.w500,
color: Colors.black),
),
onPressed: () {
showModalBottomSheet(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (context) => Container(
height: MediaQuery.of(context).size.height * 0.85,
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(25.0),
topRight: Radius.circular(25.0),
),
),
child: ListView(children: <Widget>[
Row(
children: <Widget>[
// Container(
// margin:
// const EdgeInsets.only(top: 10, left: 5),
// alignment: Alignment.topLeft,
// child: IconButton(
// icon: const Icon(
// // <-- Icon
// Icons.arrow_back_ios,
// color:
// Color.fromARGB(255, 204, 192, 192),
// size: 15.0,
// ),
// onPressed: () {
// Navigator.pop(context);
// },
// ),
// ),
Container(
margin: const EdgeInsets.only(
top: 25, left: 20),
child: GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: ClipRRect(
borderRadius:
BorderRadius.circular(20.0),
child: Image.network(
'https://icons.veryicon.com/png/o/miscellaneous/student/false.png',
width: 16.0,
height: 16.0),
),
),
),
Container(
margin: const EdgeInsets.only(
top: 25, left: 120),
alignment: Alignment.topCenter,
child: const Text(
'Edit Profile',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
fontFamily: "PlayfairDisplay"),
),
),
Container(
margin: const EdgeInsets.only(
top: 25, left: 80),
alignment: Alignment.topRight,
child: SizedBox(
width: 60, // <-- Your width
height: 25, // <-- Your height
child: ElevatedButton(
style: ElevatedButton.styleFrom(
side: const BorderSide(
color: Colors.black),
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(
5.0)),
backgroundColor: Colors
.white, // Background color
),
child: const Text(
'SAVE',
style: TextStyle(
fontSize: 7,
fontWeight: FontWeight.w500,
color: Colors.black),
),
onPressed: () {},
))
// child: IconButton(
// icon: const Icon(
// // <-- Icon
// Icons.arrow_back_ios,
// color:
// Color.fromARGB(255, 204, 192, 192),
// size: 15.0,
// ),
// onPressed: () {},
// ),
),
],
),
Container(
margin: const EdgeInsets.only(
top: 10,
),
width: 100.0,
height: 1.0,
color: Colors.black,
),
Center(
child: Container(
margin: const EdgeInsets.only(
top: 40, bottom: 12),
width: 70.0,
height: 70.0,
decoration: const BoxDecoration(
shape: BoxShape.circle,
),
child: ClipOval(
child: image != null
? Image.file(
image!,
width: 100,
height: 100,
fit: BoxFit.cover,
)
: Image.asset(
'assets/images/user.png',
width: 100,
height: 100,
fit: BoxFit.cover,
),
),
),
),
// Container(
// height: 70, width: 70,
// margin:
// const EdgeInsets.only(top: 20, left: 20),
// // Border width
// decoration: const BoxDecoration(
// color: Colors.black,
// shape: BoxShape.circle),
// child: ClipOval(
// child: image != null
// ? Image.file(
// image!,
// width: 100,
// height: 100,
// fit: BoxFit.cover,
// )
// : Image.asset(
// 'assets/images/user.png',
// width: 100,
// height: 100,
// fit: BoxFit.cover,
// ),
// ),
// ),
InkWell(
child: const Text(
'CHANGE PROFILE PHOTO',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 10,
fontWeight: FontWeight.w700,
),
),
onTap: () {
pickImage();
}),
Container(
margin:
const EdgeInsets.only(top: 40, left: 35.0),
child: const Text(
'NAME',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w400,
fontFamily: "PlayfairDisplay"),
),
),
Container(
margin: const EdgeInsets.only(
left: 35.0, right: 35),
child: const TextField(
textAlign: TextAlign.start,
),
)
])
// child: Row(
// children: <Widget>[
// Container(
// margin: const EdgeInsets.only(top: 10, left: 5),
// alignment: Alignment.topLeft,
// child: IconButton(
// icon: const Icon(
// // <-- Icon
// Icons.arrow_back_ios,
// color: Color.fromARGB(255, 204, 192, 192),
// size: 15.0,
// ),
// onPressed: () {},
// ),
// ),
// Container(
// margin:
// const EdgeInsets.only(top: 25, left: 90),
// alignment: Alignment.topCenter,
// child: const Text(
// 'Edit Profile',
// textAlign: TextAlign.center,
// style: TextStyle(
// fontSize: 14,
// fontWeight: FontWeight.w500,
// ),
// ),
// ),
// Container(
// margin:
// const EdgeInsets.only(top: 10, left: 110),
// alignment: Alignment.topRight,
// child: IconButton(
// icon: const Icon(
// // <-- Icon
// Icons.arrow_back_ios,
// color: Color.fromARGB(255, 204, 192, 192),
// size: 15.0,
// ),
// onPressed: () {},
// ),
// ),
// ],
// ),
),
);
},
)),
// image != null
// ? Image.file(image!)
// : const Text("No image selected")
],
),
));
}
}
| 0
|
mirrored_repositories/News_App_In_Flutter/lib
|
mirrored_repositories/News_App_In_Flutter/lib/components/mytopic.dart
|
// ignore_for_file: unnecessary_new, non_constant_identifier_names, file_names, prefer_typing_uninitialized_variables
import 'package:flutter/material.dart';
import 'package:rk_news/components/profile_change.dart';
void main() => runApp(const Mytopic());
class Mytopic extends StatelessWidget {
const Mytopic({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
scaffoldBackgroundColor: const Color(0xFFF5F5F5),
appBarTheme: const AppBarTheme(
backgroundColor: Color(0xFFF5F5F5),
elevation: 0, // This removes the shadow from all App Bars.
)),
debugShowCheckedModeBanner: false,
home: const MyNavigationBar(),
);
}
}
class MyNavigationBar extends StatefulWidget {
const MyNavigationBar({super.key});
@override
// ignore: library_private_types_in_public_api
_MyNavigationBarState createState() => _MyNavigationBarState();
}
class _MyNavigationBarState extends State<MyNavigationBar> {
List<Student> students = [
Student(name: "COVID-19"),
Student(name: "MENTAL HEALTH"),
Student(name: "CANADIAN POLITICS"),
Student(name: "ECONOMICS")
];
List<String> temp = [];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
toolbarHeight: 140.10, //set your height
flexibleSpace: SafeArea(
child: Container(
color: const Color(0xFFF5F5F5), // set your color
child: Column(
children: [
Row(
children: <Widget>[
Container(
margin: const EdgeInsets.only(top: 10, left: 5),
child: IconButton(
icon: const Icon(
// <-- Icon
Icons.arrow_back_ios,
color: Color.fromARGB(255, 204, 192, 192),
size: 24.0,
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Profile_change()),
);
},
),
),
Container(
margin: const EdgeInsets.only(top: 7),
child: const Text(
'BACK',
textAlign: TextAlign.left,
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w800,
),
),
),
],
),
Container(
alignment: Alignment.centerLeft,
margin: const EdgeInsets.only(top: 10, left: 20.0),
child: const Text(
'My Topics',
textAlign: TextAlign.start,
style: TextStyle(
fontSize: 33,
fontWeight: FontWeight.w300,
fontFamily: "PlayfairDisplay"),
),
),
Container(
margin: const EdgeInsets.only(
top: 3,
),
width: 350.0,
height: 3.0,
color: Colors.orange,
), // set an icon or image
// set your search bar setting
],
),
),
),
),
body: ListView.builder(
itemCount: students.length,
itemBuilder: (BuildContext ctx, index) {
return Column(children: <Widget>[
InkWell(
onTap: () {
setState(() {
if (temp.contains(students[index].name)) {
temp.remove(students[index].name);
} else {
temp.add(students[index].name);
}
});
},
child: Container(
margin: const EdgeInsets.only(
left: 20,
),
child: ListTile(
title: Text(
students[index].name,
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.w400,
),
),
trailing: SizedBox(
height: 30,
width: 50,
child: Center(
child: temp.contains(students[index].name)
? Image.asset(
'assets/images/plus.png',
width: 20,
height: 20,
)
: Image.asset(
'assets/images/right.png',
width: 20,
height: 20,
),
// child: Text(temp.contains(students[index].name)
// ? 'remove'
// : "Add")
),
),
))),
Container(
margin: const EdgeInsets.only(
top: 10,
),
width: 350.0,
height: 1.0,
color: const Color.fromARGB(255, 173, 143, 143),
),
]);
}),
);
}
}
class Student {
String name;
Student({required this.name});
}
| 0
|
mirrored_repositories/News_App_In_Flutter/lib
|
mirrored_repositories/News_App_In_Flutter/lib/Top_src/politics.dart
|
// ignore_for_file: library_private_types_in_public_api, file_names, depend_on_referenced_packages
import 'dart:convert';
// ignore: unused_import
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
class Politics extends StatefulWidget {
const Politics({super.key});
@override
_IndexPageState createState() => _IndexPageState();
}
class _IndexPageState extends State<Politics> {
List users = [];
bool isLoading = false;
@override
void initState() {
// ignore: todo
// TODO: implement initState
super.initState();
// ignore: unnecessary_this
this.fetchUser();
}
fetchUser() async {
setState(() {
isLoading = true;
});
var request = http.Request(
'GET',
Uri.parse(
'https://newsapi.org/v2/top-headlines?country=us&category=politics&apiKey=7269b488b8f84ff1ac8575ba0ac4df67'));
// http.StreamedResponse response = await request.send();
http.StreamedResponse response = await request.send();
var res = await http.Response.fromStream(response);
// var url = "https://randomuser.me/api/?results=50";
// var response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
var items = json.decode(res.body)["articles"];
// if (kDebugMode) {
// print(items);
// }
setState(() {
users = items;
isLoading = false;
});
} else {
users = [];
isLoading = false;
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFFF5F5F5),
body: getBody(),
);
}
Widget getBody() {
// ignore: prefer_is_empty
if (users.contains(null) || users.length < 0 || isLoading) {
return const Center(child: CircularProgressIndicator());
}
return ListView.builder(
itemCount: users.length,
itemBuilder: (BuildContext ctx, index) {
// return ListTile(
// leading: Image.network(
// users[index]["urlToImage"],
// width: 150,
// fit: BoxFit.cover,
// ),
// title: Text(users[index]['title']),
// subtitle: Text(users[index]["author"]));
return SizedBox(
height: 340,
width: 200,
child: Card(
margin: const EdgeInsets.all(20),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
margin: const EdgeInsets.only(top: 10),
alignment: Alignment.center,
child: ClipRRect(
borderRadius:
BorderRadius.circular(6), // Image border
// Image radius
child: Image.network(
users[index]["urlToImage"] ??
'https://images.indianexpress.com/2022/10/liz-truss-6.jpg?w=475',
cacheHeight: 140,
cacheWidth: 300,
alignment: Alignment.topCenter,
),
)),
Container(
margin: const EdgeInsets.only(top: 10.0, left: 11),
width: 130,
height: 15,
child: Text(
users[index]["source"]["name"] ?? 'CNN',
style: const TextStyle(
fontSize: 13,
fontWeight: FontWeight.w700,
),
),
),
Container(
margin: const EdgeInsets.only(top: 10),
child: Row(
children: [
Container(
margin: const EdgeInsets.only(left: 11),
width: 40,
height: 15,
child: Text(
users[index]["author"] ?? 'jacob',
style: const TextStyle(
fontSize: 13,
fontWeight: FontWeight.w700,
),
),
),
Container(
margin: const EdgeInsets.only(left: 11),
width: 130,
height: 15,
child: Text(
users[index]['title'] ?? 'Suspension cancel',
style: const TextStyle(
fontSize: 13,
fontWeight: FontWeight.w700,
),
),
),
],
),
),
Container(
margin: const EdgeInsets.only(left: 11, top: 10),
alignment: Alignment.center,
width: 250,
height: 40,
child: Text(
users[index]["description"] ??
'Liz Truss Resigns Live Updates: British Prime Minister Liz Truss today dramatically announced her resignation just six weeks after taking office.',
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
),
),
),
],
),
],
),
),
),
);
});
}
}
| 0
|
mirrored_repositories/News_App_In_Flutter/lib
|
mirrored_repositories/News_App_In_Flutter/lib/Top_src/business.dart
|
// ignore_for_file: library_private_types_in_public_api, file_names, depend_on_referenced_packages, camel_case_types
import 'dart:convert';
// ignore: unused_import
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
class business extends StatefulWidget {
const business({super.key});
@override
_IndexPageState createState() => _IndexPageState();
}
class _IndexPageState extends State<business> {
List users = [];
bool isLoading = false;
@override
void initState() {
// ignore: todo
// TODO: implement initState
super.initState();
// ignore: unnecessary_this
this.fetchUser();
}
fetchUser() async {
setState(() {
isLoading = true;
});
var request = http.Request(
'GET',
Uri.parse(
'https://newsapi.org/v2/top-headlines?country=us&category=business&apiKey=7269b488b8f84ff1ac8575ba0ac4df67'));
// http.StreamedResponse response = await request.send();
http.StreamedResponse response = await request.send();
var res = await http.Response.fromStream(response);
// var url = "https://randomuser.me/api/?results=50";
// var response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
var items = json.decode(res.body)["articles"];
// if (kDebugMode) {
// print(items);
// }
setState(() {
users = items;
isLoading = false;
});
} else {
users = [];
isLoading = false;
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFFF5F5F5),
body: getBody(),
);
}
Widget getBody() {
// ignore: prefer_is_empty
if (users.contains(null) || users.length < 0 || isLoading) {
return const Center(child: CircularProgressIndicator());
}
return ListView.builder(
itemCount: users.length,
itemBuilder: (BuildContext ctx, index) {
// return ListTile(
// leading: Image.network(
// users[index]["urlToImage"],
// width: 150,
// fit: BoxFit.cover,
// ),
// title: Text(users[index]['title']),
// subtitle: Text(users[index]["author"]));
return SizedBox(
height: 340,
width: 200,
child: Card(
margin: const EdgeInsets.all(20),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
margin: const EdgeInsets.only(top: 10),
alignment: Alignment.center,
child: ClipRRect(
borderRadius:
BorderRadius.circular(6), // Image border
// Image radius
child: Image.network(
users[index]["urlToImage"] ??
'https://images.indianexpress.com/2022/10/liz-truss-6.jpg?w=475',
cacheHeight: 140,
cacheWidth: 300,
alignment: Alignment.topCenter,
),
)),
Container(
margin: const EdgeInsets.only(top: 10.0, left: 11),
width: 130,
height: 15,
child: Text(
users[index]["source"]["name"] ?? 'CNN',
style: const TextStyle(
fontSize: 13,
fontWeight: FontWeight.w700,
),
),
),
Container(
margin: const EdgeInsets.only(top: 10),
child: Row(
children: [
Container(
margin: const EdgeInsets.only(left: 11),
width: 40,
height: 15,
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10.0),
bottomLeft: Radius.circular(10.0),
topRight: Radius.circular(10.0),
bottomRight: Radius.circular(10.0)),
color: Color.fromARGB(255, 8, 87, 151),
),
child: Text(
users[index]["author"] ?? 'CNN',
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 13,
fontWeight: FontWeight.w400,
color: Colors.white),
),
),
Container(
margin: const EdgeInsets.only(left: 11),
width: 130,
height: 18,
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10.0),
bottomLeft: Radius.circular(10.0),
topRight: Radius.circular(10.0),
bottomRight: Radius.circular(10.0)),
color: Colors.black,
),
// ignore: sort_child_properties_last
child: Text(
users[index]['title'] ?? 'CNN',
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 13,
fontWeight: FontWeight.w400,
color: Colors.white),
),
),
],
),
),
Container(
margin: const EdgeInsets.only(left: 11, top: 20),
alignment: Alignment.center,
width: 250,
height: 40,
child: Text(
users[index]["description"] ??
'Liz Truss Resigns Live Updates: British Prime Minister Liz Truss today dramatically announced her resignation just six weeks after taking office.',
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
),
),
),
// Container(
// width: 250,
// height: 40,
// decoration: const BoxDecoration(
// borderRadius: BorderRadius.only(
// topLeft: Radius.circular(10.0),
// bottomLeft: Radius.circular(10.0),
// topRight: Radius.circular(10.0),
// bottomRight: Radius.circular(10.0)),
// color: Colors.green,
// ),
// child: const Text(
// 'This is a Container',
// textScaleFactor: 2,
// style: TextStyle(color: Colors.black),
// )),
],
),
],
),
),
),
);
});
}
}
| 0
|
mirrored_repositories/News_App_In_Flutter/lib
|
mirrored_repositories/News_App_In_Flutter/lib/Top_src/sports.dart
|
// ignore_for_file: library_private_types_in_public_api, file_names, depend_on_referenced_packages
import 'dart:convert';
// ignore: unused_import
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
class Sports extends StatefulWidget {
const Sports({super.key});
@override
_IndexPageState createState() => _IndexPageState();
}
class _IndexPageState extends State<Sports> {
List users = [];
bool isLoading = false;
@override
void initState() {
// ignore: todo
// TODO: implement initState
super.initState();
// ignore: unnecessary_this
this.fetchUser();
}
fetchUser() async {
setState(() {
isLoading = true;
});
var request = http.Request(
'GET',
Uri.parse(
'https://newsapi.org/v2/top-headlines?country=us&category=sports&apiKey=7269b488b8f84ff1ac8575ba0ac4df67'));
// http.StreamedResponse response = await request.send();
http.StreamedResponse response = await request.send();
var res = await http.Response.fromStream(response);
// var url = "https://randomuser.me/api/?results=50";
// var response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
var items = json.decode(res.body)["articles"];
// if (kDebugMode) {
// print(items);
// }
setState(() {
users = items;
isLoading = false;
});
} else {
users = [];
isLoading = false;
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFFF5F5F5),
body: getBody(),
);
}
Widget getBody() {
// ignore: prefer_is_empty
if (users.contains(null) || users.length < 0 || isLoading) {
return const Center(child: CircularProgressIndicator());
}
return ListView.builder(
itemCount: users.length,
itemBuilder: (BuildContext ctx, index) {
// return ListTile(
// leading: Image.network(
// users[index]["urlToImage"],
// width: 150,
// fit: BoxFit.cover,
// ),
// title: Text(users[index]['title']),
// subtitle: Text(users[index]["author"]));
return SizedBox(
height: 340,
width: 200,
child: Card(
margin: const EdgeInsets.all(20),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
margin: const EdgeInsets.only(top: 10),
alignment: Alignment.center,
child: ClipRRect(
borderRadius:
BorderRadius.circular(6), // Image border
// Image radius
child: Image.network(
users[index]["urlToImage"] ??
'https://images.indianexpress.com/2022/10/liz-truss-6.jpg?w=475',
cacheHeight: 140,
cacheWidth: 300,
alignment: Alignment.topCenter,
),
)),
Container(
margin: const EdgeInsets.only(top: 10.0, left: 11),
width: 130,
height: 15,
child: Text(
users[index]["source"]["name"],
style: const TextStyle(
fontSize: 13,
fontWeight: FontWeight.w700,
),
),
),
Container(
margin: const EdgeInsets.only(top: 10),
child: Row(
children: [
Container(
margin: const EdgeInsets.only(left: 11),
width: 40,
height: 15,
child: Text(
users[index]["author"] ?? 'CNN' ?? 'CNN',
style: const TextStyle(
fontSize: 13,
fontWeight: FontWeight.w700,
),
),
),
Container(
margin: const EdgeInsets.only(left: 11),
width: 130,
height: 15,
child: Text(
users[index]['title'] ?? 'CNN',
style: const TextStyle(
fontSize: 13,
fontWeight: FontWeight.w700,
),
),
),
],
),
),
Container(
margin: const EdgeInsets.only(top: 10.0, left: 11),
alignment: Alignment.center,
width: 250,
height: 40,
child: Text(
users[index]["description"] ??
'Liz Truss Resigns Live Updates: British Prime Minister Liz Truss today dramatically announced her resignation just six weeks after taking office.',
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
),
),
),
],
),
],
),
),
),
);
});
}
}
| 0
|
mirrored_repositories/News_App_In_Flutter/lib
|
mirrored_repositories/News_App_In_Flutter/lib/bottom_tab/page3.dart
|
// ignore_for_file: unnecessary_new, avoid_print, library_private_types_in_public_api
import 'package:flutter/material.dart';
import 'package:rk_news/bargraph.dart';
import 'package:rk_news/components/Bias.dart';
import 'package:rk_news/components/profile_change.dart';
void main() => runApp(Page3());
/// This Widget is the main application widget.
// ignore: use_key_in_widget_constructors
class Page3 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
debugShowCheckedModeBanner: false,
home: MyNavigationBar(),
);
}
}
class MyNavigationBar extends StatefulWidget {
const MyNavigationBar({super.key});
@override
_MyNavigationBarState createState() => _MyNavigationBarState();
}
class _MyNavigationBarState extends State<MyNavigationBar> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFFF5F5F5),
body: ListView(children: <Widget>[
SizedBox(
height: 170,
width: 200,
child: Card(
elevation: 15,
color: Colors.white,
margin: const EdgeInsets.all(20),
child: Padding(
padding: const EdgeInsets.all(0.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
children: [
Container(
height: 70, width: 70,
margin: const EdgeInsets.only(top: 20, left: 20),
// Border width
decoration: const BoxDecoration(
color: Colors.black, shape: BoxShape.circle),
child: ClipOval(
child: SizedBox.fromSize(
size: const Size.fromRadius(48), // Image radius
child: Image.asset(
'assets/images/user.png',
height: 80.0,
alignment: Alignment.center,
),
),
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
margin: const EdgeInsets.only(left: 30, top: 15),
child: const Text(
'JOHN SMITH',
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.w700,
fontFamily: "PlayfairDisplay"),
),
),
Container(
margin: const EdgeInsets.only(left: 30, top: 5),
child: const Text(
'MEMBER SINCE 5 MAY 2022',
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w700,
color: Color.fromARGB(255, 204, 192, 192)),
),
),
],
),
Container(
margin: const EdgeInsets.only(top: 10, left: 20),
child: new IconButton(
icon: const Icon(
// <-- Icon
Icons.arrow_forward_ios,
color: Color.fromARGB(255, 204, 192, 192),
size: 15.0,
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Profile_change()),
);
},
),
),
],
)
],
),
),
),
),
SizedBox(
height: 350,
width: 200,
child: Card(
elevation: 15,
color: Colors.white,
margin: const EdgeInsets.all(20),
child: Padding(
padding: const EdgeInsetsDirectional.fromSTEB(16, 0, 16, 8),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Row(
children: [
Container(
margin: const EdgeInsets.only(top: 15, left: 10),
alignment: Alignment.topRight,
child: const Icon(
// <-- Icon
Icons.balance,
size: 20.0,
),
),
Container(
margin: const EdgeInsets.only(left: 10, top: 15),
child: const Text(
'BIAS BREAKDOWN',
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w700,
),
),
),
Container(
margin: const EdgeInsets.only(top: 10, left: 130),
child: new IconButton(
icon: const Icon(
// <-- Icon
Icons.arrow_forward_ios,
color: Color.fromARGB(255, 204, 192, 192),
size: 15.0,
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Bias()),
);
},
),
),
// new Container(
// margin: const EdgeInsets.only(top: 10, left: 170),
// child: new IconButton(
// icon: const Icon(
// // <-- Icon
// Icons.arrow_forward_ios,
// color: Color.fromARGB(255, 204, 192, 192),
// size: 15.0,
// ),
// onPressed: () {/* Your code */},
// ),
// )
],
),
const Expanded(
child:
Bargraph(left: 50.00, right: 110.00, center: 150.00),
)
],
),
),
),
),
SizedBox(
height: 350,
width: 200,
child: Card(
elevation: 15,
color: Colors.white,
margin: const EdgeInsets.all(20),
child: Padding(
padding: const EdgeInsets.all(0.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
children: [
Container(
margin: const EdgeInsets.only(top: 10, left: 10),
child: Image.asset(
'assets/images/news.png',
height: 30.0,
),
),
Container(
margin: const EdgeInsets.only(left: 10, top: 15),
child: const Text(
'TOP PUBLICATIONS',
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w700,
),
),
),
Container(
margin: const EdgeInsets.only(top: 10, left: 180),
alignment: Alignment.topRight,
child: const Icon(
// <-- Icon
Icons.arrow_forward_ios,
color: Color.fromARGB(255, 204, 192, 192),
size: 15.0,
),
),
],
),
Expanded(
child: Column(
children: <Widget>[
Container(
alignment: Alignment.center,
margin: const EdgeInsets.only(
top: 60,
),
child: Image.network(
"https://www.parsintl.com/wp-content/uploads/2022/01/NYT-logo.jpg",
width: 210.0,
alignment: Alignment.center,
),
),
Row(
children: [
Container(
margin: const EdgeInsets.only(
left: 120,
top: 7,
),
child: Image.network(
"https://upload.wikimedia.org/wikipedia/commons/thumb/6/67/CBC_Logo_1992-Present.svg/1200px-CBC_Logo_1992-Present.svg.png",
height: 30.0,
width: 30.0,
alignment: Alignment.topRight,
),
),
Container(
margin: const EdgeInsets.only(top: 7, left: 10),
child: const Text(
'CBC',
style: TextStyle(
fontSize: 35,
fontWeight: FontWeight.w900,
),
),
),
],
),
],
),
)
],
),
),
),
),
SizedBox(
height: 350,
width: 200,
child: Card(
elevation: 15,
color: Colors.white,
margin: const EdgeInsets.all(20),
child: Padding(
padding: const EdgeInsets.all(0.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
children: [
Container(
margin: const EdgeInsets.only(
left: 10,
top: 12,
),
child: Image.asset(
'assets/images/category.png',
height: 20.0,
),
),
Container(
margin: const EdgeInsets.only(left: 10, top: 15),
child: const Text(
'TOP CATEGORIES',
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w700,
),
),
),
Container(
margin: const EdgeInsets.only(top: 10, left: 180),
alignment: Alignment.topRight,
child: const Icon(
// <-- Icon
Icons.arrow_forward_ios,
color: Color.fromARGB(255, 204, 192, 192),
size: 15.0,
),
),
],
),
Container(
margin: const EdgeInsets.only(top: 40.0, bottom: 3.0),
alignment: Alignment.center,
),
Expanded(
child: Column(
children: <Widget>[
new SizedBox(
width: 170.0,
height: 40.0,
child: ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.white,
elevation: 15 // Background color
),
child: Row(
mainAxisSize: MainAxisSize.min,
// ignore: prefer_const_literals_to_create_immutables
children: [
const Text('HEALTH',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w700,
color: Colors.black,
)), // <-- Text
],
),
),
),
Container(
margin:
const EdgeInsets.only(top: 30.0, bottom: 3.0),
alignment: Alignment.center,
),
SizedBox(
width: 170.0,
height: 40.0,
child: ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.white, elevation: 15),
child: Row(
mainAxisSize: MainAxisSize.min,
// ignore: prefer_const_literals_to_create_immutables
children: [
const Text('TECH',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w700,
color: Colors.black,
)), // <-- Text
],
),
),
),
Container(
margin:
const EdgeInsets.only(top: 30.0, bottom: 3.0),
alignment: Alignment.center,
),
new SizedBox(
width: 170.0,
height: 40.0,
child: ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.white,
elevation: 15 // Background color
),
child: Row(
mainAxisSize: MainAxisSize.min,
// ignore: prefer_const_literals_to_create_immutables
children: [
const Text('SCIENCE',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w700,
color: Colors.black,
)), // <-- Text
],
),
),
),
],
),
)
],
),
),
),
),
SizedBox(
height: 170,
width: 200,
child: Card(
elevation: 15,
color: Colors.white,
margin: const EdgeInsets.all(20),
child: Padding(
padding: const EdgeInsets.all(0.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
children: [
Container(
margin: const EdgeInsets.only(
left: 10,
top: 12,
),
child: Image.asset(
'assets/images/time.png',
height: 25.0,
),
),
Container(
margin: const EdgeInsets.only(left: 10, top: 10),
child: const Text(
'RECENTLY VIEWED',
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w700,
),
),
),
Container(
margin: const EdgeInsets.only(top: 10, left: 180),
alignment: Alignment.topRight,
child: const Icon(
// <-- Icon
Icons.arrow_forward_ios,
color: Color.fromARGB(255, 204, 192, 192),
size: 15.0,
),
),
],
),
Expanded(
child: Row(
children: <Widget>[
Container(
margin:
const EdgeInsets.only(left: 20.0, bottom: 3.0),
alignment: Alignment.center,
),
new SizedBox(
width: 60.0,
height: 25.0,
child: ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
// Background color
),
child: Row(
mainAxisSize: MainAxisSize.min,
// ignore: prefer_const_literals_to_create_immutables
children: [
const Text('LEFT',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w700,
color: Colors.black,
)), // <-- Text
],
),
),
),
Container(
margin: const EdgeInsets.only(
left: 20.0,
),
alignment: Alignment.center,
),
SizedBox(
width: 70.0,
height: 25.0,
child: ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFFA1A1A1),
),
child: Row(
mainAxisSize: MainAxisSize.min,
// ignore: prefer_const_literals_to_create_immutables
children: [
const Text('RIGHT',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w700,
color: Colors.black,
)), // <-- Text
],
),
),
),
Container(
margin: const EdgeInsets.only(
left: 10.0,
),
alignment: Alignment.center,
),
SizedBox(
width: 80.0,
height: 25.0,
child: ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFFA1A1A1),
),
child: Row(
mainAxisSize: MainAxisSize.min,
// ignore: prefer_const_literals_to_create_immutables
children: [
const Text('CENTER',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w700,
color: Colors.black,
)), // <-- Text
],
),
),
),
Container(
margin:
const EdgeInsets.only(left: 10.0, bottom: 3.0),
alignment: Alignment.center,
),
new SizedBox(
width: 60.0,
height: 25.0,
child: ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFFA1A1A1),
// Background color
),
child: Row(
mainAxisSize: MainAxisSize.min,
// ignore: prefer_const_literals_to_create_immutables
children: [
const Text('HE',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w700,
color: Colors.black,
)), // <-- Text
],
),
),
),
],
),
)
],
),
),
),
),
]));
}
}
| 0
|
mirrored_repositories/News_App_In_Flutter/lib
|
mirrored_repositories/News_App_In_Flutter/lib/bottom_tab/page1.dart
|
// ignore_for_file: unnecessary_new, avoid_print, library_private_types_in_public_api
import 'package:flutter/material.dart';
import 'package:rk_news/Top_src/business.dart';
import 'package:rk_news/Top_src/politics.dart';
import 'package:rk_news/Top_src/sports.dart';
void main() => runApp(Page1());
/// This Widget is the main application widget.
// ignore: use_key_in_widget_constructors
class Page1 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
debugShowCheckedModeBanner: false,
home: MyNavigationBar(),
);
}
}
class MyNavigationBar extends StatefulWidget {
const MyNavigationBar({super.key});
@override
_MyNavigationBarState createState() => _MyNavigationBarState();
}
// const upperTab = TabBar(tabs: <Tab>[
// Tab(
// child: Align(
// alignment: Alignment.center,
// child: Text("Business", style: TextStyle(color: Colors.black)))),
// Tab(
// child: Align(
// alignment: Alignment.center,
// child: Text("Politics", style: TextStyle(color: Colors.black)))),
// Tab(
// child: Align(
// alignment: Alignment.center,
// child: SelectableText(
// "Sports",
// ))),
// ]);
const up = TabBar(
labelColor: Colors.green,
unselectedLabelColor: Colors.black,
tabs: [
Tab(text: 'Business'),
Tab(text: 'Politics'),
Tab(text: 'Sports'),
],
);
class _MyNavigationBarState extends State<MyNavigationBar> {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: DefaultTabController(
length: 3,
child: Scaffold(
appBar: AppBar(
toolbarHeight: 0,
bottom: up,
backgroundColor: const Color(0xFFF5F5F5),
),
body: const TabBarView(
children: [business(), Politics(), Sports()],
),
),
),
);
}
}
| 0
|
mirrored_repositories/News_App_In_Flutter/lib
|
mirrored_repositories/News_App_In_Flutter/lib/bottom_tab/page2.dart
|
// ignore_for_file: unnecessary_new, avoid_print, library_private_types_in_public_api
import 'package:flutter/material.dart';
void main() => runApp(Page2());
/// This Widget is the main application widget.
// ignore: use_key_in_widget_constructors
class Page2 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
appBarTheme: const AppBarTheme(
elevation: 0, // This removes the shadow from all App Bars.
)),
debugShowCheckedModeBanner: false,
home: const MyNavigationBar(),
);
}
}
const up = TabBar(
isScrollable: true,
labelColor: Colors.green,
unselectedLabelColor: Colors.black,
tabs: [
Tab(text: 'World'),
Tab(text: 'Tech'),
Tab(text: 'Health'),
Tab(text: 'Business'),
Tab(text: 'Politics'),
Tab(text: 'Sports'),
Tab(text: 'Business'),
Tab(text: 'Politics'),
Tab(text: 'Sports'),
],
);
class MyNavigationBar extends StatefulWidget {
const MyNavigationBar({super.key});
@override
_MyNavigationBarState createState() => _MyNavigationBarState();
}
class _MyNavigationBarState extends State<MyNavigationBar> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFFF5F5F5),
appBar: AppBar(
backgroundColor: const Color(0xFFF5F5F5),
toolbarHeight: 0,
bottom: AppBar(
backgroundColor: const Color(0xFFF5F5F5),
title: const SizedBox(
width: double.infinity,
height: 40,
child: Center(
child: TextField(
decoration: InputDecoration(
labelText: 'SEARCH ...',
labelStyle: TextStyle(
color: Color.fromARGB(255, 207, 201, 201),
fontSize: 10,
),
prefixIcon: Icon(Icons.search),
),
),
),
),
),
),
body: ListView(children: <Widget>[
const DefaultTabController(length: 9, child: up),
SizedBox(
height: 150,
width: 200,
child: Card(
color: const Color.fromARGB(255, 20, 204, 26),
margin: const EdgeInsets.all(20),
child: Padding(
padding: const EdgeInsets.all(0.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
margin: const EdgeInsets.only(top: 6, right: 6),
alignment: Alignment.topRight,
child: const Icon(
// <-- Icon
Icons.add, color: Colors.white,
size: 20.0,
),
),
Container(
margin: const EdgeInsets.only(top: 60, left: 10),
child: const Text(
'COVID-19',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
color: Colors.white),
),
),
],
),
],
),
),
),
),
SizedBox(
height: 150,
width: 200,
child: Card(
color: const Color.fromARGB(255, 10, 69, 117),
margin: const EdgeInsets.all(20),
child: Padding(
padding: const EdgeInsets.all(0.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
margin: const EdgeInsets.only(top: 6, right: 6),
alignment: Alignment.topRight,
child: const Icon(
// <-- Icon
Icons.add, color: Colors.white,
size: 20.0,
),
),
Container(
margin: const EdgeInsets.only(top: 60, left: 10),
child: const Text(
'FUTURE OF FOOD',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
color: Colors.white),
),
),
],
),
],
),
),
),
),
SizedBox(
height: 150,
width: 200,
child: Card(
color: Colors.lightBlue,
margin: const EdgeInsets.all(20),
child: Padding(
padding: const EdgeInsets.all(0.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
margin: const EdgeInsets.only(top: 6, right: 6),
alignment: Alignment.topRight,
child: const Icon(
// <-- Icon
Icons.add, color: Colors.white,
size: 20.0,
),
),
Container(
margin: const EdgeInsets.only(top: 60, left: 10),
child: const Text(
'MENTAL HEALTH',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
color: Colors.white),
),
),
],
),
],
),
),
),
),
SizedBox(
height: 150,
width: 200,
child: Card(
color: Colors.pink,
margin: const EdgeInsets.all(20),
child: Padding(
padding: const EdgeInsets.all(0.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
margin: const EdgeInsets.only(top: 6, right: 6),
alignment: Alignment.topRight,
child: const Icon(
// <-- Icon
Icons.add, color: Colors.white,
size: 20.0,
),
),
Container(
margin: const EdgeInsets.only(top: 60, left: 10),
child: const Text(
'HEALTH ISSUES',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
color: Colors.white),
),
),
],
),
],
),
),
),
)
]));
}
}
| 0
|
mirrored_repositories/News_App_In_Flutter/lib
|
mirrored_repositories/News_App_In_Flutter/lib/bottom_tab/page4.dart
|
// ignore_for_file: unnecessary_new, avoid_print, library_private_types_in_public_api, unnecessary_const
import 'package:flutter/material.dart';
void main() => runApp(Page4());
/// This Widget is the main application widget.
// ignore: use_key_in_widget_constructors
class Page4 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
debugShowCheckedModeBanner: false,
home: MyNavigationBar(),
);
}
}
class MyNavigationBar extends StatefulWidget {
const MyNavigationBar({super.key});
@override
_MyNavigationBarState createState() => _MyNavigationBarState();
}
class _MyNavigationBarState extends State<MyNavigationBar> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFFF5F5F5),
body: Center(
child: ListView(children: <Widget>[
Container(
margin: const EdgeInsets.only(left: 10),
child: Image.asset(
'assets/images/scr1.png',
height: 250,
width: 200,
),
),
Container(
height: 35,
margin: const EdgeInsets.only(),
padding: const EdgeInsets.fromLTRB(110, 0, 110, 0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor:
const Color.fromARGB(255, 37, 96, 197), // Background color
),
child: const Text(
'CONTINUE WITH GOOGLE',
style: TextStyle(
fontSize: 10,
fontWeight: FontWeight.w700,
color: Colors.white,
),
),
onPressed: () {},
)),
Container(
height: 35,
margin: const EdgeInsets.only(top: 10.0),
padding: const EdgeInsets.fromLTRB(110, 0, 110, 0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.black, // Background color
),
child: const Text(
'CONTINUE WITH APPLE',
style: TextStyle(
fontSize: 10,
fontWeight: FontWeight.w700,
color: Colors.white,
),
),
onPressed: () {},
)),
Container(
margin: const EdgeInsets.only(top: 180, left: 35, right: 20),
child: const Text(
'BY CONTINUING ,YOUR ARE AGREE TO OUR TEAMS AND CONDITIONS ',
style: TextStyle(
fontSize: 10,
fontWeight: FontWeight.w700,
),
),
),
Container(
margin: const EdgeInsets.only(left: 110),
child: const Text(
'AND UNDERSTAND PRIVATE POLICY',
style: TextStyle(
fontSize: 10,
fontWeight: FontWeight.w700,
),
),
)
])),
);
}
}
| 0
|
mirrored_repositories/News_App_In_Flutter
|
mirrored_repositories/News_App_In_Flutter/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:rk_news/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(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/QuizzlerCons
|
mirrored_repositories/QuizzlerCons/lib/Question.dart
|
class Question {
String questionText;
bool questionAns;
Question(this.questionText,this.questionAns);
}
| 0
|
mirrored_repositories/QuizzlerCons
|
mirrored_repositories/QuizzlerCons/lib/quiz_brain.dart
|
import 'Question.dart';
class QuizBrain {
int _questionNumber = 0;
final List<Question> _questionBank = [
Question('Some cats are actually allergic to humans', true),
Question('You can lead a cow down stairs but not up stairs.', false),
Question('Approximately one quarter of human bones are in the feet.', true),
Question('A slug\'s blood is green.', true),
Question('Buzz Aldrin\'s mother\'s maiden name was \"Moon\".', true),
Question('It is illegal to pee in the Ocean in Portugal.', true),
Question('No piece of square dry paper can be folded in half more than 7 times.', false),
Question(
'In London, UK, if you happen to die in the House of Parliament, you are technically entitled to a state funeral, because the building is considered too sacred a place.',
true),
Question(
'The loudest sound produced by any animal is 188 decibels. That animal is the African Elephant.',
false),
Question(
'The total surface area of two human lungs is approximately 70 square metres.',
true),
Question('Google was originally called \"Backrub\".', true),
Question(
'Chocolate affects a dog\'s heart and nervous system; a few ounces are enough to kill a small dog.',
true),
Question(
'In West Virginia, USA, if you accidentally hit an animal with your car, you are free to take it home to eat.',
true)
];
void nextQuestion(){
if(_questionNumber<_questionBank.length-1)
_questionNumber++;
else{
}
}
String getQuestionText(){
return _questionBank[_questionNumber].questionText;
}
bool getCorrectAnswer(){
return _questionBank[_questionNumber].questionAns;
}
bool isFinished(){
return _questionNumber==_questionBank.length-1;
}
void reset(){
_questionNumber=0;
}
}
| 0
|
mirrored_repositories/QuizzlerCons
|
mirrored_repositories/QuizzlerCons/lib/main.dart
|
import 'package:flutter/material.dart';
import 'package:rflutter_alert/rflutter_alert.dart';
import 'quiz_brain.dart';
import 'package:audioplayers/src/audio_cache.dart';
QuizBrain quizBrain = QuizBrain();
void main() => runApp(Quizzler());
class Quizzler extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
title: Text('Quizzler',style: TextStyle(fontSize: 20,fontFamily: 'Aclonica'),),
actions: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Icon(Icons.volume_up_outlined,color: Colors.white38,size: 35,),
),
],
backgroundColor: Colors.teal,
shadowColor: Colors.greenAccent,
elevation: 10,
),
backgroundColor: Colors.grey.shade900,
body: SafeArea(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 10.0),
child: QuizPage(),
),
),
),
);
}
}
class QuizPage extends StatefulWidget {
@override
_QuizPageState createState() => _QuizPageState();
}
class _QuizPageState extends State<QuizPage> {
List<Icon> scoreKeeper = [];
int correctAns = 0;
int questionNum = 1;
String imgString ;
String sortDesc ;
void checkAnswer(bool userPickedAnswer) {
bool correctAnswer = quizBrain.getCorrectAnswer();
setState(() {
questionNum++;
if (userPickedAnswer == correctAnswer) {
final player = AudioCache();
player.play('correct.wav');
scoreKeeper.add(Icon(
Icons.check,
color: Colors.green,
size: 25,
));
correctAns++;
} else {
final player = AudioCache();
player.play('wrong.wav');
scoreKeeper.add(Icon(
Icons.close,
color: Colors.red,
size: 25,
));
}
if (quizBrain.isFinished()) {
if(correctAns>6) {
imgString = 'images/correct.png';
sortDesc = 'Yeah!! You answered $correctAns question Correctly';
}else{
imgString = 'images/wrong.png';
sortDesc = 'Oops!! You answered only $correctAns question Correctly';
}
Alert(
context: context,
title: "Accuracy : ${((correctAns.toDouble()/13.00)*100.0).toStringAsFixed(2)}%",
desc: sortDesc,
image: Image.asset(imgString),
buttons: [
DialogButton(
child: Text(
"Play Again",
style: TextStyle(color: Colors.white, fontSize: 20),
),
onPressed: () => Navigator.pop(context),
color: Color.fromRGBO(0, 179, 134, 1.0),
radius: BorderRadius.circular(0.0),
),
],
).show();
quizBrain.reset();
scoreKeeper.clear();
correctAns=0;
questionNum=1;
}
quizBrain.nextQuestion();
});
}
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Expanded(
flex: 2,
child: Padding(
padding: EdgeInsets.only(top: 80),
child: Center(
child: Text(
'Statement Number : $questionNum',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 40,
fontFamily: 'Aclonica',
color: Colors.purple,
),
),
),
),
),
Expanded(
flex: 2,
child: Padding(
padding: EdgeInsets.only(left: 15,top: 0,right: 15,bottom: 40),
child: Center(
child: Text(
quizBrain.getQuestionText(),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 25.0,
color: Colors.white,
),
),
),
),
),
Expanded(
child: Padding(
padding: EdgeInsets.all(15.0),
child: TextButton(
style: TextButton.styleFrom(backgroundColor: Colors.green,),
child: Text(
'True',
style: TextStyle(
color: Colors.white,
fontSize: 20.0,
),
),
onPressed: () {
//The user picked true.
checkAnswer(true);
},
),
),
),
Expanded(
child: Padding(
padding: EdgeInsets.all(15.0),
child: TextButton(
style: TextButton.styleFrom(backgroundColor: Colors.red,),
child: Text(
'False',
style: TextStyle(
fontSize: 20.0,
color: Colors.white,
),
),
onPressed: () {
//The user picked false.
checkAnswer(false);
},
),
),
),
Container(
height: 30,
margin: EdgeInsets.symmetric(vertical: 10,horizontal: 5),
child: Row(
children: scoreKeeper,
),
)
],
);
}
}
/*
question1: 'You can lead a cow down stairs but not up stairs.', false,
question2: 'Approximately one quarter of human bones are in the feet.', true,
question3: 'A slug\'s blood is green.', true,
*/
| 0
|
mirrored_repositories/App_ChatGPT
|
mirrored_repositories/App_ChatGPT/lib/main.dart
|
import 'package:appchatgpt/providers/chat_provider.dart';
import 'package:appchatgpt/providers/models_provider.dart';
import 'package:provider/provider.dart';
import 'screens/chat_screen.dart';
import 'package:flutter/material.dart';
import 'constants/constants.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MultiProvider(
providers: [
ChangeNotifierProvider(
create: (_) => ModelsProvider(),
),
ChangeNotifierProvider(
create: (_) => ChatProvider(),
)
],
child: MaterialApp(
title: 'ChatGPT by Vinny',
debugShowCheckedModeBanner: false,
theme: ThemeData(
scaffoldBackgroundColor: scaffoldBackgroundColor,
appBarTheme: AppBarTheme(
color: cardColor,
)),
home: const ChatScreen(),
),
);
}
}
| 0
|
mirrored_repositories/App_ChatGPT/lib
|
mirrored_repositories/App_ChatGPT/lib/constants/api_consts.dart
|
String BASE_URL = "https://api.openai.com/v1";
String API_KEY = "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";
String REPO_URL = "https://github.com/Vinnybrunn00/App_ChatGPT";
| 0
|
mirrored_repositories/App_ChatGPT/lib
|
mirrored_repositories/App_ChatGPT/lib/constants/constants.dart
|
import 'package:flutter/material.dart';
Color scaffoldBackgroundColor = const Color(0xFF282a36);
Color cardColor = const Color(0xFF44475a);
| 0
|
mirrored_repositories/App_ChatGPT/lib
|
mirrored_repositories/App_ChatGPT/lib/widgets/chat_widget.dart
|
// ignore_for_file: use_build_context_synchronously
import 'package:animated_text_kit/animated_text_kit.dart';
import 'package:flutter/services.dart';
import 'package:image_gallery_saver/image_gallery_saver.dart';
import 'package:provider/provider.dart';
import '../models/chat_model.dart';
import '../providers/chat_provider.dart';
import '/constants/constants.dart';
import 'text_widget.dart';
import '/services/assets_manager.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
class ChatWidget extends StatefulWidget {
const ChatWidget({super.key, required this.controller});
final ScrollController controller;
@override
State<ChatWidget> createState() => _ChatWidgetState();
}
class _ChatWidgetState extends State<ChatWidget> {
bool like = false;
bool liked = false;
@override
Widget build(BuildContext context) {
final chatProvider = Provider.of<ChatProvider>(context);
List<ChatModel> chatList = chatProvider.getChaList;
return ListView.builder(
controller: widget.controller,
itemCount: chatList.length,
itemBuilder: (context, index) {
return Column(
children: [
Material(
color: chatList[index].chatIndex == 0
? scaffoldBackgroundColor
: cardColor,
child: Padding(
padding: const EdgeInsets.all(14),
child: Column(
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
chatList[index].chatIndex == 0
? Image.asset(
AssetsManager.userImage,
width: 30,
height: 30,
)
: Image.asset(
AssetsManager.botImage,
width: 30,
height: 30,
),
const SizedBox(
width: 8,
),
Expanded(
child: index == 0
? Textwidget(
label: chatList[index].msg,
)
: chatList[index].msg.contains('http')
? Image.network(chatList[index].msg)
: DefaultTextStyle(
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize: 16),
child: AnimatedTextKit(
isRepeatingAnimation: false,
repeatForever: false,
displayFullTextOnTap: true,
totalRepeatCount: 1,
animatedTexts: [
TyperAnimatedText(
chatList[index].msg.trim(),
),
]),
),
),
chatList[index].chatIndex == 0
? const SizedBox.shrink()
: Row(
children: [
Container(
padding: const EdgeInsets.only(),
child: IconButton(
splashRadius: 15,
splashColor: const Color(0xFF00B181),
icon: Icon(
chatList[index].msg.contains('http')
? Icons.download
: Icons.copy,
color: Colors.white,
size: 19,
),
onPressed: () async {
if (chatList[index]
.msg
.contains('http')) {
ScaffoldMessenger.of(context)
.clearSnackBars();
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(
backgroundColor:
Colors.transparent,
content: Text(
'⏳ BAIXANDO...',
style: TextStyle(
color: Colors.yellow),
)));
final response = await http.get(
Uri.parse(chatList[index].msg));
final bytes = response.bodyBytes;
final result =
await ImageGallerySaver.saveImage(
bytes);
ScaffoldMessenger.of(context)
.clearSnackBars();
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(
backgroundColor:
Colors.transparent,
content: Text(
'✔ IMAGEM SALVA NA GALERIA',
style: TextStyle(
color: Colors.green),
)));
} else {
final copymsg = ClipboardData(
text: chatList[index].msg);
Clipboard.setData(copymsg);
}
},
),
)
],
),
],
),
chatList[index].chatIndex == 0
? const SizedBox.shrink()
: Row(
children: [
const SizedBox(
width: 35,
),
Material(
borderRadius: BorderRadius.circular(100),
color: chatList[index].chatIndex == 0
? scaffoldBackgroundColor
: cardColor,
child: InkWell(
borderRadius: BorderRadius.circular(100),
onTap: () {
if (liked == false) {
setState(() {
liked = true;
like = true;
});
} else {
setState(() {
liked = !liked;
});
}
},
child: Padding(
padding: const EdgeInsets.all(6.0),
child: Ink(
child: Icon(
liked == true
? like == true
? Icons.thumb_up_alt
: Icons.thumb_up_off_alt
: Icons.thumb_up_off_alt,
color: liked == true
? like == true
? const Color.fromARGB(
255, 0, 253, 152)
: Colors.white
: Colors.white,
size: 15,
),
),
),
),
),
const SizedBox(
width: 10,
),
Material(
borderRadius: BorderRadius.circular(100),
color: chatList[index].chatIndex == 0
? scaffoldBackgroundColor
: cardColor,
child: InkWell(
borderRadius: BorderRadius.circular(100),
onTap: () {
if (liked == false) {
setState(() {
liked = true;
like = false;
});
} else {
setState(() {
liked = !liked;
});
}
},
child: Padding(
padding: const EdgeInsets.all(6.0),
child: Ink(
child: Icon(
liked == true
? like == false
? Icons.thumb_down_alt
: Icons.thumb_down_off_alt
: Icons.thumb_down_off_alt,
color: liked == true
? like == false
? const Color.fromARGB(
255, 255, 0, 106)
: Colors.white
: Colors.white,
size: 15,
),
),
),
),
),
],
),
],
),
),
),
],
);
},
);
}
}
| 0
|
mirrored_repositories/App_ChatGPT/lib
|
mirrored_repositories/App_ChatGPT/lib/widgets/text_widget.dart
|
import 'package:flutter/material.dart';
class Textwidget extends StatelessWidget {
const Textwidget(
{Key? key,
required this.label,
this.fontSize = 18,
this.color,
this.fontWeight})
: super(key: key);
final String label;
final double fontSize;
final Color? color;
final FontWeight? fontWeight;
@override
Widget build(BuildContext context) {
return Text(
label,
style: TextStyle(
color: color ?? Colors.white,
fontSize: fontSize,
fontWeight: fontWeight ?? FontWeight.w500,
),
);
}
}
| 0
|
mirrored_repositories/App_ChatGPT/lib
|
mirrored_repositories/App_ChatGPT/lib/widgets/button_github.dart
|
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
import '../constants/api_consts.dart';
class ButtonGitHub extends StatefulWidget {
const ButtonGitHub({Key? key}) : super(key: key);
@override
State<ButtonGitHub> createState() => _ButtonGitHubState();
}
class _ButtonGitHubState extends State<ButtonGitHub> {
Future<void> _launchUrl() async {
if (!await launchUrl(
Uri.parse(REPO_URL),
mode: LaunchMode.externalApplication,
)) {
throw Exception('Could not launch $_launchUrl');
}
}
@override
Widget build(BuildContext context) {
return GestureDetector(
child: Container(
padding: const EdgeInsets.all(1),
margin: const EdgeInsets.only(bottom: 70),
decoration: BoxDecoration(
color: const Color.fromARGB(255, 0, 177, 129),
borderRadius: BorderRadius.circular(50)),
child: IconButton(
splashRadius: 31,
splashColor: const Color.fromARGB(255, 255, 0, 160),
icon: Image.asset('assets/images/github.png'),
onPressed: () {
try {
_launchUrl();
} catch (e) {
log('error $e');
}
},
),
),
);
}
}
| 0
|
mirrored_repositories/App_ChatGPT/lib
|
mirrored_repositories/App_ChatGPT/lib/widgets/drop_down.dart
|
import 'package:appchatgpt/constants/constants.dart';
import 'package:appchatgpt/models/models_model.dart';
import 'package:appchatgpt/providers/models_provider.dart';
import 'package:appchatgpt/widgets/text_widget.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class ModelsDrowDownWidget extends StatefulWidget {
const ModelsDrowDownWidget({super.key});
@override
State<ModelsDrowDownWidget> createState() => _ModelsDrowDownWidgetState();
}
class _ModelsDrowDownWidgetState extends State<ModelsDrowDownWidget> {
String? currentModel;
@override
Widget build(BuildContext context) {
final modelsProvider = Provider.of<ModelsProvider>(context, listen: false);
currentModel = modelsProvider.getCurrentModel;
return FutureBuilder<List<ModelsModel>>(
future: modelsProvider.getAllModels(),
builder: (context, snapshot) {
if (snapshot.hasError) {
return Center(
child: Textwidget(label: snapshot.error.toString()),
);
}
return snapshot.data == null || snapshot.data!.isEmpty
? const SizedBox.shrink()
: FittedBox(
child: DropdownButton(
dropdownColor: scaffoldBackgroundColor,
iconEnabledColor: Colors.white,
items: List<DropdownMenuItem<String>>.generate(
snapshot.data!.length,
(index) => DropdownMenuItem(
value: snapshot.data![index].id,
child: Textwidget(
label: snapshot.data![index].id,
fontSize: 16,
))),
value: currentModel,
onChanged: (value) {
setState(() {
currentModel = value.toString();
});
modelsProvider.setCurrentModel(
value.toString(),
);
},
),
);
});
}
}
| 0
|
mirrored_repositories/App_ChatGPT/lib
|
mirrored_repositories/App_ChatGPT/lib/widgets/custom_text_field.dart
|
import 'package:flutter/material.dart';
import '../constants/constants.dart';
class CustomTextField extends StatelessWidget {
const CustomTextField({
Key? key,
this.focusNode,
this.controller,
this.onSubmitted,
this.onPressed,
}) : super(key: key);
final FocusNode? focusNode;
final TextEditingController? controller;
final Function(String)? onSubmitted;
final Function()? onPressed;
@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.all(11),
child: Material(
shadowColor: Colors.cyan,
borderRadius: BorderRadius.circular(16),
color: cardColor,
child: Row(
children: [
Expanded(
child: TextField(
cursorColor: Colors.white,
obscureText: false,
autofocus: false,
focusNode: focusNode,
style: const TextStyle(color: Colors.white),
controller: controller,
onSubmitted: onSubmitted,
decoration: const InputDecoration(
contentPadding: EdgeInsets.only(left: 10),
border: InputBorder.none,
isCollapsed: true,
hintText: null,
),
),
),
IconButton(
splashColor: const Color.fromARGB(255, 255, 0, 149),
splashRadius: 15,
onPressed: onPressed,
icon: const Icon(
Icons.send_outlined,
color: Color(0xFF00B181),
size: 21,
),
)
],
),
),
);
}
}
| 0
|
mirrored_repositories/App_ChatGPT/lib
|
mirrored_repositories/App_ChatGPT/lib/models/models_model.dart
|
class ModelsModel {
final String id;
final int created;
final String root;
ModelsModel({required this.id, required this.root, required this.created});
factory ModelsModel.fromJson(Map<String, dynamic> json) => ModelsModel(
id: json['id'],
root: json['root'],
created: json['created'],
);
static List<ModelsModel> modelsFromSnapshot(List modelSnapshot) {
return modelSnapshot.map((data) => ModelsModel.fromJson(data)).toList();
}
}
| 0
|
mirrored_repositories/App_ChatGPT/lib
|
mirrored_repositories/App_ChatGPT/lib/models/chat_model.dart
|
class ChatModel {
final String msg;
final int chatIndex;
ChatModel({required this.msg, required this.chatIndex});
factory ChatModel.fromJson(Map<String, dynamic> json) => ChatModel(
msg: json['msg'],
chatIndex: json['chatIndex'],
);
}
| 0
|
mirrored_repositories/App_ChatGPT/lib
|
mirrored_repositories/App_ChatGPT/lib/services/api_mod.dart
|
import 'dart:convert';
import 'dart:developer';
import 'dart:io';
import 'package:appchatgpt/constants/api_consts.dart';
import 'package:appchatgpt/models/chat_model.dart';
import 'package:http/http.dart' as http;
class ApiMod {
// send message
static Future<List<ChatModel>> sendMessage(
{required String message, required String modelId}) async {
try {
log("modelId > $modelId");
var response = await http.post(Uri.parse("$BASE_URL/images/generations"),
headers: {
'Authorization': 'Bearer $API_KEY',
"Content-Type": "application/json"
},
body: jsonEncode(
{
"prompt": message,
"n": 1,
"size": '1024x1024',
},
));
var jsonResponse = json.decode(utf8.decode(response.bodyBytes));
if (jsonResponse['error'] != null) {
throw HttpException(jsonResponse['error']['message']);
}
List<ChatModel> chatList = [];
if (jsonResponse["data"].length > 0) {
chatList = List.generate(
jsonResponse["data"].length,
(index) => ChatModel(
msg: jsonResponse["data"][0]['url'],
chatIndex: 1,
),
);
}
return chatList;
} catch (error) {
log("error_2 'api_service.dart' > $error");
rethrow;
}
}
}
| 0
|
mirrored_repositories/App_ChatGPT/lib
|
mirrored_repositories/App_ChatGPT/lib/services/api_service.dart
|
import 'dart:convert';
import 'dart:developer';
import 'dart:io';
import 'package:appchatgpt/constants/api_consts.dart';
import 'package:appchatgpt/models/chat_model.dart';
import 'package:appchatgpt/models/models_model.dart';
import 'package:http/http.dart' as http;
class ApiService {
static Future<List<ModelsModel>> getModels() async {
try {
var response = await http.get(Uri.parse("$BASE_URL/models"),
headers: {'Authorization': 'Bearer $API_KEY'});
Map jsonResponse = jsonDecode(response.body);
if (jsonResponse['error'] != null) {
throw HttpException((jsonResponse['error']['message']));
}
List temp = [];
for (var value in jsonResponse['data']) {
temp.add(value);
}
return ModelsModel.modelsFromSnapshot(temp);
} catch (error) {
log("Erro_1 File: 'api_service.dart' > $error");
rethrow;
}
}
// send message
static Future<List<ChatModel>> sendMessage(
{required String message, required String modelId}) async {
try {
log("modelId > $modelId");
var response = await http.post(Uri.parse("$BASE_URL/chat/completions"),
headers: {
'Authorization': 'Bearer $API_KEY',
"Content-Type": "application/json"
},
body: jsonEncode(
{
"model": modelId,
"messages": [
{"role": "user", "content": message}
],
"max_tokens": 1000,
},
));
var jsonResponse = json.decode(utf8.decode(response.bodyBytes));
if (jsonResponse['error'] != null) {
throw HttpException(jsonResponse['error']['message']);
}
List<ChatModel> chatList = [];
if (jsonResponse["choices"].length > 0) {
chatList = List.generate(
jsonResponse["choices"].length,
(index) => ChatModel(
msg: jsonResponse["choices"][0]['message']['content'],
chatIndex: 1,
),
);
}
return chatList;
} catch (error) {
log("error_2 'api_service.dart' > $error");
rethrow;
}
}
}
| 0
|
mirrored_repositories/App_ChatGPT/lib
|
mirrored_repositories/App_ChatGPT/lib/services/assets_manager.dart
|
class AssetsManager {
static String imagePath = "assets/images";
static String userImage = "$imagePath/user2.png";
static String botImage = "$imagePath/logo.png";
}
| 0
|
mirrored_repositories/App_ChatGPT/lib
|
mirrored_repositories/App_ChatGPT/lib/services/services.dart
|
import 'package:appchatgpt/widgets/drop_down.dart';
import 'package:flutter/material.dart';
import '../constants/constants.dart';
import '../widgets/text_widget.dart';
class Services {
static Future<void> showModalSheet({required BuildContext context}) async {
await showModalBottomSheet(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(20))),
backgroundColor: scaffoldBackgroundColor,
context: context,
builder: (context) {
return const Padding(
padding: EdgeInsets.all(18.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(
child: Textwidget(
label: "Models",
fontSize: 16,
)),
Flexible(flex: 2, child: ModelsDrowDownWidget())
],
),
);
});
}
}
| 0
|
mirrored_repositories/App_ChatGPT/lib
|
mirrored_repositories/App_ChatGPT/lib/screens/chat_screen.dart
|
import 'dart:developer';
import 'package:appchatgpt/screens/chat_mod.dart';
import 'package:appchatgpt/widgets/button_github.dart';
import 'package:appchatgpt/widgets/custom_text_field.dart';
import 'package:appchatgpt/widgets/text_widget.dart';
import 'package:provider/provider.dart';
import '../providers/chat_provider.dart';
import '../providers/models_provider.dart';
import '../services/services.dart';
import '/widgets/chat_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
class ChatScreen extends StatefulWidget {
const ChatScreen({super.key});
@override
State<ChatScreen> createState() => _ChatScreenState();
}
class _ChatScreenState extends State<ChatScreen> {
bool _isTyping = false;
late TextEditingController textEditingController;
late ScrollController _listScrollController;
late FocusNode focusNode;
@override
void initState() {
_listScrollController = ScrollController();
textEditingController = TextEditingController();
focusNode = FocusNode();
super.initState();
}
@override
void dispose() {
_listScrollController.dispose();
textEditingController.dispose();
focusNode.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final modelsProvider = Provider.of<ModelsProvider>(context);
final chatProvider = Provider.of<ChatProvider>(context);
return Scaffold(
drawer: Drawer(
shadowColor: const Color(0xFF50fa7b),
backgroundColor: const Color(0xFF44475a),
child: ListView(
primary: false,
padding: EdgeInsets.zero,
children: <Widget>[
const UserAccountsDrawerHeader(
decoration: BoxDecoration(color: Color.fromARGB(255, 43, 39, 63)),
accountName: Text("CHATGPT"),
accountEmail: Text(
'Versão 1.0.8',
style: TextStyle(
color: Color(0xFF50fa7b),
),
),
currentAccountPicture: CircleAvatar(
backgroundColor: Color.fromARGB(255, 0, 177, 129),
child: Image(
image: AssetImage('assets/images/logo_app.png'),
),
),
),
ListTile(
leading: const Icon(
Icons.chat_bubble_outline_outlined,
),
title: const Text(
'Gerador de Imagens',
style: TextStyle(
color: Color.fromARGB(255, 186, 186, 186),
fontSize: 15,
fontWeight: FontWeight.w900,
),
),
iconColor: const Color.fromARGB(255, 0, 164, 99),
onTap: () {
try {
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => const ChatMod()),
(route) => false);
setState(() => chatProvider.chatList.clear());
log('onTap!!!');
} catch (e) {
log('Error> $e');
}
},
),
],
),
),
floatingActionButton: const ButtonGitHub(),
appBar: AppBar(
elevation: 2,
centerTitle: true,
title: const Text("Novo Chat - Mensagem"),
actions: [
IconButton(
onPressed: () async {
await Services.showModalSheet(
context: context,
);
},
icon: const Icon(
Icons.more_vert_rounded,
color: Colors.white,
),
),
],
),
body: Center(
child: SafeArea(
child: Column(
children: [
Flexible(child: ChatWidget(controller: _listScrollController)),
if (_isTyping) ...[
const SpinKitThreeBounce(
color: Color(0xFF50fa7b),
size: 18,
),
],
CustomTextField(
controller: textEditingController,
focusNode: focusNode,
onSubmitted: (value) async {
await sendMessageFCT(
modelsProvider: modelsProvider,
chatProvider: chatProvider,
);
},
onPressed: () async {
await sendMessageFCT(
modelsProvider: modelsProvider,
chatProvider: chatProvider,
);
},
),
],
),
),
),
);
}
void scrollListToEND() {
_listScrollController.animateTo(
_listScrollController.position.maxScrollExtent,
duration: const Duration(seconds: 2),
curve: Curves.easeOut);
}
Future<void> sendMessageFCT(
{required ModelsProvider modelsProvider,
required ChatProvider chatProvider}) async {
if (textEditingController.text.isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Textwidget(
label: "Escreva algo!",
color: Colors.red,
),
backgroundColor: Colors.transparent,
),
);
return;
}
try {
String msg = textEditingController.text;
setState(
() {
_isTyping = true;
chatProvider.addUserMessage(msg: msg);
textEditingController.clear();
focusNode.unfocus();
},
);
await chatProvider.sendMessageAndGetAnswers(
msg: msg, chosenModelId: modelsProvider.getCurrentModel);
} catch (error) {
log("Erro_3 File: 'chat_screen.dart' > $error");
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Textwidget(
label: 'Requer uma chave API',
color: Colors.red,
),
backgroundColor: Colors.transparent,
),
);
} finally {
setState(() {
scrollListToEND();
_isTyping = false;
});
}
}
}
| 0
|
mirrored_repositories/App_ChatGPT/lib
|
mirrored_repositories/App_ChatGPT/lib/screens/chat_mod.dart
|
import 'dart:developer';
import 'package:appchatgpt/widgets/button_github.dart';
import 'package:appchatgpt/widgets/custom_text_field.dart';
import 'package:appchatgpt/widgets/text_widget.dart';
import 'package:provider/provider.dart';
import '../constants/constants.dart';
import '../providers/chat_provider.dart';
import '../providers/models_provider.dart';
import '/widgets/chat_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'chat_screen.dart';
class ChatMod extends StatefulWidget {
const ChatMod({super.key});
@override
State<ChatMod> createState() => _ChatModState();
}
class _ChatModState extends State<ChatMod> {
bool _isTyping = false;
late TextEditingController textEditingController;
late ScrollController _listScrollController;
late FocusNode focusNode;
@override
void initState() {
_listScrollController = ScrollController();
textEditingController = TextEditingController();
focusNode = FocusNode();
super.initState();
}
@override
void dispose() {
_listScrollController.dispose();
textEditingController.dispose();
focusNode.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final modelsProvider = Provider.of<ModelsProvider>(context);
final chatProvider = Provider.of<ChatProvider>(context);
return Scaffold(
floatingActionButton: const ButtonGitHub(),
drawer: Drawer(
shadowColor: const Color(0xFF50fa7b),
backgroundColor: const Color(0xFF44475a),
child: ListView(
primary: false,
padding: EdgeInsets.zero,
children: <Widget>[
const UserAccountsDrawerHeader(
decoration: BoxDecoration(color: Color.fromARGB(255, 43, 39, 63)),
accountName: Text("CHATGPT"),
accountEmail: Text(
'Versão 1.0.7',
style: TextStyle(
color: Color(0xFF50fa7b),
),
),
currentAccountPicture: CircleAvatar(
backgroundColor: Color.fromARGB(255, 0, 177, 129),
child: Image(
image: AssetImage('assets/images/logo_app.png'),
),
),
),
ListTile(
leading: const Icon(
Icons.chat_bubble_outline_outlined,
),
title: const Text(
'Chat de Mensagem',
style: TextStyle(
color: Color.fromARGB(255, 186, 186, 186),
fontSize: 15,
fontWeight: FontWeight.w900,
),
),
iconColor: const Color.fromARGB(255, 0, 164, 99),
onTap: () {
try {
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (context) => const ChatScreen()),
(route) => false);
setState(() => chatProvider.chatList.clear());
log('onTap!!!');
} catch (e) {
log('Error> $e');
}
},
),
],
),
),
appBar: AppBar(
elevation: 2,
centerTitle: true,
title: const Text("Novo Chat - Gerador"),
actions: [
IconButton(
onPressed: () async {
showModalBottomSheet(
shape: const RoundedRectangleBorder(
borderRadius:
BorderRadius.vertical(top: Radius.circular(20))),
backgroundColor: scaffoldBackgroundColor,
context: context,
builder: (context) {
return Padding(
padding: const EdgeInsets.all(18.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(
child: GestureDetector(
onTap: () =>
setState(() => chatProvider.chatList.clear()),
child: const Textwidget(
label: "Limpar Conversa",
color: Color.fromARGB(255, 255, 128, 0),
fontSize: 16,
),
)),
],
),
);
});
},
icon: const Icon(
Icons.more_vert_rounded,
color: Colors.white,
),
),
],
),
body: Center(
child: SafeArea(
child: Column(
children: [
Flexible(
child: ChatWidget(
controller: _listScrollController,
)),
if (_isTyping) ...[
const SpinKitFadingFour(
color: Color(0xFF50fa7b),
size: 18,
),
],
CustomTextField(
controller: textEditingController,
focusNode: focusNode,
onSubmitted: (value) async {
await sendMessageFCT(
modelsProvider: modelsProvider,
chatProvider: chatProvider,
);
},
onPressed: () async {
await sendMessageFCT(
modelsProvider: modelsProvider,
chatProvider: chatProvider,
);
},
),
],
),
),
),
);
}
void scrollListToEND() {
_listScrollController.animateTo(
_listScrollController.position.maxScrollExtent,
duration: const Duration(seconds: 2),
curve: Curves.easeOut);
}
Future<void> sendMessageFCT(
{required ModelsProvider modelsProvider,
required ChatProvider chatProvider}) async {
if (textEditingController.text.isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Textwidget(
label: "Escreva algo!",
color: Colors.red,
),
backgroundColor: Colors.transparent,
),
);
return;
}
try {
String msg = textEditingController.text;
setState(
() {
_isTyping = true;
chatProvider.addUserMessage(msg: msg);
textEditingController.clear();
focusNode.unfocus();
},
);
await chatProvider.sendMessageAndGetImage(
msg: msg, chosenModelId: modelsProvider.getCurrentModel);
} catch (error) {
log("Erro_3 File: 'chat_mod.dart' > $error");
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Textwidget(
label: error.toString(),
color: Colors.red,
),
backgroundColor: Colors.transparent,
),
);
} finally {
setState(() {
scrollListToEND();
_isTyping = false;
});
}
}
}
| 0
|
mirrored_repositories/App_ChatGPT/lib
|
mirrored_repositories/App_ChatGPT/lib/providers/chat_provider.dart
|
import 'package:flutter/material.dart';
import '../models/chat_model.dart';
import '../services/api_mod.dart';
import '../services/api_service.dart';
class ChatProvider with ChangeNotifier {
List<ChatModel> chatList = [];
List<ChatModel> get getChaList {
return chatList;
}
void addUserMessage({required String msg}) {
chatList.add(ChatModel(msg: msg, chatIndex: 0));
notifyListeners();
}
Future<void> sendMessageAndGetAnswers(
{required String msg, required chosenModelId}) async {
chatList.addAll(await ApiService.sendMessage(
message: msg,
modelId: chosenModelId,
));
notifyListeners();
}
Future<void> sendMessageAndGetImage(
{required String msg, required chosenModelId}) async {
chatList.addAll(await ApiMod.sendMessage(
message: msg,
modelId: chosenModelId,
));
notifyListeners();
}
}
| 0
|
mirrored_repositories/App_ChatGPT/lib
|
mirrored_repositories/App_ChatGPT/lib/providers/models_provider.dart
|
import 'package:appchatgpt/models/models_model.dart';
import 'package:appchatgpt/services/api_service.dart';
import 'package:flutter/material.dart';
class ModelsProvider with ChangeNotifier {
String currentModel = "gpt-3.5-turbo";
String get getCurrentModel {
return currentModel;
}
void setCurrentModel(String newModel) {
currentModel = newModel;
notifyListeners();
}
List<ModelsModel> modelsList = [];
List<ModelsModel> get getModelsList {
return modelsList;
}
Future<List<ModelsModel>> getAllModels() async {
modelsList = await ApiService.getModels();
return modelsList;
}
}
| 0
|
mirrored_repositories/App_ChatGPT
|
mirrored_repositories/App_ChatGPT/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:appchatgpt/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/flutter_inject
|
mirrored_repositories/flutter_inject/lib/main.dart
|
import 'package:flutter/material.dart';
// import 'injection/injection_get_it.dart';
import 'injection/injection_injectable.dart';
import 'pages/login_page.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await configureDependencies();
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Inject',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const LoginPage(),
);
}
}
| 0
|
mirrored_repositories/flutter_inject/lib
|
mirrored_repositories/flutter_inject/lib/pages/home_page.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_inject/injection/injection_get_it.dart';
import 'package:flutter_inject/managers/session_manager.dart';
class HomePage extends StatefulWidget {
const HomePage({super.key});
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
// final sessionManager = GetIt.I.get<SessionManager>();
final SessionManager sessionManager = getIt();
@override
Widget build(BuildContext context) {
debugPrint(sessionManager.hashCode.toString());
return Scaffold(
appBar: AppBar(
title: Text(sessionManager.user?.name ?? 'Not logged'),
),
body: Container(),
);
}
}
| 0
|
mirrored_repositories/flutter_inject/lib
|
mirrored_repositories/flutter_inject/lib/pages/login_page.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_inject/injection/injection_injectable.dart';
import 'package:flutter_inject/managers/session_manager.dart';
import 'home_page.dart';
class LoginPage extends StatefulWidget {
const LoginPage({super.key});
@override
State<LoginPage> createState() => _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Login'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () {
// 1.
// final sessionManager = GetIt.I.get<SessionManager>();
// 2.
// final SessionManager sessionManager = GetIt.I.get();
// 3.
// final SessionManager sessionManager = getIt();
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => const HomePage(),
),
);
},
child: const Text('Login'),
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () {
debugPrint(
'before isRegistered: ${getIt.isRegistered<SessionManager>()}',
);
// getIt.unregister<SessionManager>();
getIt.resetLazySingleton<SessionManager>();
debugPrint(
'after isRegistered: ${getIt.isRegistered<SessionManager>()}',
);
// getIt.registerSingleton<SessionManager>(getIt());
},
child: const Text('Remove SessionManager'),
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () {
debugPrint(
// 'before reset all: ${getIt.reset()}',
'before reset all: ',
);
// getIt.reset();
debugPrint(
// 'after reset all: ${getIt.reset()}',
'after reset all: ',
);
// open
// getIt.registerSingleton<SessionManager>(getIt());
},
child: const Text('Reset all'),
),
],
),
),
);
}
}
| 0
|
mirrored_repositories/flutter_inject/lib
|
mirrored_repositories/flutter_inject/lib/models/user.dart
|
class User {
User(this.name);
final String name;
}
| 0
|
mirrored_repositories/flutter_inject/lib
|
mirrored_repositories/flutter_inject/lib/injection/injection_injectable.config.dart
|
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// InjectableConfigGenerator
// **************************************************************************
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:dio/dio.dart' as _i5;
import 'package:flutter_inject/datasources/auth_local_datasource.dart' as _i3;
import 'package:flutter_inject/datasources/auth_remote_datasource.dart' as _i8;
import 'package:flutter_inject/injection/injection_injectable.dart' as _i9;
import 'package:flutter_inject/managers/session_manager.dart' as _i6;
import 'package:flutter_inject/repositories/auth_repository.dart' as _i4;
import 'package:get_it/get_it.dart' as _i1;
import 'package:injectable/injectable.dart' as _i2;
import 'package:shared_preferences/shared_preferences.dart' as _i7;
const String _node = 'node';
const String _firebase = 'firebase';
const String _test = 'test';
/// ignore_for_file: unnecessary_lambdas
/// ignore_for_file: lines_longer_than_80_chars
extension GetItInjectableX on _i1.GetIt {
/// initializes the registration of main-scope dependencies inside of [GetIt]
Future<_i1.GetIt> init({
String? environment,
_i2.EnvironmentFilter? environmentFilter,
}) async {
final gh = _i2.GetItHelper(
this,
environment,
environmentFilter,
);
final registerModule = _$RegisterModule();
gh.factory<_i3.AuthLocalDatasource>(() => _i3.AuthLocalDatasource());
gh.factory<_i4.AuthRepository>(
() => _i4.FirebaseAuthRepository(),
registerFor: {_firebase},
);
gh.factory<_i4.AuthRepository>(
() => _i4.MockAuthRepository(),
registerFor: {_test},
);
gh.singleton<_i5.Dio>(registerModule.dio);
gh.lazySingleton<_i6.SessionManager>(
() => _i6.SessionManager(gh<_i4.AuthRepository>()),
dispose: (i) => i.dispose(),
);
await gh.singletonAsync<_i7.SharedPreferences>(
() => registerModule.sharedPreferences,
preResolve: true,
);
gh.factory<_i8.AuthRemoteDatasource>(
() => _i8.AuthRemoteDatasource(gh<_i5.Dio>()));
gh.factory<_i4.AuthRepository>(
() => _i4.NodeAuthRepository(
gh<_i8.AuthRemoteDatasource>(),
gh<_i3.AuthLocalDatasource>(),
),
registerFor: {_node},
);
return this;
}
}
class _$RegisterModule extends _i9.RegisterModule {}
| 0
|
mirrored_repositories/flutter_inject/lib
|
mirrored_repositories/flutter_inject/lib/injection/injection_injectable.dart
|
import 'package:dio/dio.dart';
import 'package:get_it/get_it.dart';
import 'package:injectable/injectable.dart';
import 'package:flutter_inject/injection/injection_injectable.config.dart';
import 'package:shared_preferences/shared_preferences.dart';
final getIt = GetIt.instance;
const node = Environment('node');
const firebase = Environment('firebase');
const test = Environment('test');
@InjectableInit()
Future<void> configureDependencies() => getIt.init(
environment: 'node',
// environment: 'firebase',
// environment: 'test',
);
@module
abstract class RegisterModule {
@singleton
Dio get dio => Dio();
// @preResolve is for async dependencies, and init on app start
// but this await the init and put more time to start the app (in some cases)
// if not use @preResolve, we can use putAsync and init on constructor
@preResolve
@singleton
Future<SharedPreferences> get sharedPreferences =>
SharedPreferences.getInstance();
}
| 0
|
mirrored_repositories/flutter_inject/lib
|
mirrored_repositories/flutter_inject/lib/injection/injection_get_it.dart
|
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_inject/managers/session_manager.dart';
import 'package:get_it/get_it.dart';
import 'package:flutter_inject/datasources/auth_local_datasource.dart';
import 'package:flutter_inject/datasources/auth_remote_datasource.dart';
import 'package:flutter_inject/repositories/auth_repository.dart';
final getIt = GetIt.I;
void configureDependencies() {
debugPrint('Configuring dependencies');
// final sessionManager = SessionManager();
// debugPrint(sessionManager.hashCode.toString());
// GetIt.I.registerSingleton<SessionManager>(sessionManager);
// GetIt.I.registerSingleton<SessionManager>(SessionManager());
// GetIt.I.registerLazySingleton<SessionManager>(() => SessionManager());
// getIt.registerFactory(() => SessionManager());
// getIt.registerSingleton(
// SessionManager(
// AuthRepository(AuthRemoteDatasource(Dio()), AuthLocalDatasource()),
// ),
// );
// getIt.registerSingleton(LoginManager(
// AuthRepository(AuthRemoteDatasource(Dio()), AuthLocalDatasource()),
// ));
// Add dependencies in order!
// var useFirebase = false;
getIt.registerSingleton(Dio());
getIt.registerFactory((() => AuthRemoteDatasource(getIt())));
getIt.registerFactory((() => AuthLocalDatasource()));
getIt.registerFactory<AuthRepository>(
() => NodeAuthRepository(getIt(), getIt()),
); // getIt<AuthRemoteDatasource>(), getIt<AuthLocalDatasource>(),
// if (useFirebase) {
// getIt.registerFactory<AuthRepository>(
// () => FirebaseAuthRepository(),
// );
// } else {
// getIt.registerFactory<AuthRepository>(
// () => NodeAuthRepository(getIt(), getIt()),
// );
// }
getIt.registerSingleton(SessionManager(getIt()));
getIt.registerSingleton(LoginManager(getIt()));
debugPrint('Dependencies configured');
}
class LoginManager {
LoginManager(this.authRepository);
final AuthRepository authRepository;
}
| 0
|
mirrored_repositories/flutter_inject/lib
|
mirrored_repositories/flutter_inject/lib/datasources/auth_local_datasource.dart
|
import 'package:injectable/injectable.dart';
import 'package:flutter_inject/models/user.dart';
@injectable
class AuthLocalDatasource {
// AuthLocalDatasource(this.sharedPreferences);
// AuthLocalDatasource() {
// getIt
// .getAsync<SharedPreferences>()
// .then((value) => sharedPreferences = value);
// }
// late SharedPreferences sharedPreferences;
// final SharedPreferences sharedPreferences;
User? getCurrentUser() {
// call shared_preferences or flutter_secure_storage
return User('Felipe Sales | Local');
}
}
| 0
|
mirrored_repositories/flutter_inject/lib
|
mirrored_repositories/flutter_inject/lib/datasources/auth_remote_datasource.dart
|
import 'package:dio/dio.dart';
import 'package:injectable/injectable.dart';
import 'package:flutter_inject/models/user.dart';
@injectable
class AuthRemoteDatasource {
AuthRemoteDatasource(this.dio);
final Dio dio;
User? getCurrentUser() {
// call dio
return User('Felipe Sales | Remote');
}
}
| 0
|
mirrored_repositories/flutter_inject/lib
|
mirrored_repositories/flutter_inject/lib/repositories/auth_repository.dart
|
import 'package:flutter_inject/injection/injection_injectable.dart';
import 'package:injectable/injectable.dart';
import 'package:flutter_inject/datasources/auth_local_datasource.dart';
import 'package:flutter_inject/datasources/auth_remote_datasource.dart';
import 'package:flutter_inject/models/user.dart';
abstract class AuthRepository {
User? getCurrentUser();
}
@Injectable(as: AuthRepository, env: ['node'])
class NodeAuthRepository implements AuthRepository {
NodeAuthRepository(this._remoteDatasource, this._localDatasource);
final AuthRemoteDatasource _remoteDatasource;
final AuthLocalDatasource _localDatasource;
@override
User? getCurrentUser() {
User? user = _localDatasource.getCurrentUser();
if (user == null) {
return _remoteDatasource.getCurrentUser();
}
return user;
}
}
@Injectable(as: AuthRepository, env: ['firebase'])
class FirebaseAuthRepository implements AuthRepository {
@override
User? getCurrentUser() {
return User('Felipe Sales | Firebase');
}
}
@firebase
@Injectable(as: AuthRepository, env: ['test'])
class MockAuthRepository implements AuthRepository {
@override
User? getCurrentUser() {
return User('Felipe Sales | Mock');
}
}
| 0
|
mirrored_repositories/flutter_inject/lib
|
mirrored_repositories/flutter_inject/lib/managers/session_manager.dart
|
import 'package:flutter/material.dart';
import 'package:injectable/injectable.dart';
import 'package:flutter_inject/models/user.dart';
import 'package:flutter_inject/repositories/auth_repository.dart';
@lazySingleton
class SessionManager {
SessionManager(this._authRepository) {
debugPrint('SessionManager created');
_getCurrentUser();
}
final AuthRepository _authRepository;
User? user;
void _getCurrentUser() {
user = _authRepository.getCurrentUser();
}
@disposeMethod
void dispose() {
debugPrint('SessionManager disposed');
}
}
| 0
|
mirrored_repositories/flutter_inject
|
mirrored_repositories/flutter_inject/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:flutter_inject/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/flutter_cubit_localization
|
mirrored_repositories/flutter_cubit_localization/lib/language_cache_helper.dart
|
import 'package:shared_preferences/shared_preferences.dart';
class LanguageCacheHelper {
Future<void> cacheLanguageCode(String languageCode) async {
final SharedPreferences sharedPreferences =
await SharedPreferences.getInstance();
sharedPreferences.setString('LOCALE', languageCode);
}
Future<String> getCachedLanguageCode() async {
final SharedPreferences sharedPreferences =
await SharedPreferences.getInstance();
final String? languageCode = sharedPreferences.getString('LOCALE');
if (languageCode != null) {
return languageCode;
} else {
return 'en';
}
}
}
| 0
|
mirrored_repositories/flutter_cubit_localization
|
mirrored_repositories/flutter_cubit_localization/lib/settings_screen.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_cubit_localization/cubit/locale_cubit.dart';
import 'package:flutter_cubit_localization/localization/app_localization.dart';
class SettingsScreen extends StatelessWidget {
const SettingsScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('settings'.tr(context)),
),
body: Center(
child: Padding(
padding: const EdgeInsets.all(16),
child: BlocConsumer<LocaleCubit, LocaleState>(
listener: (context, state) {
Navigator.of(context).pop();
},
builder: (context, state) {
if (state is LocaleChangedState) {
return DropdownButton(
value: state.locale.languageCode,
items: ['en', 'ar']
.map((String item) => DropdownMenuItem(
value: item,
child: Text(item),
))
.toList(),
onChanged: (String? newValue) {
if (newValue != null) {
context.read<LocaleCubit>().changeLanguageCode(newValue);
}
},
);
} else {
return const SizedBox();
}
},
),
),
),
);
}
}
| 0
|
mirrored_repositories/flutter_cubit_localization
|
mirrored_repositories/flutter_cubit_localization/lib/main.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_cubit_localization/cubit/locale_cubit.dart';
import 'package:flutter_cubit_localization/localization/app_localization.dart';
import 'package:flutter_cubit_localization/settings_screen.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MultiBlocProvider(
providers: [
BlocProvider(
create: (context) => LocaleCubit()..getSavedLanguageCode(),
),
],
child: BlocBuilder<LocaleCubit, LocaleState>(
builder: (context, state) {
if (state is LocaleChangedState) {
return MaterialApp(
debugShowCheckedModeBanner: false,
locale: state.locale,
supportedLocales: const [Locale('en'), Locale('ar')],
localizationsDelegates: const [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
localeResolutionCallback: (deviceLocale, supportedLocale) {
for (var locale in supportedLocale) {
if (deviceLocale != null &&
deviceLocale.languageCode == locale.languageCode) {
return deviceLocale;
}
}
return supportedLocale.first;
},
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(),
);
} else {
return const SizedBox();
}
},
),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('home_appbar'.tr(context)),
actions: [
IconButton(
onPressed: () => Navigator.of(context).push(MaterialPageRoute(
builder: (context) => const SettingsScreen(),
)),
icon: const Icon(Icons.settings))
],
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'home_msg'.tr(context),
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
);
}
}
| 0
|
mirrored_repositories/flutter_cubit_localization/lib
|
mirrored_repositories/flutter_cubit_localization/lib/cubit/locale_cubit.dart
|
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter/material.dart';
import 'package:flutter_cubit_localization/language_cache_helper.dart';
part 'locale_state.dart';
class LocaleCubit extends Cubit<LocaleState> {
LocaleCubit() : super(LocaleInitial());
Future<void> getSavedLanguageCode() async {
final String cachedLanguageCode =
await LanguageCacheHelper().getCachedLanguageCode();
emit(LocaleChangedState(locale: Locale(cachedLanguageCode)));
}
Future<void> changeLanguageCode(String languageCode) async {
await LanguageCacheHelper().cacheLanguageCode(languageCode);
emit(LocaleChangedState(locale: Locale(languageCode)));
}
}
| 0
|
mirrored_repositories/flutter_cubit_localization/lib
|
mirrored_repositories/flutter_cubit_localization/lib/cubit/locale_state.dart
|
part of 'locale_cubit.dart';
@immutable
abstract class LocaleState {}
class LocaleInitial extends LocaleState {}
class LocaleChangedState extends LocaleState {
final Locale locale;
LocaleChangedState({required this.locale});
}
| 0
|
mirrored_repositories/flutter_cubit_localization/lib
|
mirrored_repositories/flutter_cubit_localization/lib/localization/app_localization.dart
|
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class AppLocalizations {
final Locale? locale;
AppLocalizations({required this.locale});
static AppLocalizations? of(BuildContext context) {
return Localizations.of<AppLocalizations>(context, AppLocalizations);
}
static const LocalizationsDelegate<AppLocalizations> delegate =
_AppLocalizationDelegate();
late Map<String, String> _localizedStrings;
Future loadJsonLanguage() async {
String jsonString =
await rootBundle.loadString('assets/lang/${locale!.languageCode}.json');
Map<String, dynamic> jsonMap = json.decode(jsonString);
_localizedStrings = jsonMap.map((key, value) {
return MapEntry(key, value.toString());
});
}
String translate(String key) => _localizedStrings[key] ?? '';
}
class _AppLocalizationDelegate extends LocalizationsDelegate<AppLocalizations> {
const _AppLocalizationDelegate();
@override
bool isSupported(Locale locale) {
return ['en', 'ar'].contains(locale.languageCode);
}
@override
Future<AppLocalizations> load(Locale locale) async {
AppLocalizations localizations = AppLocalizations(locale: locale);
await localizations.loadJsonLanguage();
return localizations;
}
@override
bool shouldReload(covariant LocalizationsDelegate<AppLocalizations> old) =>
false;
}
extension TranslateX on String {
String tr(BuildContext context) {
return AppLocalizations.of(context)!.translate(this);
}
}
| 0
|
mirrored_repositories/flutter_cubit_localization
|
mirrored_repositories/flutter_cubit_localization/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:flutter_cubit_localization/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/IntelliChat
|
mirrored_repositories/IntelliChat/lib/main.dart
|
import "dart:math";
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
import './screens/home.dart';
import './providers/contacts.dart';
import './providers/self.dart';
import './providers/customization.dart';
import './models/customize.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
runApp(
MultiProvider(
providers: [
ChangeNotifierProvider(
create: (_) => ContactsProvider(),
),
ChangeNotifierProvider(
create: (_) => SelfProvider(),
),
ChangeNotifierProvider(
create: (_) => CustomizationProvider(),
),
],
child: IntelliChatMain(),
),
);
}
class IntelliChatMain extends StatelessWidget {
late final int _randomindex;
ThemeData switchTheme(int rand, bool darkmode) {
final ThemeData dark = ThemeData(
scaffoldBackgroundColor: Colors.black,
fontFamily: 'Oswald',
brightness: Brightness.dark,
/* theme */
primaryColor: Colors.primaries[_randomindex],
accentColor: Colors.primaries[_randomindex],
// primarySwatch: Colors
// .primaries[new Random().nextInt(Colors.primaries.length)], //xD
/////////////////////////////////////////////////////////////////////////
textTheme: ThemeData.dark().textTheme.copyWith(
bodyText1: TextStyle(
color: Colors.white,
),
bodyText2: TextStyle(
color: Color(0xEEFFFFFF),
),
),
);
final ThemeData light = ThemeData(
// scaffoldBackgroundColor: Colors.black,
fontFamily: 'Oswald',
// brightness: Brightness.light,
/* theme */
primaryColor: Colors.primaries[_randomindex],
accentColor: Colors.primaries[_randomindex],
// primarySwatch: Colors
// .primaries[new Random().nextInt(Colors.primaries.length)], //xD
);
return darkmode ? dark : light;
}
@override
Widget build(BuildContext context) {
final CustomizationProvider handle =
Provider.of<CustomizationProvider>(context);
final CustomizeModel mode = handle.data;
try {
// ignore: unnecessary_statements
_randomindex;
} catch (e) {
_randomindex = new Random().nextInt(Colors.primaries.length);
}
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: switchTheme(_randomindex, mode.darkmode),
title: 'simply intelligent',
home: IntelliChatHome(),
);
}
}
| 0
|
mirrored_repositories/IntelliChat/lib
|
mirrored_repositories/IntelliChat/lib/widgets/appdrawer.dart
|
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../providers/self.dart';
import '../models/myself.dart';
import '../providers/customization.dart';
import '../models/customize.dart';
import './drawerheader.dart';
class AppDrawer extends StatelessWidget {
final double width, height;
final MediaQueryData mq;
AppDrawer({
required this.width,
required this.height,
required this.mq,
});
Widget listTileGen(IconData icondata, String title, Function funx) {
return ListTile(
leading: Icon(
icondata,
size: 30,
color: Colors.white30,
),
title: Text(
title,
style: TextStyle(
fontSize: 15,
),
),
enableFeedback: true,
onTap: () => funx(),
);
}
@override
Widget build(BuildContext context) {
final SelfProvider handle = Provider.of<SelfProvider>(context);
final MyselfModel myself = handle.myself;
final CustomizationProvider handle2 =
Provider.of<CustomizationProvider>(context);
final CustomizeModel theme = handle2.data;
return Drawer(
child: Column(
children: [
DrawerzHeader(
height: height,
mq: mq,
myself: myself,
theme: theme,
width: width,
handle: handle2,
),
Container(
color: Colors.black38,
height: height - mq.padding.bottom - 195,
child: Column(
children: [
listTileGen(
Icons.people_outline,
'New Group',
() {},
),
listTileGen(
Icons.person_outline_rounded,
'Contacts',
() {},
),
listTileGen(
Icons.save_outlined,
'Saved Chats',
() {},
),
listTileGen(
Icons.settings_applications_outlined,
'Settings',
() {},
),
Divider(
color: Colors.black54,
thickness: 2,
),
listTileGen(
Icons.person_add_alt_outlined,
'Invite Friends',
() {},
),
listTileGen(
Icons.help_outline_outlined,
'Changelogs',
() {},
),
listTileGen(
Icons.info_outline_rounded,
'About',
() {},
),
],
),
),
],
),
);
}
}
| 0
|
mirrored_repositories/IntelliChat/lib
|
mirrored_repositories/IntelliChat/lib/widgets/drawerheader.dart
|
import 'package:flutter/material.dart';
import '../providers/customization.dart';
import '../models/customize.dart';
import '../models/myself.dart';
class DrawerzHeader extends StatelessWidget {
final MediaQueryData mq;
final double width, height;
final MyselfModel myself;
final CustomizeModel theme;
final CustomizationProvider handle;
DrawerzHeader({
required this.height,
required this.mq,
required this.myself,
required this.theme,
required this.width,
required this.handle,
});
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
height: 195,
decoration: BoxDecoration(
color: Colors.black, /* theme */
),
child: Padding(
padding: EdgeInsets.only(
top: mq.padding.top + 20,
bottom: 5,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
margin: EdgeInsets.symmetric(horizontal: 15),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ClipRRect(
borderRadius: BorderRadius.circular(100),
child: myself.picuri == 'null'
? Container(
width: 68,
height: 68,
decoration: BoxDecoration(
color: Theme.of(context).accentColor,
),
child: Center(
child: Text(
myself.name.substring(0, 2),
/* split and then first */
style: TextStyle(
fontSize: 25,
),
),
),
)
: Image(
image: NetworkImage(myself.picuri),
fit: BoxFit.cover,
width: 68,
height: 68,
),
),
Material(
borderRadius: BorderRadius.circular(100),
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.circular(100),
child: Container(
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(100),
// ),
width: 45,
height: 45,
// color: Colors.amber,
child: Icon(
theme.darkmode
? Icons.wb_sunny_rounded
: Icons.dark_mode_rounded,
size: 30,
color: theme.darkmode ? null : Colors.white,
),
),
onTap: () {
// print('theme changed');
handle.toggle();
},
),
)
],
),
),
Container(
margin: EdgeInsets.symmetric(horizontal: 15),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
Text(
myself.name,
style: TextStyle(
fontSize: 18,
),
),
Text(
myself.secondaryid,
style: TextStyle(
fontSize: 14,
color: Colors.white54,
),
),
],
),
Material(
borderRadius: BorderRadius.circular(100),
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.circular(100),
child: Container(
width: 45,
height: 45,
child: Icon(Icons.logout_rounded),
),
onTap: () {
print('logout');
},
),
),
],
),
),
],
),
),
);
}
}
| 0
|
mirrored_repositories/IntelliChat/lib
|
mirrored_repositories/IntelliChat/lib/models/customize.dart
|
class CustomizeModel {
bool darkmode;
CustomizeModel({
this.darkmode = true,
});
}
| 0
|
mirrored_repositories/IntelliChat/lib
|
mirrored_repositories/IntelliChat/lib/models/contact.dart
|
class ContactModel {
String primaryid;
String secondaryid;
String name;
String picuri;
DateTime lastchatdate;
int unreadmsg;
bool msgsent;
bool msgreceived;
bool msgread;
bool ismuted;
String lastmsg;
bool sentbycontact;
ContactModel({
required this.primaryid,
this.secondaryid = 'null',
required this.name,
this.picuri = 'null',
required this.lastchatdate,
this.msgsent = false,
this.msgreceived = false,
this.msgread = false,
this.unreadmsg = 0,
this.ismuted = false,
required this.lastmsg,
required this.sentbycontact,
});
}
| 0
|
mirrored_repositories/IntelliChat/lib
|
mirrored_repositories/IntelliChat/lib/models/myself.dart
|
class MyselfModel {
String primaryid;
String secondaryid;
String name;
String picuri;
// final bool isOnline; TODO: privacy settings manual overwrite
String bio;
bool isLoggedin;
String authToken;
MyselfModel({
required this.primaryid,
required this.secondaryid,
required this.name,
this.picuri = 'null',
// required this.isOnline,
required this.bio,
required this.isLoggedin,
required this.authToken,
});
}
| 0
|
mirrored_repositories/IntelliChat/lib
|
mirrored_repositories/IntelliChat/lib/screens/status.dart
|
import 'package:flutter/material.dart';
class IntelliChatStatus extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(
child: Container(
child: Text('Status'),
),
);
}
}
| 0
|
mirrored_repositories/IntelliChat/lib
|
mirrored_repositories/IntelliChat/lib/screens/chats.dart
|
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:intl/intl.dart';
import '../providers/contacts.dart';
import '../models/contact.dart';
class IntelliChatChats extends StatelessWidget {
@override
Widget build(BuildContext context) {
final MediaQueryData mq = MediaQuery.of(context);
final ContactsProvider contactshandle =
Provider.of<ContactsProvider>(context);
final List<ContactModel> contacts = contactshandle.contacts;
// return ListView.builder(
// itemCount: contacts.length,
// itemBuilder: (ctx, id) {
// return;
// },
// );
return Column(children: [
Container(
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: Colors.white12,
width: 2,
),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Padding(
padding: const EdgeInsets.all(10),
child: ClipRRect(
borderRadius: BorderRadius.circular(100),
child: contacts.first.picuri == 'null'
? Container(
width: 58,
height: 58,
decoration: BoxDecoration(
color: Theme.of(context).accentColor,
),
child: Center(
child: Text(
contacts.first.name.substring(0, 2),
/* split and then first */
style: TextStyle(
fontSize: 28,
),
),
),
)
: Image(
image: NetworkImage(contacts.first.picuri),
fit: BoxFit.cover,
width: 58,
height: 58,
),
),
),
Container(
width: mq.size.width - 170,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
contacts.first.name,
style: TextStyle(
fontSize: 19,
// color: Color(0xEEFFFFFF),
),
overflow: TextOverflow.ellipsis,
),
Text(
contacts.first.lastmsg,
style: TextStyle(
color: Colors.white54,
fontSize: 15,
),
overflow: TextOverflow.ellipsis,
),
],
),
),
Padding(
padding: const EdgeInsets.only(right: 8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Padding(
padding: const EdgeInsets.only(
right: 5,
),
child: Icon(
Icons.done_all_rounded,
size: 20,
color: Colors.blue,
),
),
Text(
DateFormat('h:mm a')
.format(contacts.first.lastchatdate),
style: TextStyle(fontSize: 13, color: Colors.white54),
overflow: TextOverflow.ellipsis,
),
],
),
Container(
decoration: BoxDecoration(
color: Theme.of(context).primaryColor,
borderRadius: BorderRadius.horizontal(
left: Radius.circular(12),
right: Radius.circular(12),
),
),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 5, vertical: 2),
child: Text(
contacts.first.unreadmsg.toString(),
overflow: TextOverflow.ellipsis,
),
),
),
],
),
),
],
),
),
]);
}
}
| 0
|
mirrored_repositories/IntelliChat/lib
|
mirrored_repositories/IntelliChat/lib/screens/home.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_search_bar/flutter_search_bar.dart';
import './chats.dart';
import './calls.dart';
import './status.dart';
import '../widgets/appdrawer.dart';
class IntelliChatHome extends StatefulWidget {
@override
_IntelliChatHomeState createState() => _IntelliChatHomeState();
}
class _IntelliChatHomeState extends State<IntelliChatHome> {
late SearchBar searchBar;
int _page = 0;
late PageController _pc;
int _totalpages = 3;
late double width, height;
AppBar buildAppBar(BuildContext context) {
return new AppBar(
title: new Text('IntelliChat'),
actions: [searchBar.getSearchAction(context)],
);
}
@override
void initState() {
_pc = new PageController(
initialPage: _page,
);
searchBar = new SearchBar(
inBar: false,
setState: setState,
onSubmitted: print,
buildDefaultAppBar: buildAppBar,
);
super.initState();
}
@override
Widget build(BuildContext context) {
final MediaQueryData mq = MediaQuery.of(context);
width = mq.size.width;
height = mq.size.height;
return Scaffold(
appBar: searchBar.build(context),
drawer: AppDrawer(
mq: mq,
width: width,
height: height,
),
bottomNavigationBar: BottomNavigationBar(
elevation: 10,
currentIndex: _page,
// backgroundColor: Colors.black,
selectedItemColor: Theme.of(context).primaryColor,
onTap: (p) {
_pc.animateToPage(
p,
duration: const Duration(milliseconds: 300),
curve: Curves.decelerate,
);
},
items: [
BottomNavigationBarItem(
icon: Icon(Icons.chat),
label: 'Chats',
),
BottomNavigationBarItem(
icon: Icon(Icons.access_time_filled),
label: 'Status',
),
BottomNavigationBarItem(
icon: Icon(Icons.call),
label: 'Calls',
),
],
),
body: PageView(
controller: _pc,
onPageChanged: (p) {
if (p > _totalpages - 1) {
return;
}
setState(() {
_page = p;
});
},
children: [
IntelliChatChats(),
IntelliChatStatus(),
IntelliChatCalls(),
],
),
);
}
}
| 0
|
mirrored_repositories/IntelliChat/lib
|
mirrored_repositories/IntelliChat/lib/screens/calls.dart
|
import 'package:flutter/material.dart';
class IntelliChatCalls extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(
child: Container(
child: Text('Calls'),
),
);
}
}
| 0
|
mirrored_repositories/IntelliChat/lib
|
mirrored_repositories/IntelliChat/lib/providers/contacts.dart
|
import 'package:flutter/material.dart';
import '../models/contact.dart';
class ContactsProvider with ChangeNotifier {
List<ContactModel> _contacts = [
ContactModel(
primaryid: 'foahioghaiogh',
name: 'Akash Ranjan',
lastchatdate: DateTime.now(),
lastmsg:
'hello brother how are you?? fhu ish fui sg ui su ish ugo hs uig bsu ibg uis ghb uis bgu isb gu ib sg uib su gi',
sentbycontact: true,
unreadmsg: 9999999,
),
ContactModel(
primaryid: 'aifhioasghnsiog',
name: 'Anjnai Saurav',
lastchatdate: DateTime.now(),
lastmsg: 'fjajfhiaofhioahfif',
sentbycontact: true,
),
ContactModel(
primaryid: 'oifhjsiogjsiogjisog',
name: 'Avi Singh',
lastchatdate: DateTime.now(),
lastmsg: 'fjafgbuifbuisafgbisge',
sentbycontact: true,
),
ContactModel(
primaryid: 'eguisjkvgbsuieg',
name: 'Harshil Dhingra',
lastchatdate: DateTime.now(),
lastmsg: 'uigbuidsbguisngiosbg',
sentbycontact: true,
),
ContactModel(
primaryid: 'yjfhjbsyuifgbsf',
name: 'Devesh Mirani',
lastchatdate: DateTime.now(),
lastmsg: 'wuifghuiacnuisfgbesuif',
sentbycontact: true,
),
ContactModel(
primaryid: 'ugebvsuivbuis',
name: 'Harsh Kumar',
lastchatdate: DateTime.now(),
lastmsg: 'uihfuisnfuisgef',
sentbycontact: true,
),
ContactModel(
primaryid: 'nchbecyuibsuievc',
name: 'Harsh Deep',
lastchatdate: DateTime.now(),
lastmsg: 'winaifbayuifbafuifa',
sentbycontact: true,
),
];
List<ContactModel> get contacts {
return _contacts;
}
}
| 0
|
mirrored_repositories/IntelliChat/lib
|
mirrored_repositories/IntelliChat/lib/providers/self.dart
|
import 'package:flutter/material.dart';
import '../models/myself.dart';
class SelfProvider with ChangeNotifier {
MyselfModel _myself = MyselfModel(
primaryid: 'nfioanfioaf',
secondaryid: 'uifbanuifauif',
name: 'Harsh Raj',
bio: 'i am a good guy',
isLoggedin: true,
authToken: 'afkhfgbuibguisbguis',
);
MyselfModel get myself {
return _myself;
}
}
| 0
|
mirrored_repositories/IntelliChat/lib
|
mirrored_repositories/IntelliChat/lib/providers/customization.dart
|
import 'package:flutter/material.dart';
import '../models/customize.dart';
class CustomizationProvider with ChangeNotifier {
CustomizeModel _data = CustomizeModel(
darkmode: true,
);
CustomizeModel get data {
return _data;
}
void toggle() {
_data.darkmode = !_data.darkmode;
notifyListeners();
}
}
| 0
|
mirrored_repositories/flutter_sliver_example
|
mirrored_repositories/flutter_sliver_example/lib/.samples.dart
|
import 'package:flutter/material.dart';
import 'dart:math' as math;
void main(List<String> args) {
runApp(MaterialApp(
home: MyApp(),
));
}
class MyApp extends StatefulWidget {
MyApp({Key? key}) : super(key: key);
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: CustomScrollView(
slivers: [
SliverAnimatedList(
itemBuilder: (context, index, animation) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Text("$index"),
);
},
initialItemCount: 5,
),
//
SliverAppBar(
title: Text("Hello Da"),
),
//
SliverPersistentHeader(
floating: true,
// pinned: true,
delegate: _SliverAppBarDelegate(
minHeight: 10,
maxHeight: 40,
child: Container(
color: Colors.pink,
child: Center(child: Text("Hello"))))),
//
SliverGrid(
delegate: SliverChildListDelegate(List.generate(
24,
(index) => Container(
color:
Color((math.Random().nextDouble() * 0xFFFFFF).toInt())
.withOpacity(1.0)),
)
// [
// Container(color: Colors.red),
// Container(color: Colors.purple),
// Container(color: Colors.green),
// Container(color: Colors.orange),
// Container(color: Colors.yellow),
// ]
),
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4)),
//
SliverList(
delegate: SliverChildListDelegate(List.generate(
25,
(index) => Container(
width: 50,
height: 50,
child: Text("$index"),
)))),
//
SliverGrid.count(
crossAxisCount: 6,
children: List.generate(
24,
(index) => Container(
color: Color((math.Random().nextDouble() * 0xFFFFFF).toInt())
.withOpacity(1.0)),
),
),
//
SliverPadding(
padding: EdgeInsets.all(25),
sliver:
//
SliverReorderableList(
key: UniqueKey(),
itemBuilder: (con, index) {
return Container(
key: UniqueKey(), child: Text(" I miss you" + "$index"));
},
itemCount: 2,
onReorder: (a, b) {},
)),
],
),
));
}
}
class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
_SliverAppBarDelegate({
required this.minHeight,
required this.maxHeight,
required this.child,
});
final double minHeight;
final double maxHeight;
final Widget child;
@override
double get minExtent => minHeight;
@override
double get maxExtent => math.max(maxHeight, minHeight);
@override
Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) {
return new SizedBox.expand(child: child);
}
@override
bool shouldRebuild(_SliverAppBarDelegate oldDelegate) {
return maxHeight != oldDelegate.maxHeight ||
minHeight != oldDelegate.minHeight ||
child != oldDelegate.child;
}
}
| 0
|
mirrored_repositories/flutter_sliver_example
|
mirrored_repositories/flutter_sliver_example/lib/main.dart
|
import 'package:flutter/material.dart';
import 'dart:math' as math;
void main(List<String> args) {
runApp(const MaterialApp(home: MyApp()));
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
MyAppState createState() => MyAppState();
}
class MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: CustomScrollView(
slivers: [
SliverPersistentHeader(
floating: true,
pinned: true,
delegate: _SliverAppBarDelegate(
minHeight: 50,
maxHeight: 70,
child: Container(
color: Colors.pink,
child: const Center(
child: Text(
"Sliver Header",
style: TextStyle(
color: Colors.white,
fontSize: 24,
decoration: TextDecoration.none),
),
),
)),
),
SliverList(
delegate: SliverChildListDelegate(List.generate(
26,
(index) => Container(
padding: const EdgeInsets.all(15),
color: Color((math.Random().nextDouble() * 0xFFFFFF)
.toInt())
.withOpacity(1.0),
child: Text(
"Container number $index",
style: const TextStyle(
color: Colors.black,
fontWeight: FontWeight.w500,
fontSize: 20,
decoration: TextDecoration.none),
),
))))
],
),
),
);
}
}
class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
_SliverAppBarDelegate({
required this.minHeight,
required this.maxHeight,
required this.child,
});
final double minHeight;
final double maxHeight;
final Widget child;
@override
double get minExtent => minHeight;
@override
double get maxExtent => math.max(maxHeight, minHeight);
@override
Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) {
return SizedBox.expand(child: child);
}
@override
bool shouldRebuild(_SliverAppBarDelegate oldDelegate) {
return maxHeight != oldDelegate.maxHeight ||
minHeight != oldDelegate.minHeight ||
child != oldDelegate.child;
}
}
| 0
|
mirrored_repositories/AestheticsFlutterApp-
|
mirrored_repositories/AestheticsFlutterApp-/lib/main.dart
|
import 'package:flutter/material.dart';
import 'package:aesthetics/views/home.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Aesthetics',
theme: ThemeData(
primaryColor: Colors.white,
),
home: Home(),
);
}
}
| 0
|
mirrored_repositories/AestheticsFlutterApp-/lib
|
mirrored_repositories/AestheticsFlutterApp-/lib/views/categorie.dart
|
import 'package:flutter/material.dart';
import 'package:aesthetics/widget/widget.dart';
import 'package:http/http.dart' as http;
import 'package:aesthetics/data/data.dart';
import 'package:aesthetics/model/wallpaper_model.dart';
import 'dart:convert';
class Categorie extends StatefulWidget {
final String categorieName;
Categorie({this.categorieName});
@override
_CategorieState createState() => _CategorieState();
}
class _CategorieState extends State<Categorie> {
List<WallpaperModel> wallpapers = new List();
getSearchWallpapers() async {
var response = await http.get(
"https://api.pexels.com/v1/search?query=${widget.categorieName}&per_page=15&page=1",
headers: {"Authorization": apikey});
//print(response.body.toString());
Map<String, dynamic> jsonData = jsonDecode(response.body);
jsonData["photos"].forEach((element) {
// print(element);
WallpaperModel wallpaperModel = new WallpaperModel();
wallpaperModel = WallpaperModel.fromMap(element);
wallpapers.add(wallpaperModel);
});
setState(() {});
}
@override
void initState() {
getSearchWallpapers();
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
title: brandName(),
elevation: 0.0,
),
body: SingleChildScrollView(
child: Container(
child: Column(
children: <Widget>[
SizedBox(
height: 16,
),
wallpapersList(wallpapers: wallpapers, context: context)
],
)),
),
);
}
}
| 0
|
mirrored_repositories/AestheticsFlutterApp-/lib
|
mirrored_repositories/AestheticsFlutterApp-/lib/views/search.dart
|
import 'package:flutter/material.dart';
import 'package:aesthetics/widget/widget.dart';
import 'package:http/http.dart' as http;
import 'package:aesthetics/data/data.dart';
import 'package:aesthetics/model/wallpaper_model.dart';
import 'dart:convert';
class Search extends StatefulWidget {
final String searchQuery;
Search({this.searchQuery});
@override
_SearchState createState() => _SearchState();
}
class _SearchState extends State<Search> {
TextEditingController searchcontroller = new TextEditingController();
List<WallpaperModel> wallpapers = new List();
getSearchWallpapers(String query) async {
var response = await http.get(
"https://api.pexels.com/v1/search?query=$query&per_page=15&page=1",
headers: {"Authorization": apikey});
//print(response.body.toString());
Map<String, dynamic> jsonData = jsonDecode(response.body);
jsonData["photos"].forEach((element) {
// print(element);
WallpaperModel wallpaperModel = new WallpaperModel();
wallpaperModel = WallpaperModel.fromMap(element);
wallpapers.add(wallpaperModel);
});
setState(() {});
}
@override
void initState() {
getSearchWallpapers(widget.searchQuery);
super.initState();
searchcontroller.text = widget.searchQuery;
}
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
title: brandName(),
elevation: 0.0,
),
body: SingleChildScrollView(
child: Container(
child: Column(
children: <Widget>[
Container(
padding: EdgeInsets.symmetric(horizontal: 24),
margin: EdgeInsets.symmetric(horizontal: 24),
decoration: BoxDecoration(
color: Color(0xfff5f8fd),
borderRadius: BorderRadius.circular(30)),
child: Row(
children: <Widget>[
Expanded(
child: TextField(
controller: searchcontroller,
decoration: InputDecoration(
hintText: "search", border: InputBorder.none),
),
),
GestureDetector(
onTap: () {
getSearchWallpapers(searchcontroller.text);
},
child: Container(child: Icon(Icons.search)),
)
],
),
),
SizedBox(
height: 16,
),
wallpapersList(wallpapers: wallpapers, context: context)
],
)),
),
);
}
}
| 0
|
mirrored_repositories/AestheticsFlutterApp-/lib
|
mirrored_repositories/AestheticsFlutterApp-/lib/views/image_view.dart
|
import 'dart:typed_data';
import 'dart:ui';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:image_gallery_saver/image_gallery_saver.dart';
//import 'package:permission_handler/permission_handler.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:image_downloader/image_downloader.dart';
//import 'dart:js' as js;
class ImageView extends StatefulWidget {
final String imgPath;
ImageView({@required this.imgPath});
@override
_ImageViewState createState() => _ImageViewState();
}
class _ImageViewState extends State<ImageView> {
var filePath;
_launchURL(String url) async {
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: <Widget>[
Hero(
tag: widget.imgPath,
child: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: kIsWeb
? Image.network(widget.imgPath, fit: BoxFit.cover)
: CachedNetworkImage(
imageUrl: widget.imgPath,
placeholder: (context, url) => Container(
color: Color(0xfff5f8fd),
),
fit: BoxFit.cover,
),
),
),
Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
alignment: Alignment.bottomCenter,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
InkWell(
onTap: () {
if (kIsWeb) {
_launchURL(widget.imgPath);
//js.context.callMethod('downloadUrl',[widget.imgPath]);
//response = await dio.download(widget.imgPath, "./xx.html");
} else {
//print(widget.imgPath);
_save();
}
//Navigator.pop(context);
},
child: Stack(
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width / 2,
height: 50,
decoration: BoxDecoration(
color: Color(0xff1C1B1B).withOpacity(0.8),
borderRadius: BorderRadius.circular(40),
),
),
Container(
width: MediaQuery.of(context).size.width / 2,
height: 50,
alignment: Alignment.center,
decoration: BoxDecoration(
border:
Border.all(color: Colors.white24, width: 1),
borderRadius: BorderRadius.circular(40),
gradient: LinearGradient(
colors: [
Color(0x36FFFFFF),
Color(0x0FFFFFFF)
],
begin: FractionalOffset.topLeft,
end: FractionalOffset.bottomRight)),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
"Set Wallpaper",
style: TextStyle(
color: Colors.white70,
fontSize: 15,
fontWeight: FontWeight.w500),
),
SizedBox(
height: 1,
),
Text(
kIsWeb
? "Image will open in new tab to download"
: "Image will be saved in gallery",
style: TextStyle(
fontSize: 8, color: Colors.white70),
),
],
)),
],
)),
SizedBox(
height: 16,
),
InkWell(
onTap: () {
Navigator.pop(context);
},
child: Text(
"Cancel",
style: TextStyle(
color: Colors.white60,
fontSize: 12,
fontWeight: FontWeight.w500),
),
),
SizedBox(
height: 50,
)
],
),
)
],
),
);
}
_save() async {
// await _askPermission();
ImageDownloader.downloadImage(widget.imgPath);
var response = await Dio().get(widget.imgPath,
options: Options(responseType: ResponseType.bytes));
final result =
await ImageGallerySaver.saveImage(Uint8List.fromList(response.data));
print(result);
Navigator.pop(context);
}
// _askPermission() async {
// if (Platform.isIOS) {
// /*Map<PermissionGroup, PermissionStatus> permissions =
// */
// await Permission.storage.request();
// // await PermissionHandler().requestPermissions([PermissionGroup.photos]);
// } else {
// /* PermissionStatus permission = */ await PermissionHandler()
// .checkPermissionStatus(PermissionGroup.storage);
// }
// }
}
| 0
|
mirrored_repositories/AestheticsFlutterApp-/lib
|
mirrored_repositories/AestheticsFlutterApp-/lib/views/home.dart
|
import 'dart:convert';
import 'package:aesthetics/data/data.dart';
import 'package:aesthetics/model/wallpaper_model.dart';
import 'package:aesthetics/views/categorie.dart';
//import 'package:aesthetics/views/image_view.dart';
import 'package:flutter/material.dart';
import 'package:aesthetics/widget/widget.dart';
import 'package:aesthetics/model/categories_model.dart';
import 'package:http/http.dart' as http;
import 'search.dart';
class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
List<CategoriesModel> categories = new List();
List<WallpaperModel> wallpapers = new List();
TextEditingController searchcontroller = new TextEditingController();
getTrendingWallpapers() async {
var response = await http.get(
"https://api.pexels.com/v1/curated?per_page=15&page=1",
headers: {"Authorization": apikey});
//print(response.body.toString());
Map<String, dynamic> jsonData = jsonDecode(response.body);
jsonData["photos"].forEach((element) {
// print(element);
WallpaperModel wallpaperModel = new WallpaperModel();
wallpaperModel = WallpaperModel.fromMap(element);
wallpapers.add(wallpaperModel);
});
setState(() {});
}
@override
void initState() {
getTrendingWallpapers();
categories = getCategories();
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
title: brandName(),
elevation: 0.0,
),
body: SingleChildScrollView(
child: Column(
children: <Widget>[
Container(
padding: EdgeInsets.symmetric(horizontal: 24),
margin: EdgeInsets.symmetric(horizontal: 24),
decoration: BoxDecoration(
color: Color(0xfff5f8fd),
borderRadius: BorderRadius.circular(30)),
child: Row(
children: <Widget>[
Expanded(
child: TextField(
controller: searchcontroller,
decoration: InputDecoration(
hintText: "search", border: InputBorder.none),
),
),
GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Search(
searchQuery: searchcontroller.text,
)));
},
child: Container(child: Icon(Icons.search)),
)
],
),
),
Container(
//orignal 16 amogh changed to 8
height: 30,
margin: EdgeInsets.all(24),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("Made by "),
Text("Amogh Chavan",
style: TextStyle(
color: Colors.black87, fontFamily: 'Overpass'))
],
),
),
Container(
height: 80,
child: ListView.builder(
padding: EdgeInsets.symmetric(horizontal: 24),
shrinkWrap: true,
scrollDirection: Axis.horizontal,
itemCount: categories.length,
itemBuilder: (context, index) {
return CategoriesTile(
title: categories[index].categorieName,
imgUrl: categories[index].imgUrl);
}),
),
SizedBox(
height: 16,
),
wallpapersList(wallpapers: wallpapers, context: context),
Container(
//orignal 16 amogh changed to 8
height: 16,
margin: EdgeInsets.all(10),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("Powered by "),
Text("pexels",
style:
TextStyle(color: Colors.blue, fontFamily: 'Overpass'))
],
),
),
],
),
),
);
}
}
class CategoriesTile extends StatelessWidget {
final String imgUrl, title;
CategoriesTile({@required this.title, @required this.imgUrl});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Categorie(
categorieName: title.toLowerCase(),
)));
},
child: Container(
margin: EdgeInsets.only(right: 4),
child: Stack(
children: <Widget>[
// GestureDetector(
// onTap: () {
// Navigator.push(context,
// MaterialPageRoute(builder: (Context) => ImageView()));
// },
// child: Hero(
// tag: imgUrl,
// child:
ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Image.network(
imgUrl,
height: 50,
width: 100,
fit: BoxFit.cover,
)),
// ),
// ),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Colors.black26,
),
height: 50,
width: 100,
alignment: Alignment.center,
child: Text(
title,
style: TextStyle(
color: Colors.white, fontWeight: FontWeight.w500),
),
)
],
)));
}
}
| 0
|
mirrored_repositories/AestheticsFlutterApp-/lib
|
mirrored_repositories/AestheticsFlutterApp-/lib/model/categories_model.dart
|
class CategoriesModel {
String categorieName;
String imgUrl;
}
| 0
|
mirrored_repositories/AestheticsFlutterApp-/lib
|
mirrored_repositories/AestheticsFlutterApp-/lib/model/wallpaper_model.dart
|
class WallpaperModel {
String photographer;
String photographer_url;
int photographer_id;
SrcModel src;
WallpaperModel(
{this.src,
this.photographer,
this.photographer_id,
this.photographer_url});
factory WallpaperModel.fromMap(Map<String, dynamic> jsonData) {
return WallpaperModel(
//src: jsonData["src"],
photographer_url: jsonData["photographer_url"],
photographer_id: jsonData["photographer_id"],
photographer: jsonData["photographer"],
src: SrcModel.fromMap(jsonData["src"]));
}
}
class SrcModel {
String orignal;
String small;
String portrait;
SrcModel({this.orignal, this.portrait, this.small});
factory SrcModel.fromMap(Map<String, dynamic> jsonData) {
return SrcModel(
portrait: jsonData["portrait"],
orignal: jsonData["orignal"],
small: jsonData["samll"]);
}
}
| 0
|
mirrored_repositories/AestheticsFlutterApp-/lib
|
mirrored_repositories/AestheticsFlutterApp-/lib/widget/widget.dart
|
import 'package:flutter/material.dart';
import 'package:aesthetics/model/wallpaper_model.dart';
import 'package:aesthetics/views/image_view.dart';
Widget brandName() {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
"Aesth",
style: TextStyle(color: Colors.black87, fontFamily: 'Overpass'),
),
Text(
"etics",
style: TextStyle(color: Colors.blue, fontFamily: 'Overpass'),
)
],
);
}
Widget wallpapersList({List<WallpaperModel> wallpapers, context}) {
return Container(
padding: EdgeInsets.symmetric(horizontal: 16),
child: GridView.count(
shrinkWrap: true,
physics: ClampingScrollPhysics(),
crossAxisCount: 2,
childAspectRatio: 0.6,
mainAxisSpacing: 6.0,
crossAxisSpacing: 6.0,
children: wallpapers.map((wallpaper) {
return GridTile(
child: GestureDetector(
onTap: () {
print(wallpaper.src.portrait);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ImageView(
imgPath: wallpaper.src.portrait,
)));
},
child: Hero(
tag: wallpaper.src.portrait,
child: Container(
child: ClipRRect(
borderRadius: BorderRadius.circular(16),
child: Image.network(
wallpaper.src.portrait,
fit: BoxFit.cover,
)),
),
),
),
);
}).toList(),
),
);
}
| 0
|
mirrored_repositories/AestheticsFlutterApp-
|
mirrored_repositories/AestheticsFlutterApp-/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 that Flutter provides. 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:aesthetics/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(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/Flutter-Delivery-App
|
mirrored_repositories/Flutter-Delivery-App/lib/main.dart
|
// ignore_for_file: unused_import, prefer_const_constructors
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:meli_melo/controllers/popular_product_controller.dart';
import 'package:meli_melo/pages/cart/cart_page.dart';
import 'package:meli_melo/pages/food/popular_food_detail.dart';
import 'package:meli_melo/pages/food/recommended_food_detail.dart';
import 'package:meli_melo/pages/help/help_page.dart';
import 'package:meli_melo/pages/home/food_page_body.dart';
import 'package:meli_melo/pages/home/main_food_page.dart';
import 'package:meli_melo/routes/route_helper.dart';
import 'controllers/recommanded_product_controller.dart';
import 'helper/dependencies.dart' as dep;
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await dep.init();
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
Get.find<PopularProductController>().getPopularProductList();
Get.find<RecommendedProductController>().getRecommendedProductList();
return GetMaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
home: MainFoodPage(),
initialRoute: RouteHelper.initial,
getPages: RouteHelper.routes,
);
}
}
| 0
|
mirrored_repositories/Flutter-Delivery-App/lib
|
mirrored_repositories/Flutter-Delivery-App/lib/controllers/popular_product_controller.dart
|
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:meli_melo/controllers/cart_controller.dart';
import 'package:meli_melo/data/repersitory/popular_product_repo.dart';
import 'package:meli_melo/models/cart_model.dart';
import 'package:meli_melo/utils/colors.dart';
import '../models/products_model.dart';
class PopularProductController extends GetxController{
final PopularProductRepo popularProductRepo;
PopularProductController({required this.popularProductRepo});
List<ProductModel> _popularProductList = [];
List<ProductModel> get popularProductList =>_popularProductList;
late CartController _cart;
bool _isLoaded = false;
bool get isLoaded=>_isLoaded;
int _quantity=0;
int get quantity=>_quantity;
int _inCartItems=0;
int get inCartItems=>_inCartItems+_quantity;
Future<void> getPopularProductList() async {
Response response = await popularProductRepo.getPopularProductList();
if(response.statusCode == 200){
_popularProductList = [];
_popularProductList.addAll(Product.fromJson(response.body).products);
//print(_popularProductList);
_isLoaded=true;
update();
}else{
}
}
void setQuantity(bool isIncrement){
if(isIncrement){
_quantity=checkQuantity(_quantity+1);
//print("number of items "+_quantity.toString());
}else{
_quantity=checkQuantity(_quantity-1);
//print("decrement "+_quantity.toString());
}
update();
}
int checkQuantity(int quantity){
if((_inCartItems+quantity)<0){
Get.snackbar("Nombre d'article", "Vous ne pouvez commander moins !",
backgroundColor: AppColors.mainColor,
colorText: Colors.white,
);
if(_inCartItems>0){
_quantity = -_inCartItems;
return _quantity;
}
return 0;
}else if((_inCartItems+quantity)>20){
Get.snackbar("Nombre d'article", "Vous ne pouvez commander plus !",
backgroundColor: AppColors.mainColor,
colorText: Colors.white,
);
return 20;
}else{
return quantity;
}
}
void initProduct(ProductModel product, CartController cart){
_quantity=0;
_inCartItems=0;
_cart = cart;
var exist = false;
exist = _cart.existInCart(product);
//if exist
//get from storage _inCartItems=3
print("exist or not "+exist.toString());
if(exist){
_inCartItems=_cart.getQuantity(product);
}
print("the quantity is "+_inCartItems.toString());
}
void addItem(ProductModel product){
_cart.addItem(product, _quantity);
_quantity=0;
_inCartItems=_cart.getQuantity(product);
_cart.items.forEach((key, value) {
print("The id is "+value.id.toString()+" The quantity is "+value.quantity.toString());
});
update();
}
int get totalItems{
return _cart.totalItems;
}
List<CartModel> get getItems{
return _cart.getItems;
}
}
| 0
|
mirrored_repositories/Flutter-Delivery-App/lib
|
mirrored_repositories/Flutter-Delivery-App/lib/controllers/recommanded_product_controller.dart
|
import 'package:get/get.dart';
import 'package:meli_melo/data/repersitory/popular_product_repo.dart';
import '../data/repersitory/recommended_product_repo.dart';
import '../models/products_model.dart';
class RecommendedProductController extends GetxController{
final RecommendedProductRepo recommendedProductRepo;
RecommendedProductController({required this.recommendedProductRepo});
List<ProductModel> _recommendedProductList = [];
List<ProductModel> get recommendedProductList =>_recommendedProductList;
bool _isLoaded = false;
bool get isLoaded=>_isLoaded;
Future<void> getRecommendedProductList() async {
Response response = await recommendedProductRepo.getRecommendedProductList();
if(response.statusCode == 200){
print("got products recommended");
_recommendedProductList = [];
_recommendedProductList.addAll(Product.fromJson(response.body).products);
//print(_popularProductList);
_isLoaded=true;
update();
}else{
print("could not get products recommended");
}
}
}
| 0
|
mirrored_repositories/Flutter-Delivery-App/lib
|
mirrored_repositories/Flutter-Delivery-App/lib/controllers/cart_controller.dart
|
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:meli_melo/models/products_model.dart';
import '../data/repersitory/cart_repo.dart';
import '../models/cart_model.dart';
import '../utils/colors.dart';
class CartController extends GetxController{
final CartRepo cartRepo;
CartController({required this.cartRepo});
Map<int, CartModel> _items={};
Map<int, CartModel> get items=>_items;
void addItem(ProductModel product, int quantity){
var totalQuantity=0;
if(_items.containsKey(product.id!)){
_items.update(product.id!, (value) {
totalQuantity=value.quantity!+quantity;
return CartModel(
id: value.id,
name: value.name,
price: value.price,
img: value.img,
quantity:value.quantity!+quantity,
isExist:true,
time:DateTime.now().toString(),
);
});
if(totalQuantity<=0){
_items.remove(product.id);
}
}else{
if(quantity>0){
_items.putIfAbsent(product.id!, (){
return CartModel(
id: product.id,
name: product.name,
price: product.price,
img: product.img,
quantity:quantity,
isExist:true,
time:DateTime.now().toString(),
);}
);
}else{
Get.snackbar("Nombre d'article", "Vous devez ajouter au moin 1 articles !",
backgroundColor: AppColors.mainColor,
colorText: Colors.white,
);
}
}
}
bool existInCart(ProductModel product){
if(_items.containsKey(product.id)){
return true;
}else{
return false;
}
}
int getQuantity(ProductModel product){
var quantity= 0;
if(_items.containsKey(product.id)){
_items.forEach((key, value) {
if(key==product.id){
quantity = value.quantity!;
}
});
}
return quantity;
}
int get totalItems{
var totalQuantity=0;
_items.forEach((key, value) {
totalQuantity += value.quantity!;
});
return totalQuantity;
}
List<CartModel> get getItems{
return _items.entries.map((e) {
return e.value;
}).toList();
}
}
| 0
|
mirrored_repositories/Flutter-Delivery-App/lib
|
mirrored_repositories/Flutter-Delivery-App/lib/widgets/small_text.dart
|
import 'package:flutter/cupertino.dart';
class SmallText extends StatelessWidget {
Color? color;
final String text;
double size;
double height;
SmallText({ Key? key,
this.color = const Color(0xFFccc7c5),
required this.text,
this.size = 12,
this.height = 1.2,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Text(
text,
style: TextStyle(
color : color,
height: height
)
);
}
}
| 0
|
mirrored_repositories/Flutter-Delivery-App/lib
|
mirrored_repositories/Flutter-Delivery-App/lib/widgets/big_text.dart
|
import 'package:flutter/cupertino.dart';
import 'package:meli_melo/utils/dimensions.dart';
class BigText extends StatelessWidget {
Color? color;
final String text;
double size;
TextOverflow overFlow;
BigText({ Key? key, this.color = const Color(0xFF332d2b) ,
required this.text,
this.size=0,
this.overFlow = TextOverflow.ellipsis
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Text(
text,
overflow: overFlow,
style : TextStyle(
fontFamily: 'Roboto',
color: color,
fontSize : size==0?Dimensions.font20:size,
fontWeight: FontWeight.w400
),
);
}
}
| 0
|
mirrored_repositories/Flutter-Delivery-App/lib
|
mirrored_repositories/Flutter-Delivery-App/lib/widgets/icon_and_text_widget.dart
|
import 'package:flutter/cupertino.dart';
import 'package:meli_melo/widgets/small_text.dart';
import '../utils/dimensions.dart';
class IconAndTextWidget extends StatelessWidget {
final IconData icon;
final String text;
final Color iconColor;
const IconAndTextWidget({ Key? key ,
required this.icon,
required this.text,
required this.iconColor }) : super(key: key);
@override
Widget build(BuildContext context) {
return Row(
children: [
Icon(icon, color:iconColor,size: Dimensions.iconSize24, ),
SizedBox(width: 5,),
SmallText(text: text),
]
);
}
}
| 0
|
mirrored_repositories/Flutter-Delivery-App/lib
|
mirrored_repositories/Flutter-Delivery-App/lib/widgets/app_column.dart
|
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:meli_melo/widgets/small_text.dart';
import '../utils/colors.dart';
import '../utils/dimensions.dart';
import 'big_text.dart';
import 'icon_and_text_widget.dart';
class AppColumn extends StatelessWidget {
final String text;
const AppColumn({ Key? key, required this.text }) : super(key: key);
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start, // pointe les elements au debut
children: [
BigText(text:text, size : Dimensions.font26),
SizedBox(height:Dimensions.height10),
Row(
children: [
Wrap(
children: List.generate(5, (index) { return Icon(Icons.star, color:AppColors.mainColor, size: 15);}),
),
SizedBox(width: 10),
SmallText(text: "4.5"),
SizedBox(width: 10),
SmallText(text: "20"),
SizedBox(width: 5),
SmallText(text: "comments")
]
),
SizedBox(height: Dimensions.height20,),
//TIME AND DISTANCE
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconAndTextWidget(icon: Icons.circle_sharp,
text: "Normal",
iconColor : AppColors.iconColor1),
IconAndTextWidget(icon: Icons.location_on,
text: "1.7km",
iconColor : AppColors.mainColor),
IconAndTextWidget(icon: Icons.access_time_filled_rounded,
text: "32min",
iconColor : AppColors.iconColor2)
],
)
],
);
}
}
| 0
|
mirrored_repositories/Flutter-Delivery-App/lib
|
mirrored_repositories/Flutter-Delivery-App/lib/widgets/exandable_text_widget.dart
|
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:meli_melo/utils/colors.dart';
import 'package:meli_melo/widgets/small_text.dart';
import '../utils/dimensions.dart';
class ExpandableTextWidget extends StatefulWidget {
final String text;
const ExpandableTextWidget({ Key? key, required this.text }) : super(key: key);
@override
_ExpandableTextWidgetState createState() => _ExpandableTextWidgetState();
}
class _ExpandableTextWidgetState extends State<ExpandableTextWidget> {
late String firstHalf;
late String secondHalf;
bool hiddenText = true;
double textHeight = Dimensions.screenHeight/5.63;
@override
void initState(){
super.initState();
if(widget.text.length>textHeight){
firstHalf = widget.text.substring(0, textHeight.toInt());
secondHalf = widget.text.substring(textHeight.toInt()+1, widget.text.length);
}else{
firstHalf = widget.text;
secondHalf = "";
}
}
@override
Widget build(BuildContext context) {
return Container(
child: secondHalf.isEmpty?SmallText(height:1.8,color : AppColors.paraColor,size: Dimensions.font16,text: firstHalf):Column(
children: [
SmallText(height:1.8,color : AppColors.paraColor, size: Dimensions.font16,text:hiddenText?(firstHalf+"..."):(firstHalf+secondHalf)),
InkWell(
onTap: (){
setState(() {
hiddenText=!hiddenText;
});
},
child: Row(
children: [
SmallText(text: hiddenText?"Voir plus":"Voir moins", color: AppColors.mainColor,),
Icon(hiddenText?Icons.arrow_drop_down:Icons.arrow_drop_up, color: AppColors.mainColor,)
],
),
)
],
),
);
}
}
| 0
|
mirrored_repositories/Flutter-Delivery-App/lib
|
mirrored_repositories/Flutter-Delivery-App/lib/widgets/app_icon.dart
|
import 'package:flutter/cupertino.dart';
import 'package:meli_melo/utils/dimensions.dart';
class AppIcon extends StatelessWidget {
final IconData icon;
final Color backgroundColor;
final Color iconColor;
final double size;
final double iconSize;
AppIcon({ Key? key,
required this.icon,
this.backgroundColor = const Color(0xFFfcf4e4),
this.iconColor = const Color(0xFF756d54),
this.size = 40,
this.iconSize = 16
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
width: size,
height: size,
decoration: BoxDecoration(
borderRadius : BorderRadius.circular(size/2),
color: backgroundColor,
),
child : Icon(
icon,
color : iconColor,
size : iconSize
)
);
}
}
| 0
|
mirrored_repositories/Flutter-Delivery-App/lib
|
mirrored_repositories/Flutter-Delivery-App/lib/routes/route_helper.dart
|
import 'package:get/get.dart';
import 'package:meli_melo/pages/food/popular_food_detail.dart';
import 'package:meli_melo/pages/food/recommended_food_detail.dart';
import 'package:meli_melo/pages/home/main_food_page.dart';
import '../pages/cart/cart_page.dart';
class RouteHelper{
static const String initial="/";
static const String popularFood="/popular-food";
static const String recommendedFood="/recommended-food";
static const String cartPage = "/cart-page";
static String getInitial()=>'$initial';
static String getPopularFood(int pageId)=>'$popularFood?pageId=$pageId';
static String getRecommendedFood(int pageId)=>'$recommendedFood?pageId=$pageId';
static String getCartPage()=>'$cartPage';
static List<GetPage> routes=[
GetPage(name: initial, page: ()=>MainFoodPage()),
GetPage(name: popularFood, page: (){
var pageId=Get.parameters['pageId'];
return PopularFoodDetail(pageId:int.parse(pageId!));
},
transition: Transition.fadeIn
),
GetPage(name: recommendedFood, page: (){
var pageId=Get.parameters['pageId'];
return RecommendedFoodDetail(pageId:int.parse(pageId!));
},
transition: Transition.fadeIn
),
GetPage(name: cartPage, page:(){
return CartPage();
},
transition: Transition.fadeIn
)
];
}
| 0
|
mirrored_repositories/Flutter-Delivery-App/lib/pages
|
mirrored_repositories/Flutter-Delivery-App/lib/pages/cart/cart_page.dart
|
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:meli_melo/pages/home/main_food_page.dart';
import 'package:meli_melo/utils/app_constants.dart';
import 'package:meli_melo/utils/colors.dart';
import 'package:meli_melo/utils/dimensions.dart';
import 'package:meli_melo/widgets/app_icon.dart';
import 'package:meli_melo/widgets/big_text.dart';
import 'package:meli_melo/widgets/small_text.dart';
import 'package:get/get.dart';
import '../../controllers/cart_controller.dart';
import '../../routes/route_helper.dart';
class CartPage extends StatelessWidget {
const CartPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: [
Positioned(
top: Dimensions.height20*3,
left: Dimensions.width20,
right: Dimensions.width20,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
AppIcon(icon: Icons.arrow_back_ios,
iconColor: Colors.white,
backgroundColor: AppColors.mainColor,
iconSize: Dimensions.iconSize24,
),
SizedBox(width: Dimensions.width20*5,),
GestureDetector(
onTap: (){
Get.toNamed(RouteHelper.getInitial());
},
child: AppIcon(icon: Icons.home_outlined,
iconColor: Colors.white,
backgroundColor: AppColors.mainColor,
iconSize: Dimensions.iconSize24,
),
),
AppIcon(icon: Icons.shopping_cart,
iconColor: Colors.white,
backgroundColor: AppColors.mainColor,
iconSize: Dimensions.iconSize24,
),
],
)),
Positioned(
top:Dimensions.height20*5,
left: Dimensions.width20,
right: Dimensions.width20,
bottom: 0,
child: Container(
margin: EdgeInsets.only(top: Dimensions.height15),
//color: Colors.red,
child: MediaQuery.removePadding(
context: context,
removeTop: true,
child: GetBuilder<CartController>(builder: (cartController){
var _carList = cartController.getItems;
return ListView.builder(
itemCount: _carList.length,
itemBuilder:(_, index){
return Container(
width: double.maxFinite,
height: Dimensions.height20*5,
margin: EdgeInsets.only(bottom: Dimensions.height10),
child: Row(
children: [
Container(
width: Dimensions.height20*5,
height: Dimensions.height20*5,
decoration: BoxDecoration(
image: DecorationImage(
fit:BoxFit.cover,
image: NetworkImage(
AppConstants.BASE_URL+AppConstants.UPLOAD_URL+cartController.getItems[index].img!
)
),
borderRadius: BorderRadius.circular(Dimensions.radius20),
color: Colors.white
),
),
SizedBox(width: Dimensions.width10,),
Expanded(child: Container(
height: Dimensions.radius20*5,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
BigText(text: cartController.getItems[index].name!, color: Colors.black54,),
SmallText(text: "Epicé"),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
BigText(text: "\$ "+cartController.getItems[index].price!.toString(), color: Colors.redAccent,),
Container(
padding: EdgeInsets.only(top: Dimensions.height10, bottom: Dimensions.height10, left: Dimensions.width10,right: Dimensions.width10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(Dimensions.radius20),
color: Colors.white
),
child: Row(
children: [
GestureDetector(
onTap: (){
//popularProduct.setQuantity(false);
},
child: Icon(Icons.remove, color: AppColors.SignColor,)),
SizedBox(width: Dimensions.width10/2,),
BigText(text: _carList[index].quantity.toString()),//popularProduct.inCartItems.toString()),
SizedBox(width: Dimensions.width10/2,),
GestureDetector(
onTap: (){
//popularProduct.setQuantity(true);
},
child: Icon(Icons.add, color: AppColors.SignColor,))
],
),
)
],
)
],
),
))
],
),
);
});
}),
),
))
],
),
);
}
}
| 0
|
mirrored_repositories/Flutter-Delivery-App/lib/pages
|
mirrored_repositories/Flutter-Delivery-App/lib/pages/help/help_page.dart
|
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:meli_melo/pages/home/food_page_body.dart';
import 'package:meli_melo/pages/home/main_food_page.dart';
import 'package:meli_melo/widgets/small_text.dart';
import '../../routes/route_helper.dart';
import '../../utils/colors.dart';
import '../../utils/dimensions.dart';
import '../../widgets/app_icon.dart';
import '../../widgets/big_text.dart';
class HelpPage extends StatelessWidget {
const HelpPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: [
Positioned(
top: Dimensions.height20*3,
left: Dimensions.width20,
right: Dimensions.width20,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
AppIcon(icon: Icons.arrow_back_ios,
iconColor: Colors.white,
backgroundColor: AppColors.mainColor,
iconSize: Dimensions.iconSize24,
),
SizedBox(width: Dimensions.width20*5,),
GestureDetector(
onTap: (){
//Get.toNamed(RouteHelper.getInitial());
Get.to(MainFoodPage());
},
child: AppIcon(icon: Icons.home_outlined,
iconColor: Colors.white,
backgroundColor: AppColors.mainColor,
iconSize: Dimensions.iconSize24,
),
),
],
)),
Positioned(
top:Dimensions.height20*5,
left: Dimensions.width20,
right: Dimensions.width20,
child: Container(
margin: EdgeInsets.only(top: Dimensions.height15),
//color: Colors.red,
//child: GetBuilder<CartController>(builder: (cartController){
child: Row(
children: [
BigText(text: 'RUBRIQUE AIDE', ),
SizedBox(height:5 ),
],
),
),
),
],
),
);;
}
}
| 0
|
mirrored_repositories/Flutter-Delivery-App/lib/pages
|
mirrored_repositories/Flutter-Delivery-App/lib/pages/food/recommended_food_detail.dart
|
// ignore_for_file: prefer_const_constructors
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:meli_melo/controllers/popular_product_controller.dart';
import 'package:meli_melo/controllers/recommanded_product_controller.dart';
import 'package:meli_melo/pages/cart/cart_page.dart';
import 'package:meli_melo/utils/app_constants.dart';
import 'package:meli_melo/utils/colors.dart';
import 'package:meli_melo/widgets/app_icon.dart';
import 'package:meli_melo/widgets/big_text.dart';
import 'package:meli_melo/widgets/exandable_text_widget.dart';
import 'package:get/get.dart';
import '../../controllers/cart_controller.dart';
import '../../routes/route_helper.dart';
import '../../utils/dimensions.dart';
class RecommendedFoodDetail extends StatelessWidget {
final int pageId;
const RecommendedFoodDetail({ Key? key, required this.pageId }) : super(key: key);
@override
Widget build(BuildContext context) {
var product = Get.find<RecommendedProductController>().recommendedProductList[pageId];
Get.find<PopularProductController>().initProduct(product, Get.find<CartController>());
return Scaffold(
backgroundColor: Colors.white,
body: CustomScrollView(
slivers : [
SliverAppBar(
automaticallyImplyLeading: false,
toolbarHeight: 70,
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
GestureDetector(
onTap: (){
Get.toNamed(RouteHelper.getInitial());
},
child:AppIcon(icon: Icons.clear),
),
//AppIcon(icon: Icons.shopping_cart_outlined)
GetBuilder<PopularProductController>(builder: (controller){
return GestureDetector(
onTap: (){
if(controller.totalItems>=1)
Get.toNamed(RouteHelper.getCartPage());
},
child: Stack(
children: [
AppIcon(icon: Icons.shopping_cart_checkout_outlined),
Get.find<PopularProductController>().totalItems>=1?
Positioned(
right:0, top: 0,
child: AppIcon(icon: Icons.circle, size: 20,
iconColor: Colors.transparent,
backgroundColor: Colors.red,),
):
Container(),
Get.find<PopularProductController>().totalItems>=1?
Positioned(
right:5, top: 3,
child: BigText(text: Get.find<PopularProductController>().totalItems.toString(),
size:12, color: Colors.white,
),
):
Container()
],
),
);
})
],
),
bottom: PreferredSize(
preferredSize: Size.fromHeight(20),
child: Container(
child: Center(child: BigText(size : Dimensions.font26,text: product.name!),),
width: double.maxFinite,
padding: EdgeInsets.only(top: 5, bottom: 10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topRight: Radius.circular(Dimensions.radius20),
topLeft: Radius.circular(Dimensions.radius20)
)
),
) ,
),
pinned: true,
backgroundColor: AppColors.mainColor,
expandedHeight: 300,
flexibleSpace: FlexibleSpaceBar(
background : Image.network(
AppConstants.BASE_URL+AppConstants.UPLOAD_URL+product.img!,
width :double.maxFinite,
fit: BoxFit.cover,
),
),
),
SliverToBoxAdapter(
child: Column(
children: [
Container(
child : ExpandableTextWidget(text: product.description!,),
margin : EdgeInsets.only(left: Dimensions.width20, right: Dimensions.width20),
)
],
),
)
]
),
bottomNavigationBar: GetBuilder<PopularProductController>(builder: (controller){
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
padding: EdgeInsets.only(
left: Dimensions.width20*2.5,
right: Dimensions.width20*2.5,
top: Dimensions.height10,
bottom: Dimensions.height10
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
GestureDetector(
onTap: (){
controller.setQuantity(false);
},
child: AppIcon(
iconSize: Dimensions.iconSize24,
iconColor : Colors.white,
backgroundColor : AppColors.mainColor,
icon: Icons.remove)
),
BigText(text: "\$ ${product.price!} X ${controller.inCartItems} ", color: AppColors.mainBlackColor, size: Dimensions.font26),
GestureDetector(
onTap: (){
controller.setQuantity(true);
},
child: AppIcon(
iconSize: Dimensions.iconSize24,
iconColor : Colors.white,
backgroundColor : AppColors.mainColor,
icon: Icons.add)
)
],
),
),
Container(
height: Dimensions.bottomHeightBar,
padding: EdgeInsets.only(top: Dimensions.height20, bottom: Dimensions.height20, left: Dimensions.width20, right: Dimensions.width20),
decoration: BoxDecoration(
color: AppColors.buttonBackgroundColor,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(Dimensions.radius20*2),
topRight: Radius.circular(Dimensions.radius20*2)
)
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
padding: EdgeInsets.only(top: Dimensions.height20, bottom: Dimensions.height20, left: Dimensions.width20,right: Dimensions.width20),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(Dimensions.radius20),
color: Colors.white
),
child: Icon(
Icons.favorite,
color: AppColors.mainColor,
),
),
GestureDetector(
onTap: (){
controller.addItem(product);
},
child: Container(
padding: EdgeInsets.only(top: Dimensions.height20, bottom: Dimensions.height20, left: Dimensions.width20,right: Dimensions.width20),
child: BigText(text: "\$ ${product.price} | Ajouter", color: Colors.white,),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(Dimensions.radius20),
color: AppColors.mainColor
),
),
)
],
),
)
],
);
}),
);
}
}
| 0
|
mirrored_repositories/Flutter-Delivery-App/lib/pages
|
mirrored_repositories/Flutter-Delivery-App/lib/pages/food/popular_food_detail.dart
|
// ignore_for_file: prefer_const_constructors
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:meli_melo/controllers/cart_controller.dart';
import 'package:meli_melo/controllers/popular_product_controller.dart';
import 'package:meli_melo/pages/cart/cart_page.dart';
import 'package:meli_melo/utils/app_constants.dart';
import 'package:meli_melo/widgets/app_column.dart';
import 'package:meli_melo/widgets/app_icon.dart';
import 'package:meli_melo/widgets/exandable_text_widget.dart';
import '../../routes/route_helper.dart';
import '../../utils/colors.dart';
import '../../utils/dimensions.dart';
import '../../widgets/big_text.dart';
import '../../widgets/icon_and_text_widget.dart';
import '../../widgets/small_text.dart';
import '../home/main_food_page.dart';
class PopularFoodDetail extends StatelessWidget {
final int pageId;
const PopularFoodDetail({ Key? key , required this.pageId}) : super(key: key);
@override
Widget build(BuildContext context) {
var product= Get.find<PopularProductController>().popularProductList[pageId];
Get.find<PopularProductController>().initProduct(product, Get.find<CartController>());
return Scaffold(
backgroundColor: Colors.white,
body: Stack(
children:[
//BACKGROUND IMAGE
Positioned(
left : 0,
right : 0,
child: Container(
width: double.maxFinite,
height: Dimensions.popularFoodImgSize,
decoration: BoxDecoration(
image : DecorationImage(
fit : BoxFit.cover,
image : NetworkImage(
AppConstants.BASE_URL+AppConstants.UPLOAD_URL+product.img!
)
)
),
)
),
//ICON WIDGETS
Positioned(
top: Dimensions.height45,
left: Dimensions.width20,
right: Dimensions.width20,
child: Row(
mainAxisAlignment : MainAxisAlignment.spaceBetween,
children: [
GestureDetector(
onTap:(){
Get.to(()=>MainFoodPage());
},
child:
AppIcon(icon: Icons.arrow_back_ios)
),
GetBuilder<PopularProductController>(builder: (controller){
return GestureDetector(
onTap: (){
if(controller.totalItems>=1)
Get.toNamed(RouteHelper.getCartPage());
},
child: Stack(
children: [
AppIcon(icon: Icons.shopping_cart_checkout_outlined),
controller.totalItems>=1?
Positioned(
right:0, top: 0,
child: AppIcon(icon: Icons.circle, size: 20,
iconColor: Colors.transparent,
backgroundColor: Colors.red,),
):
Container(),
Get.find<PopularProductController>().totalItems>=1?
Positioned(
right:5, top: 3,
child: BigText(text: Get.find<PopularProductController>().totalItems.toString(),
size:12, color: Colors.white,
),
):
Container()
],
),
);
})
],
)),
//INTRODUCTION TO FOOD
Positioned(
left: 0,
right: 0,
bottom: 0,
top: Dimensions.popularFoodImgSize - 20,
child: Container(
padding: EdgeInsets.only(left: Dimensions.width20, right: Dimensions.width20, top: Dimensions.height20),
decoration: BoxDecoration(
borderRadius : BorderRadius.only(
topRight: Radius.circular(Dimensions.radius20),
topLeft : Radius.circular(Dimensions.radius20)
),
color: Colors.white,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AppColumn(text:product.name!),
SizedBox(height: Dimensions.height20,),
BigText(text: "Introduction",),
SizedBox(height: Dimensions.height20,),
Expanded(child: SingleChildScrollView(child: ExpandableTextWidget(text: product.description!)))
],
),
))
],
),
bottomNavigationBar: GetBuilder<PopularProductController>(builder: (popularProduct){
return Container(
height: Dimensions.bottomHeightBar,
padding: EdgeInsets.only(top: Dimensions.height20, bottom: Dimensions.height20, left: Dimensions.width20, right: Dimensions.width20),
decoration: BoxDecoration(
color: AppColors.buttonBackgroundColor,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(Dimensions.radius20*2),
topRight: Radius.circular(Dimensions.radius20*2)
)
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
padding: EdgeInsets.only(top: Dimensions.height20, bottom: Dimensions.height20, left: Dimensions.width20,right: Dimensions.width20),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(Dimensions.radius20),
color: Colors.white
),
child: Row(
children: [
GestureDetector(
onTap: (){
popularProduct.setQuantity(false);
},
child: Icon(Icons.remove, color: AppColors.SignColor,)),
SizedBox(width: Dimensions.width10/2,),
BigText(text: popularProduct.inCartItems.toString()),
SizedBox(width: Dimensions.width10/2,),
GestureDetector(
onTap: (){
popularProduct.setQuantity(true);
},
child: Icon(Icons.add, color: AppColors.SignColor,))
],
),
),
GestureDetector(
onTap: (){
popularProduct.addItem(product);
},
child: Container(
padding: EdgeInsets.only(top: Dimensions.height20, bottom: Dimensions.height20, left: Dimensions.width20,right: Dimensions.width20),
child: BigText(text: "\$ ${product.price!} | Ajouter", color: Colors.white,),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(Dimensions.radius20),
color: AppColors.mainColor
),
),
)
],
),
);
},),
);
}
}
| 0
|
mirrored_repositories/Flutter-Delivery-App/lib/pages
|
mirrored_repositories/Flutter-Delivery-App/lib/pages/home/food_page_body.dart
|
// ignore_for_file: avoid_unnecessary_containers, unnecessary_new, prefer_const_constructors, duplicate_ignore, unnecessary_import, avoid_single_cascade_in_expression_statements, unused_field, prefer_const_literals_to_create_immutables, prefer_final_fields
import 'package:dots_indicator/dots_indicator.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:meli_melo/controllers/popular_product_controller.dart';
import 'package:meli_melo/controllers/recommanded_product_controller.dart';
import 'package:meli_melo/models/products_model.dart';
import 'package:meli_melo/pages/food/popular_food_detail.dart';
import 'package:meli_melo/pages/food/recommended_food_detail.dart';
import 'package:meli_melo/routes/route_helper.dart';
import 'package:meli_melo/utils/app_constants.dart';
import 'package:meli_melo/utils/dimensions.dart';
import 'package:meli_melo/widgets/app_column.dart';
import 'package:meli_melo/widgets/icon_and_text_widget.dart';
import 'package:meli_melo/widgets/small_text.dart';
import 'package:get/get.dart';
import '../../utils/colors.dart';
import '../../widgets/big_text.dart';
class FoodPageBody extends StatefulWidget {
const FoodPageBody({ Key? key }) : super(key: key);
@override
_FoodPageBodyState createState() => _FoodPageBodyState();
}
class _FoodPageBodyState extends State<FoodPageBody> {
PageController pageController = PageController(viewportFraction: 0.85);
var _currPageValue = 0.0;
double _scaleFactor = 0.8;
double _height = 220;
@override
void initState(){
super.initState();
pageController.addListener(() {
setState((){
_currPageValue = pageController.page!;
});
});
}
@override
void dispose(){
pageController.dispose();
}
@override
Widget build(BuildContext context) {
return Column(
children: [
//SLIDER SECTION
GetBuilder<PopularProductController>(builder:(popularProducts){
return popularProducts.isLoaded?Container(
//color: Colors.redAccent,
height: Dimensions.pageView,
child: PageView.builder(
controller : pageController,
itemCount:popularProducts.popularProductList.length,
itemBuilder: (context, position){
return _buildPageItem(position, popularProducts.popularProductList[position]);
}),
):CircularProgressIndicator(
color: AppColors.mainColor,
);
}),
// DOTS SECTION
GetBuilder<PopularProductController>(builder: (popularProducts){
return new DotsIndicator(
dotsCount:popularProducts.popularProductList.isEmpty?1:popularProducts.popularProductList.length,
position: _currPageValue,
decorator: DotsDecorator(
activeColor : AppColors.mainColor,
size: const Size.square(9.0),
activeSize:const Size(18.0, 9.0),
activeShape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)),
)
);
}),
//POPULAR TEXT
SizedBox(height: Dimensions.height30,),
Container(
margin: EdgeInsets.only(left: Dimensions.width30),
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children:[
BigText(text: "Recommandés"),
SizedBox(width:Dimensions.width10,),
Container(
margin: const EdgeInsets.only(bottom:3),
child: BigText(text: ".", color: Colors.black26),
),
SizedBox(width:Dimensions.width10,),
Container(
margin: const EdgeInsets.only(bottom:2),
child: SmallText(text: "Details"),
)
]
),
),
//RECOMMENDED FOOD
//LIST OF FOOD AND IMAGES
GetBuilder<RecommendedProductController>(builder: (recommendedProduct){
return recommendedProduct.isLoaded?ListView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: recommendedProduct.recommendedProductList.length,
itemBuilder: (context, index){
return GestureDetector(
onTap: (){
Get.toNamed(RouteHelper.getRecommendedFood(index));
},
child: Container(
margin: EdgeInsets.only(left: Dimensions.width20, right: Dimensions.width20, bottom: Dimensions.width10),
child: Row(
children: [
//IMAGE SECTION
Container(
width: Dimensions.listViewImgSize,
height: Dimensions.listViewImgSize,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(Dimensions.radius20),
color: Colors.white38,
image: DecorationImage(
fit: BoxFit.cover,
image: NetworkImage(
AppConstants.BASE_URL+AppConstants.UPLOAD_URL+recommendedProduct.recommendedProductList[index].img!
)
)
)
),
//TEXT CONTAINER
Expanded(
child: Container(
height : Dimensions.listViewTextContSize,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topRight : Radius.circular(Dimensions.radius20),
bottomRight: Radius.circular(Dimensions.radius20)
),
color: Colors.white,
),
child : Padding(
padding : EdgeInsets.only(left : Dimensions.width10, right : Dimensions.width10),
child: Column(
crossAxisAlignment : CrossAxisAlignment.start,
mainAxisAlignment : MainAxisAlignment.center,
children : [
BigText(text: recommendedProduct.recommendedProductList[index].name!),
SizedBox(height : Dimensions.height10,),
SmallText(text: "Spécialité du chef ",),
SizedBox(height : Dimensions.height10),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconAndTextWidget(icon: Icons.circle_sharp,
text: "Normal",
iconColor : AppColors.iconColor1),
IconAndTextWidget(icon: Icons.location_on,
text: "1.7km",
iconColor : AppColors.mainColor),
IconAndTextWidget(icon: Icons.access_time_filled_rounded,
text: "3min",
iconColor : AppColors.iconColor2)
],
)
]
)
)
),
)
],
)
),
);
}):CircularProgressIndicator(
color: AppColors.mainColor,
);
})
],
);
}
Widget _buildPageItem(int index, ProductModel popularProduct){
Matrix4 matrix = new Matrix4.identity();
if(index==_currPageValue.floor()){
var currScale = 1-(_currPageValue-index)*(1-_scaleFactor);
var currTrans = _height*(1-currScale)/2;
matrix = Matrix4.diagonal3Values(1, currScale, 1)..setTranslationRaw(0, currTrans, 0);
}else if(index == _currPageValue.floor()+1){
var currScale = _scaleFactor+(_currPageValue-index+1)*(1-_scaleFactor);
var currTrans = _height*(1-currScale)/2;
matrix = Matrix4.diagonal3Values(1, currScale, 1);
matrix = Matrix4.diagonal3Values(1, currScale, 1)..setTranslationRaw(0, currTrans, 0);
}else if(index == _currPageValue.floor()-1){
var currScale = 1-(_currPageValue-index)*(1-_scaleFactor); var currTrans = _height*(1-currScale)/2;
matrix = Matrix4.diagonal3Values(1, currScale, 1);
matrix = Matrix4.diagonal3Values(1, currScale, 1)..setTranslationRaw(0, currTrans, 0);
}else {
var currScale = 0.8;
matrix = Matrix4.diagonal3Values(1, currScale, 1)..setTranslationRaw(0, _height*(1-_scaleFactor)/2, 1);
}
return Transform(
transform: matrix,
child: Stack(
children: [
GestureDetector(
onTap: (){
Get.toNamed(RouteHelper.getPopularFood(index));
},
child: Container(
height: Dimensions.pageViewContainer,
margin: EdgeInsets.only(left: Dimensions.width10, right: Dimensions.width10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(Dimensions.radius30),
color: index.isEven?Color(0xFF69c5df):Color(0xFF9294cc),
// ignore: prefer_const_constructors
image: DecorationImage(
fit: BoxFit.cover,
// ignore: prefer_const_constructors
image: NetworkImage(
AppConstants.BASE_URL+AppConstants.UPLOAD_URL+popularProduct.img!
)
)
),
),
),
Align(
alignment: Alignment.bottomCenter,
child: Container(
height: Dimensions.pageViewTextContainer,
margin: EdgeInsets.only(left: Dimensions.width30, right: Dimensions.width30, bottom: Dimensions.height30),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(Dimensions.radius20),
color: Colors.white,
boxShadow: [
BoxShadow(
color: Color(0xFFe8e8e8),
blurRadius: 5.0,
offset: Offset(0,5)
),
BoxShadow(
color: Colors.white,
offset: Offset(-5, 0)
),
BoxShadow(
color: Colors.white,
offset: Offset(-5, 0)
)
]
// ignore: prefer_const_constructors
),
child: Container(
padding: EdgeInsets.only(top:Dimensions.height15, left: 15, right:15),
child: AppColumn(text: popularProduct.name!),
),
),
)
]
),
);
}
}
| 0
|
mirrored_repositories/Flutter-Delivery-App/lib/pages
|
mirrored_repositories/Flutter-Delivery-App/lib/pages/home/main_food_page.dart
|
// ignore_for_file: prefer_const_constructors, avoid_unnecessary_containers, unnecessary_import, duplicate_ignore
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:meli_melo/pages/help/help_page.dart';
import 'package:meli_melo/utils/colors.dart';
import 'package:meli_melo/widgets/big_text.dart';
import 'package:meli_melo/widgets/small_text.dart';
import '../../utils/dimensions.dart';
import 'food_page_body.dart';
class MainFoodPage extends StatefulWidget {
const MainFoodPage({ Key? key }) : super(key: key);
@override
_MainFoodPageState createState() => _MainFoodPageState();
}
class _MainFoodPageState extends State<MainFoodPage> {
@override
Widget build(BuildContext context) {
// ignore: prefer_const_constructors
return Scaffold(
body: Column(
children: [
//showing the header
Container(
child: Container(
margin: EdgeInsets.only(top:Dimensions.height45, bottom:Dimensions.height15),
padding: EdgeInsets.only(left:Dimensions.width20, right:Dimensions.width20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
// ignore: prefer_const_literals_to_create_immutables
children: [
BigText(text: "Sénégal", color: AppColors.mainColor ),
Row(
children: [
SmallText(text: "Dakar", color: Colors.black54),
Icon(Icons.arrow_drop_down_rounded)
],
)
],
),
Center(
child: Container(
width:Dimensions.height45,
height: Dimensions.height45,
child: GestureDetector(
onTap: (){
Get.to(HelpPage());
},
child: Icon(Icons.help_outlined, color:Colors.white, size: Dimensions.iconSize24)),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(Dimensions.radius15),
color: AppColors.mainColor,
),
)),
],)
),
),
//showing the body
Expanded(child: SingleChildScrollView(
child: FoodPageBody(),
)),
],
),
);
}
}
| 0
|
mirrored_repositories/Flutter-Delivery-App/lib
|
mirrored_repositories/Flutter-Delivery-App/lib/models/products_model.dart
|
class Product {
int? _totalSize;
int? _typeId;
int? _offset;
late List<ProductModel> _products;
List<ProductModel> get products=>_products;
Product({required totalSize, required typeId, required offset, required products}){
this._totalSize=totalSize;
this._typeId=typeId;
this._offset=offset;
this._products=products;
}
Product.fromJson(Map<String, dynamic> json) {
_totalSize = json['total_size'];
_typeId = json['type_id'];
_offset = json['offset'];
if (json['products'] != null) {
_products = <ProductModel>[];
json['products'].forEach((v) {
_products.add(ProductModel.fromJson(v));
});
}
}
}
class ProductModel {
int? id;
String? name;
String? description;
int? price;
int? stars;
String? img;
String? location;
String? createdAt;
String? updatedAt;
int? typeId;
ProductModel(
{this.id,
this.name,
this.description,
this.price,
this.stars,
this.img,
this.location,
this.createdAt,
this.updatedAt,
this.typeId});
ProductModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
description = json['description'];
price = json['price'];
stars = json['stars'];
img = json['img'];
location = json['location'];
createdAt = json['created_at'];
updatedAt = json['updated_at'];
typeId = json['type_id'];
}
}
| 0
|
mirrored_repositories/Flutter-Delivery-App/lib
|
mirrored_repositories/Flutter-Delivery-App/lib/models/cart_model.dart
|
class CartModel {
int? id;
String? name;
int? price;
String? img;
int? quantity;
bool? isExist;
String? time;
CartModel(
{this.id,
this.name,
this.price,
this.img,
this.quantity,
this.isExist,
this.time,
});
CartModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
price = json['price'];
img = json['img'];
quantity = json['quantity'];
isExist = json['isExist'];
time = json['time'];
}
}
| 0
|
mirrored_repositories/Flutter-Delivery-App/lib/data
|
mirrored_repositories/Flutter-Delivery-App/lib/data/api/api_client.dart
|
import 'package:get/get.dart';
import '../../utils/app_constants.dart';
class ApiClient extends GetConnect implements GetxService{
late String token;
final String appBaseUrl;
late Map<String , String> _mainHeaders;
ApiClient({required this.appBaseUrl}){
baseUrl = appBaseUrl;
timeout = Duration(seconds:30);
token = AppConstants.TOKEN;
_mainHeaders = {
'Content-type':'application/json; charset=UTF-8',
'Authorization' : 'Bearer $token',
};
}
Future<Response> getData(String uri,) async {
try{
Response response = await get(uri);
return response;
}catch(e){
return Response(statusCode: 1, statusText: e.toString());
}
}
}
| 0
|
mirrored_repositories/Flutter-Delivery-App/lib/data
|
mirrored_repositories/Flutter-Delivery-App/lib/data/repersitory/popular_product_repo.dart
|
import 'package:get/get.dart';
import 'package:meli_melo/data/api/api_client.dart';
import '../../utils/app_constants.dart';
class PopularProductRepo extends GetxService{
final ApiClient apiClient;
PopularProductRepo({required this.apiClient});
Future<Response> getPopularProductList() async{
return await apiClient.getData(AppConstants.POPULAR_PRODUCT_URI);
}
}
| 0
|
mirrored_repositories/Flutter-Delivery-App/lib/data
|
mirrored_repositories/Flutter-Delivery-App/lib/data/repersitory/cart_repo.dart
|
class CartRepo{
}
| 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.