repo_id
stringlengths 21
168
| file_path
stringlengths 36
210
| content
stringlengths 1
9.98M
| __index_level_0__
int64 0
0
|
---|---|---|---|
mirrored_repositories/Corona-Meter-App/lib | mirrored_repositories/Corona-Meter-App/lib/screens/faq_screen.dart | import 'package:flutter/material.dart';
import 'package:coronameterapp/faqsource.dart';
class FAQscreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text('FAQs'),
flexibleSpace: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: <Color>[
Color(0xFF3383CD),
Color(0xFF11249F),
],
),
),
),
),
body: ListView.builder(
itemCount: FAQsource.FAQ.length,
itemBuilder: (context,index){
return ExpansionTile(
title: Text(
FAQsource.FAQ[index]['question'],
style: TextStyle(fontWeight: FontWeight.bold,fontSize: 18),
),
children: <Widget>[
Padding(
padding: const EdgeInsets.all(10.0),
child: Text(
FAQsource.FAQ[index]['answer'],
style: TextStyle(
fontSize: 18,
),
),
),
],
);
}),
);
}
}
| 0 |
mirrored_repositories/Corona-Meter-App/lib | mirrored_repositories/Corona-Meter-App/lib/screens/aboutscreen.dart | import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
class AboutScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text('About COVID 19'),
flexibleSpace: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: <Color>[
Color(0xFF3383CD),
Color(0xFF11249F),
],
),
),
),
),
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
Center(
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.blue[100],
),
padding: EdgeInsets.all(10),
child: Text(
'Symptoms',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18,
),
),
),
),
Container(
padding: EdgeInsets.only(top: 10),
height: 280,
child: ListView(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
children: <Widget>[
Container(
margin: EdgeInsets.all(10),
width: 200,
child: Column(
children: <Widget>[
Image.asset('images/cough.jpg'),
Container(
padding: EdgeInsets.all(10),
width: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(10),bottomRight: Radius.circular(10)),
color: Colors.blue[100],
),
child: Center(
child: Text(
'Cough',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold
),
),
),
),
],
),
),
Container(
margin: EdgeInsets.all(10),
width: 200,
child: Column(
children: <Widget>[
Image.asset('images/highfever.jpg'),
Container(
padding: EdgeInsets.all(12),
width: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(10),bottomRight: Radius.circular(10)),
color: Colors.blue[100],
),
child: Center(
child: Text(
'High Fever',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold
),
),
),
),
],
),
),
Container(
margin: EdgeInsets.all(10),
width: 200,
child: Column(
children: <Widget>[
Image.asset('images/pneumonia.jpg'),
Container(
padding: EdgeInsets.all(10),
width: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(10),bottomRight: Radius.circular(10)),
color: Colors.blue[100],
),
child: Center(
child: Text(
'Pneumonia',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold
),
),
),
),
],
),
),
Container(
margin: EdgeInsets.all(10),
width: 200,
child: Column(
children: <Widget>[
Image.asset('images/runnynose.jpg'),
Container(
padding: EdgeInsets.all(10),
width: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(10),bottomRight: Radius.circular(10)),
color: Colors.blue[100],
),
child: Center(
child: Text(
'Runny Nose',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold
),
),
),
),
],
),
),
],
),
),
Center(
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.blue[100],
),
padding: EdgeInsets.all(10),
child: Text(
'Prevention',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18,
),
),
),
),
Container(
padding: EdgeInsets.all(10),
height: 280,
child: ListView(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
children: <Widget>[
Container(
margin: EdgeInsets.all(10),
child: Column(
children: <Widget>[
Expanded(
child: Container(
padding: EdgeInsets.all(10),
color: Colors.green[100],
child: CircleAvatar(
backgroundImage: AssetImage('images/wearmasks.jpg'),
radius: 80,
),
),
),
Container(
width: 180,
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(10),bottomRight: Radius.circular(10)),
color: Colors.blue[100],
),
child: Center(
child: Text(
'Wear Masks',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold
),
),
),
),
],
),
),
Container(
margin: EdgeInsets.all(10),
child: Column(
children: <Widget>[
Expanded(
child: Container(
padding: EdgeInsets.all(10),
color: Colors.green[100],
child: CircleAvatar(
backgroundImage: AssetImage('images/cleanhands.jpg'),
radius: 80,
),
),
),
Container(
width: 180,
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(10),bottomRight: Radius.circular(10)),
color: Colors.blue[100],
),
child: Center(
child: Text(
'Wash Hands',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold
),
),
),
),
],
),
),
Container(
margin: EdgeInsets.all(10),
child: Column(
children: <Widget>[
Expanded(
child: Container(
padding: EdgeInsets.all(10),
color: Colors.green[100],
child: CircleAvatar(
backgroundImage: AssetImage('images/sanitizer.jpg'),
radius: 80,
),
),
),
Container(
width: 180,
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(10),bottomRight: Radius.circular(10)),
color: Colors.blue[100],
),
child: Center(
child: Text(
'Use sanitizers',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold
),
),
),
),
],
),
),
Container(
margin: EdgeInsets.all(10),
child: Column(
children: <Widget>[
Expanded(
child: Container(
padding: EdgeInsets.all(10),
color: Colors.green[100],
child: CircleAvatar(
backgroundImage: AssetImage('images/avoidcrowd.jpg'),
radius: 80,
),
),
),
Container(
width: 180,
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(10),bottomRight: Radius.circular(10)),
color: Colors.blue[100],
),
child: Center(
child: Text(
'Avoid Crowd',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold
),
),
),
),
],
),
),
],
),
),
Container(
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
color: Colors.blue[200],
borderRadius: BorderRadius.circular(10),
),
child: Column(
children: <Widget>[
Text(
'To know more about COVID-19, it\'s symptoms and preventions,please refer our FAQs section or WHO official website. ',
style: TextStyle(
fontSize: 15,
),
),
RaisedButton(
onPressed: (){
launch('https://www.who.int/health-topics/coronavirus#tab=tab_1');
},
color: Colors.blue,
splashColor: Colors.green,
child: Text(
'Go to WHO website',
style: TextStyle(
color: Colors.black,
),
),
),
],
),
),
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/Corona-Meter-App/lib | mirrored_repositories/Corona-Meter-App/lib/screens/home_screen.dart | import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../header.dart';
import 'dart:convert';
import '../panels/worldwide_panel.dart';
import 'package:http/http.dart' as http;
import '../panels/mostAffected.dart';
import 'countryscreen.dart';
class HomeScreen extends StatefulWidget {
@override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
Map worldData;
List countryData;
void fetchData() async{
http.Response response = await http.get('https://corona.lmao.ninja/v2/all');
setState(() {
worldData = jsonDecode(response.body);
});
}
void fetchCountryData()async{
http.Response response = await http.get('https://corona.lmao.ninja/v2/countries?sort=deaths');
setState(() {
countryData = jsonDecode(response.body);
});
}
Future <void> refresh()async{
fetchData();
fetchCountryData();
}
@override
void initState() {
refresh();
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: RefreshIndicator(
onRefresh: refresh,
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Header(),
Padding(
padding: const EdgeInsets.only(left:10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
'Worldwide',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 25,
),
),
GestureDetector(
onTap: (){
Navigator.push(context, MaterialPageRoute(builder: (context){
return CountryScreen();
}));
},
child: Container(
margin: EdgeInsets.only(right: 10),
decoration: BoxDecoration(
color: Colors.indigo,
borderRadius: BorderRadius.circular(10),
),
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Text(
'Regional',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16,
color: Colors.white,
),
),
),
),
),
],
),
),
worldData==null?Container(
margin: EdgeInsets.only(top: 10,bottom: 10),
alignment: Alignment.center,
child: CircularProgressIndicator(),
): Worldwide(worldData:worldData),
Padding(
padding: const EdgeInsets.only(left: 10,top: 10),
child: Text(
'Afflicted Nations',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 25,
),
),
),
countryData==null?Container():MostAffected(countryData:countryData),
Container(
margin: EdgeInsets.symmetric(horizontal: 40,vertical: 20),
child: Center(
child: Text(
'Developed By: Akash Chaudhary\n Flutter Developer',
style: TextStyle(fontWeight: FontWeight.bold),
),
),
)
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/Corona-Meter-App/lib | mirrored_repositories/Corona-Meter-App/lib/screens/donate.dart | import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
class Donate extends StatefulWidget {
@override
_DonateState createState() => _DonateState();
}
class _DonateState extends State<Donate> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topRight,
end: Alignment.bottomLeft,
colors: [
Color(0xFF3383CD),
Color(0xFF11249F),
],
),
),
child: Padding(
padding: const EdgeInsets.all(15.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
CircleAvatar(
radius: 100,
backgroundImage: AssetImage('images/donate.jpg'),
),
SizedBox(height: 20),
Divider(
color: Colors.tealAccent,
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 10,horizontal: 10),
child: Text(
'\"We are together in this fight for survival,\nto triumph we all have to do our parts,lend a helping hand to the ones lost in this darkness.\" ',
style: TextStyle(
fontSize: 30,
color: Colors.white,
fontFamily: 'Dancing Script'
),
),
),
SizedBox(height: 30),
RaisedButton(
color: Colors.tealAccent,
onPressed: () {
launch(
'https://www.who.int/emergencies/diseases/novel-coronavirus-2019/donate');
},
child: Text('Donate'),
),
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/Corona-Meter-App/lib | mirrored_repositories/Corona-Meter-App/lib/screens/countryscreen.dart | import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
import '../panels/countrypanel.dart';
class CountryScreen extends StatefulWidget {
@override
_CountryScreenState createState() => _CountryScreenState();
}
class _CountryScreenState extends State<CountryScreen> {
String country;
Map countryInfo;
void fetchCountry(String searchText)async{
http.Response response = await http.get('https://corona.lmao.ninja/v2/countries/$searchText');
setState(() {
countryInfo = jsonDecode(response.body);
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomPadding: false,
backgroundColor: Colors.lightBlue[100],
appBar: AppBar(
centerTitle: true,
title: Text('Country Statistics'),
flexibleSpace: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: <Color>[
Color(0xFF3383CD),
Color(0xFF11249F),
],
),
),
),
),
body: SingleChildScrollView(
child: Column(
children: <Widget>[
Container(
padding: EdgeInsets.all(20),
child: Row(
children: <Widget>[
Expanded(
child: TextField(
decoration: InputDecoration(
hasFloatingPlaceholder: true,
labelText: 'Search Country',
labelStyle: TextStyle(
fontSize: 20,
color: Colors.black,
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
),
filled: true,
fillColor: Colors.blue[100],
suffixIcon: Icon(
Icons.search,
color: Colors.black,
),
),
onChanged: (value){
country = value;
},
),
),
SizedBox(width: 10),
Container(
height: 55,
width: 100,
child: RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
),
color: Colors.indigo,
splashColor: Colors.green,
padding: EdgeInsets.all(10),
child: Text(
'Search',
style: TextStyle(
fontSize: 20,
color: Colors.white,
),
),
onPressed: (){
FocusScope.of(context).requestFocus(new FocusNode());
fetchCountry(country);
},
),
),
],
),
),
countryInfo==null?Container(
margin: EdgeInsets.all(40),
child: Column(
children: <Widget>[
Image(image: AssetImage('images/circle-cropped.png'),),
Text(
'Corona Meter',
style: TextStyle(
color: Colors.blue[900],
fontWeight: FontWeight.bold,
fontSize: 50,
),
),
],
),
):CountryPanel(countryInfo: countryInfo,),
],
),
),
);
}
}
| 0 |
mirrored_repositories/Corona-Meter-App | mirrored_repositories/Corona-Meter-App/test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility 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:coronameterapp/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-UIs-Collection/pet_adoption_ui | mirrored_repositories/Flutter-UIs-Collection/pet_adoption_ui/lib/main.dart | import 'package:flutter/material.dart';
import 'package:pet_adoption_ui/src/app.dart';
void main() => runApp(App()); | 0 |
mirrored_repositories/Flutter-UIs-Collection/pet_adoption_ui/lib | mirrored_repositories/Flutter-UIs-Collection/pet_adoption_ui/lib/src/app.dart | import 'package:flutter/material.dart';
import 'package:pet_adoption_ui/src/pet_detail.dart';
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Pets adoption ui',
debugShowCheckedModeBanner: false,
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
List<String> items = ['Cats', 'Dogs', 'Birds', 'Others'];
var _selectedIndex = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
body: ListView(
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 28.0, left: 40.0),
child: CircleAvatar(
backgroundImage: AssetImage('assets/profile.jpg'),
radius: 25.0,
),
),
],
),
Padding(
padding:
const EdgeInsets.only(top: 48.0, left: 100.0, right: 100.0),
child: Text(
'Location',
style: TextStyle(color: Colors.grey[400], fontSize: 18.0),
),
),
Padding(
padding: const EdgeInsets.only(top: 18.0, left: 38.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Icon(
Icons.add_location,
color: Colors.black,
size: 40.0,
),
Padding(
padding: const EdgeInsets.only(left: 20.0),
child: Text(
'Luisville,',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
fontSize: 30.0),
),
),
Padding(
padding: const EdgeInsets.only(left: 10.0),
child: Text(
'KY',
style: TextStyle(color: Colors.black, fontSize: 30.0),
),
)
],
),
),
Padding(
padding: const EdgeInsets.only(top: 25.0, left: 40.0, right: 40.0),
child: Divider(
height: 2.0,
color: Colors.grey[300],
),
),
Padding(
padding: const EdgeInsets.only(top: 20.0, left: 40.0, right: 20.0),
child: SizedBox(
height: 70.0,
width: 300.0,
child: Row(
children: <Widget>[
Icon(
Icons.storage,
color: Colors.black,
size: 30.0,
),
Expanded(
child: ListView.builder(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
itemCount: items.length,
itemBuilder: (context, index) {
return Padding(
padding:
const EdgeInsets.only(left: 22.0, right: 14.0),
child: Material(
child: GestureDetector(
onTap: () {
setState(() {
_selectedIndex = index;
print('Selected index :$_selectedIndex');
});
},
child: Container(
height: index == _selectedIndex ? 140.0 : 150.0,
width: index == _selectedIndex ? 75.0 : 65.0,
decoration: BoxDecoration(
border: index == _selectedIndex
? Border.all(
color: Colors.red[100], width: 5)
: null,
borderRadius: BorderRadius.circular(15.0),
color: index == _selectedIndex
? Colors.red
: Colors.grey[300],
),
child: Center(
child: Text(
items[index],
style: TextStyle(
color: index == _selectedIndex
? Colors.white
: Colors.black),
),
),
),
),
),
);
},
),
)
],
),
),
),
Padding(
padding: const EdgeInsets.only(top: 80.0, left: 35.0),
child: SubSectionPage(_selectedIndex),
),
],
),
// body:
);
}
}
Widget SubSectionPage(int _currentIndex) {
List<String> listImages = [
'assets/image_three.jpg',
'assets/image_one.jpg',
'assets/image_two.jpg',
'assets/image_one.jpg',
'assets/image_one.jpg'
];
if (_currentIndex == 0) {
return Container(
height: 20.0,
width: 20.0,
child: Center(
child: Text(
'Cats page',
style: TextStyle(color: Colors.black, fontSize: 20.0),
)));
} else if (_currentIndex == 1) {
return ListView.builder(
shrinkWrap: true,
scrollDirection: Axis.vertical,
itemCount: listImages.length,
itemBuilder: (BuildContext context, int index) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
PetDetailPage(listImages[index])));
},
child: Container(
width: 500.0,
height: 200.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20.0),
bottomLeft: Radius.circular(20.0)),
image: DecorationImage(
fit: BoxFit.cover,
image: AssetImage(listImages[index]))),
),
),
Padding(
padding: const EdgeInsets.all(5.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 12.0),
child: Text(
'Puppy Katherin',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 25.0),
),
),
Padding(
padding: const EdgeInsets.only(top: 12.0, right: 20.0),
child: Icon(
Icons.favorite_border,
color: Colors.red,
size: 25.0,
),
)
],
),
),
Padding(
padding: const EdgeInsets.only(top: 4.0, left: 5.0, bottom: 50.0),
child: Text(
'French Black puppy',
style: TextStyle(color: Colors.grey[400], fontSize: 15.0),
),
)
],
);
},
);
} else if (_currentIndex == 2) {
return Container(
height: 20.0,
width: 20.0,
child: Center(
child: Text(
'Birds page',
style: TextStyle(color: Colors.black, fontSize: 20.0),
)),
);
} else {
return Container(
height: 20.0,
width: 20.0,
child: Center(
child: Text(
'Others page',
style: TextStyle(color: Colors.black, fontSize: 20.0),
)));
}
}
| 0 |
mirrored_repositories/Flutter-UIs-Collection/pet_adoption_ui/lib | mirrored_repositories/Flutter-UIs-Collection/pet_adoption_ui/lib/src/pet_detail.dart | import 'package:flutter/material.dart';
class PetDetailPage extends StatelessWidget {
final String image;
final List<String> title = ['Age' , 'Sex' , 'Color' , 'ID'];
final List<String> data = ['1' , 'Female' , 'White' , '123'];
final String desc =
'I recently lost my job and don\'t have enough time or money to tend to Bo anymore. I have a lot of health issues that need attention...';
PetDetailPage(this.image);
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
top: false,
bottom: false,
child: NestedScrollView(
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverAppBar(
expandedHeight: 230.0,
floating: false,
pinned: true,
elevation: 0.0,
flexibleSpace: FlexibleSpaceBar(
background: Image.asset(
image,
fit: BoxFit.cover,
),
),
)
];
},
body: ListView(
shrinkWrap: true,
scrollDirection: Axis.vertical,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 30.0, right: 30.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
'Puppy Katherin',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 25.0),
),
Padding(
padding: const EdgeInsets.only(right: 20.0),
child: Icon(
Icons.favorite,
color: Colors.red,
size: 25.0,
),
)
],
),
),
Padding(
padding: const EdgeInsets.only(
top: 15.0, left: 30.0, bottom: 30.0),
child: Text(
'French Black puppy',
style: TextStyle(color: Colors.grey[400], fontSize: 15.0),
),
),
Padding(
padding:
const EdgeInsets.only(top: 3.0, left: 25.0, right: 0.0),
child: SizedBox(
height: 100.0,
width: 400.0,
child: Row(
children: <Widget>[
Expanded(
child: ListView.builder(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
itemCount: title.length,
itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.only(
left: 5.0, right: 14.0),
child: Material(
child: GestureDetector(
child: Container(
height: 200.0,
width: 100.0,
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(15.0),
color: Colors.grey[200],
),
child: Center(
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[
Text(title[index],
style: TextStyle(
color: Colors.red,
fontSize: 16.0)),
Padding(
padding: const EdgeInsets.only(
top: 8.0),
child: Text(
data[index],
style: TextStyle(
color: Colors.black,
fontSize: 16.0),
),
)
],
),
),
),
),
),
);
},
),
)
],
),
),
),
Padding(
padding: const EdgeInsets.only(top: 38.0, left: 20.0),
child: Container(
width: 375.0,
height: 85.0,
child: ListTile(
leading: CircleAvatar(
radius: 20.0,
backgroundImage: AssetImage('assets/profile.jpg'),
),
title: Text(
'Roselia Drew',
style: TextStyle(
fontSize: 17.0, fontWeight: FontWeight.bold),
),
trailing: Text('1.68 km',
style: TextStyle(
fontSize: 15.0,
color: Colors.red,
fontWeight: FontWeight.bold)),
subtitle: Text('Owner',
style: TextStyle(
fontSize: 15.0,
color: Colors.red,
fontWeight: FontWeight.bold)),
),
decoration: BoxDecoration(
color: Colors.red[100],
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20.0),
bottomLeft: Radius.circular(20.0)),
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 40.0, right: 35.0, top: 20.0),
child: Text(
desc,
style: TextStyle(color: Colors.black, fontSize: 16.0),
),
),
Padding(
padding: const EdgeInsets.only(top:50.0 , left: 30.0 , right: 20.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
height: 70.0,
width: 70.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30.0),
color: Colors.grey[200],
),
child: Center(
child: Icon(
Icons.present_to_all,
color: Colors.black,
size: 25,
)),
),
Container(
height: 65.0,
width: 240.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(35.0),
border: Border.all(color: Colors.red[100] , width: 5),
color: Colors.red[400]
),
child: Center(
child: Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left:25.0),
child: Icon(Icons.pets , color: Colors.white,),
),
Padding(
padding: const EdgeInsets.only(left:25.0),
child: Text('ADOPTION' , style: TextStyle(color: Colors.white , fontSize: 18.0 ),),
)
],
),
),
)
],
),
)
],
)
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/Flutter-UIs-Collection/pet_adoption_ui | mirrored_repositories/Flutter-UIs-Collection/pet_adoption_ui/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:pet_adoption_ui/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-UIs-Collection/Furniture-Screens-UI | mirrored_repositories/Flutter-UIs-Collection/Furniture-Screens-UI/lib/main.dart | import 'package:flutter/material.dart';
import 'package:ui_shopping_cart/screens/find_product_screen.dart';
import 'package:ui_shopping_cart/screens/home_screen.dart';
import 'package:ui_shopping_cart/screens/shopping_cart_screen.dart';
import 'package:ui_shopping_cart/screens/stats_screen.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Furniture UI",
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMixin{
TabController controller;
@override
void initState() {
super.initState();
controller = new TabController(vsync: this, length: 4);
}
@override
void dispose() {
super.dispose();
controller.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
bottomNavigationBar: Material(
color: Colors.white,
child: TabBar(
controller: controller,
indicatorColor: Colors.yellow,
indicatorSize: TabBarIndicatorSize.tab,
indicatorWeight: 5.0,
tabs: <Widget>[
Tab(icon: Icon(Icons.event_seat, color: Colors.grey,),),
Tab(icon: Icon(Icons.timer, color: Colors.grey,),),
Tab(icon: Icon(Icons.shopping_cart, color: Colors.grey,),),
Tab(icon: Icon(Icons.person_outline, color: Colors.grey,),)
],
),
),
body: TabBarView(
controller: controller,
children: <Widget>[
HomeScreen(),
FindProductScreen(),
ShoppingCartScreen(),
StatsScreen()
],
),
);
}
} | 0 |
mirrored_repositories/Flutter-UIs-Collection/Furniture-Screens-UI/lib | mirrored_repositories/Flutter-UIs-Collection/Furniture-Screens-UI/lib/screens/shopping_cart_screen.dart | import 'package:flutter/material.dart';
class ShoppingCartScreen extends StatefulWidget {
_ShoppingCartScreenState createState() => _ShoppingCartScreenState();
}
class _ShoppingCartScreenState extends State<ShoppingCartScreen> {
@override
Widget build(BuildContext context) {
return Container(
child: Center(
child: Text('Shopping cart Screen', style: TextStyle(
fontSize: 24.0
),),
),
);
}
} | 0 |
mirrored_repositories/Flutter-UIs-Collection/Furniture-Screens-UI/lib | mirrored_repositories/Flutter-UIs-Collection/Furniture-Screens-UI/lib/screens/home_screen.dart | import 'package:flutter/material.dart';
import 'package:ui_shopping_cart/screens/product_detail_screen.dart';
class HomeScreen extends StatefulWidget {
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: ListView(
children: <Widget>[
Column(
children: <Widget>[
Stack(
children: <Widget>[
Container(
height: 250.0,
width: double.infinity,
color: Colors.yellow[700],
),
Positioned(
bottom: 50.0,
right: 100.0,
child: Container(
height: 400.0,
width: 400.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(200.0),
color: Colors.yellow[400].withOpacity(0.5),
),
),
),
Positioned(
bottom: 100.0,
left: 150.0,
child: Container(
height: 300.0,
width: 300.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(200.0),
color: Colors.yellow[400].withOpacity(0.5),
),
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SizedBox(
height: 10.0,
),
Row(
children: <Widget>[
SizedBox(
width: 15.0,
),
Container(
alignment: Alignment.topLeft,
width: 50.0,
height: 50.0,
decoration: BoxDecoration(
border: Border.all(
color: Colors.white,
style: BorderStyle.solid,
width: 2.0),
shape: BoxShape.circle,
image: DecorationImage(
image: AssetImage('assets/chris.jpg'))),
),
SizedBox(
width: MediaQuery.of(context).size.width - 120.0,
),
Container(
alignment: Alignment.topRight,
child: IconButton(
icon: Icon(Icons.menu),
color: Colors.white,
onPressed: () => {},
iconSize: 30.0,
),
)
],
),
SizedBox(
height: 50.0,
),
Padding(
padding: EdgeInsets.only(left: 15.0),
child: Text('Hello , Pino',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontFamily: 'Quicksand',
fontSize: 30.0)),
),
SizedBox(
height: 15.0,
),
Padding(
padding: EdgeInsets.only(left: 15.0),
child: Text('What do you want to buy?',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontFamily: 'Quicksand',
fontSize: 23.0)),
),
SizedBox(
height: 25.0,
),
Padding(
padding: EdgeInsets.only(left: 15.0, right: 15.0),
child: Material(
elevation: 5.0,
borderRadius: BorderRadius.circular(5.0),
child: TextFormField(
decoration: InputDecoration(
border: InputBorder.none,
prefixIcon: Icon(Icons.search,
color: Colors.yellow[700], size: 30.0),
contentPadding:
EdgeInsets.only(left: 15.0, top: 15.0),
hintText: 'Search',
hintStyle: TextStyle(
color: Colors.grey,
fontFamily: 'Quicksand')),
),
),
),
SizedBox(
height: 15.0,
)
],
)
],
),
SizedBox(
height: 15.0,
),
Stack(
children: <Widget>[
SizedBox(
height: 10.0,
),
Material(
elevation: 1.0,
child: Container(
height: 75.0,
color: Colors.white,
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Container(
height: 75.0,
width: MediaQuery.of(context).size.width / 4,
child: Column(
children: <Widget>[
Container(
height: 50.0,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/sofas.png'))),
),
Text('Sofas',
style: TextStyle(fontFamily: 'Quicksand'))
],
),
),
Container(
height: 75.0,
width: MediaQuery.of(context).size.width / 4,
child: Column(
children: <Widget>[
Container(
height: 50.0,
decoration: BoxDecoration(
image: DecorationImage(
image:
AssetImage('assets/wardrobe.png'))),
),
Text('Wardrobe',
style: TextStyle(fontFamily: 'Quicksand'))
],
),
),
Container(
height: 75.0,
width: MediaQuery.of(context).size.width / 4,
child: Column(
children: <Widget>[
Container(
height: 50.0,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/desk.png'))),
),
Text('Desk',
style: TextStyle(fontFamily: 'Quicksand'))
],
),
),
Container(
height: 75.0,
width: MediaQuery.of(context).size.width / 4,
child: Column(
children: <Widget>[
Container(
height: 50.0,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/dresser.png'))),
),
Text('Dresser',
style: TextStyle(fontFamily: 'Quicksand'))
],
),
)
],
)
],
),
itemCard('FinnNavian', 'assets/ottoman.jpg', true),
itemCard('FinnNavian', 'assets/anotherchair.jpg', false),
itemCard('FinnNavian', 'assets/chair.jpg', false)
],
)
],
),
);
}
Widget itemCard(String title, String imgPath, bool isFavourite) {
return Padding(
padding: EdgeInsets.only(left: 15.0, right: 15.0, top: 15.0),
child: GestureDetector(
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (context) {
return ProductDetailScreen();
}));
},
child: Container(
color: Colors.white,
height: 155.0,
width: double.infinity,
child: Row(
children: <Widget>[
Container(
width: 140.0,
height: 150.0,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(imgPath), fit: BoxFit.cover)),
),
SizedBox(
width: 4.0,
),
Column(
children: <Widget>[
Row(
children: <Widget>[
Text(title,
style: TextStyle(
fontFamily: 'Quicksand',
fontSize: 17.0,
fontWeight: FontWeight.bold)),
SizedBox(
width: 45.0,
),
Material(
elevation: isFavourite ? 2.0 : 0.0,
borderRadius: BorderRadius.circular(20.0),
child: Container(
width: 40.0,
height: 40.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0),
color: isFavourite
? Colors.white
: Colors.grey.withOpacity(0.2)),
child: Center(
child: isFavourite
? Icon(
Icons.favorite,
color: Colors.red,
)
: Icon(Icons.favorite_border),
)),
)
],
),
SizedBox(
height: 5.0,
),
Container(
width: 175.0,
child: Text(
'Scandinavian small sized double sofa imported full leather / Dale Italia oil wax leather black',
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.grey,
),
),
),
SizedBox(
height: 5.0,
),
Row(
children: <Widget>[
SizedBox(
width: 35.0,
),
Container(
height: 40.0,
width: 50.0,
color: Colors.orange,
child: Center(
child: Text("\$248",
style: TextStyle(
color: Colors.white,
fontFamily: 'Quicksand',
fontWeight: FontWeight.bold)),
)),
Container(
height: 40.0,
width: 100.0,
color: Colors.yellow[700],
child: Center(
child: Text("Add to cart",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontFamily: 'Quicksand')),
)),
],
)
],
)
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/Flutter-UIs-Collection/Furniture-Screens-UI/lib | mirrored_repositories/Flutter-UIs-Collection/Furniture-Screens-UI/lib/screens/stats_screen.dart | import 'package:flutter/material.dart';
class StatsScreen extends StatefulWidget {
_StatsScreenState createState() => _StatsScreenState();
}
class _StatsScreenState extends State<StatsScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: ListView(
children: <Widget>[
Column(
children: <Widget>[
Stack(
children: <Widget>[
Container(
height: 250.0,
width: double.infinity,
color: Colors.yellow[700],
),
Positioned(
bottom: 50.0,
right: 100.0,
child: Container(
width: 400.0,
height: 400.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(200.0),
color: Colors.yellow[400].withOpacity(0.5)),
),
),
Positioned(
bottom: 100.0,
left: 150.0,
child: Container(
width: 300.0,
height: 300.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(200.0),
color: Colors.yellow[400].withOpacity(0.5)),
),
),
Column(
children: <Widget>[
SizedBox(
height: 15.0,
),
Row(
children: <Widget>[
SizedBox(
width: 10.0,
),
Container(
width: 75.0,
height: 75.0,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: Colors.white,
style: BorderStyle.solid,
width: 2.0),
image: DecorationImage(
image: AssetImage('assets/chris.jpg'))),
),
SizedBox(
width: 10.0,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text('Pino',
style: TextStyle(
color: Colors.black,
fontFamily: 'Quicksand',
fontSize: 24.0,
fontWeight: FontWeight.bold)),
Text('176***590',
style: TextStyle(
color: Colors.black,
fontFamily: 'Quicksand',
fontSize: 20.0))
],
),
SizedBox(
width: MediaQuery.of(context).size.width - 230.0,
),
IconButton(
icon: Icon(
Icons.settings,
color: Colors.white,
size: 30.0,
),
onPressed: () => {},
),
],
),
SizedBox(
height: 25.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Column(
children: <Widget>[
Icon(Icons.perm_contact_calendar,
color: Colors.white, size: 35.0),
SizedBox(
height: 5.0,
),
Text('Favorites',
style: TextStyle(
color: Colors.white,
fontFamily: 'Quicksand',
fontWeight: FontWeight.bold,
fontSize: 18.0))
],
),
Column(
children: <Widget>[
Icon(Icons.account_balance_wallet,
color: Colors.white, size: 35.0),
SizedBox(
height: 5.0,
),
Text('Wallet',
style: TextStyle(
color: Colors.white,
fontFamily: 'Quicksand',
fontWeight: FontWeight.bold,
fontSize: 18.0))
],
),
Column(
children: <Widget>[
Icon(Icons.print,
color: Colors.white, size: 35.0),
SizedBox(
height: 5.0,
),
Text('Footprint',
style: TextStyle(
color: Colors.white,
fontFamily: 'Quicksand',
fontWeight: FontWeight.bold,
fontSize: 18.0))
],
),
Column(
children: <Widget>[
Icon(Icons.laptop,
color: Colors.white, size: 35.0),
SizedBox(
height: 5.0,
),
Text('Coupon',
style: TextStyle(
color: Colors.white,
fontFamily: 'Quicksand',
fontWeight: FontWeight.bold,
fontSize: 18.0))
],
)
],
),
SizedBox(
height: 15.0,
),
Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
customCards(
'Pending payment', '5', 'assets/card.png'),
customCards(
'To be shipped', '2', 'assets/box.png'),
],
),
SizedBox(
height: 5.0,
)
],
)
],
)
],
),
SizedBox(
height: 15.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
customCards('To be received', '8', 'assets/trucks.png'),
customCards('Return/replace', '0', 'assets/returnbox.png'),
],
),
SizedBox(height: 10.0,),
customlistDetails('Gift card', Icons.account_box, Colors.red[100], Colors.red[400]),
customlistDetails('Bank card', Icons.credit_card, Colors.orange[200], Colors.orange[400]),
customlistDetails('Replacement code', Icons.sim_card, Colors.red[50], Colors.red[300]),
customlistDetails('Consulting collection', Icons.dashboard, Colors.blue[100], Colors.blue[400]),
customlistDetails('Customer service', Icons.people, Colors.orange[100], Colors.orange[300])
],
)
],
),
);
}
Widget customCards(String title, String qty, String imagePath) {
return Material(
elevation: 5.0,
borderRadius: BorderRadius.circular(8.0),
child: Container(
height: 125.0,
width: (MediaQuery.of(context).size.width / 2.0) - 20.0,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SizedBox(
height: 10.0,
),
Padding(
padding: EdgeInsets.only(left: 15.0),
child: Image.asset(imagePath,
fit: BoxFit.cover, width: 50.0, height: 50.0),
),
SizedBox(height: 2.0),
Padding(
padding: EdgeInsets.only(left: 15.0),
child: Text(title,
style: TextStyle(
fontFamily: 'Quicksand',
fontSize: 15.0,
color: Colors.black,
)),
),
SizedBox(height: 3.0),
Padding(
padding: EdgeInsets.only(left: 15.0),
child: Text(qty,
style: TextStyle(
fontFamily: 'Quicksand',
fontSize: 15.0,
color: Colors.red,
fontWeight: FontWeight.bold)),
),
],
),
),
);
}
Widget customlistDetails(String title, IconData icon, Color backgroundColor, Color iconColor) {
return ListTile(
title: Text(
title,
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontFamily: 'Quicksand',
fontSize: 18.0
)
),
leading: CircleAvatar(
backgroundColor: backgroundColor,
child: Center(
child: Icon(icon, color: iconColor,),
),
),
trailing: Icon(Icons.chevron_right, color: Colors.black),
);
}
}
| 0 |
mirrored_repositories/Flutter-UIs-Collection/Furniture-Screens-UI/lib | mirrored_repositories/Flutter-UIs-Collection/Furniture-Screens-UI/lib/screens/find_product_screen.dart | import 'package:flutter/material.dart';
class FindProductScreen extends StatefulWidget {
_FindProductScreenState createState() => _FindProductScreenState();
}
class _FindProductScreenState extends State<FindProductScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: Text('Find Product Screen', style: TextStyle(fontSize: 24.0)),
),
),
);
}
} | 0 |
mirrored_repositories/Flutter-UIs-Collection/Furniture-Screens-UI/lib | mirrored_repositories/Flutter-UIs-Collection/Furniture-Screens-UI/lib/screens/product_detail_screen.dart | import 'package:flutter/material.dart';
class ProductDetailScreen extends StatefulWidget {
_ProductDetailScreenState createState() => _ProductDetailScreenState();
}
class _ProductDetailScreenState extends State<ProductDetailScreen> {
int photoIndex = 0;
List<String> photos = [
'assets/ottoman.jpg',
'assets/otto2.jpeg',
'assets/otto3.jpg',
'assets/otto4.jpg'
];
void _previousImage() {
setState(() {
photoIndex = photoIndex > 0 ? photoIndex - 1 : 0;
});
}
void _nextImage() {
setState(() {
photoIndex = photoIndex < photos.length - 1 ? photoIndex + 1 : photoIndex;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: ListView(
shrinkWrap: true,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Stack(
children: <Widget>[
Container(
height: 275.0,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(photos[photoIndex]),
fit: BoxFit.cover),
),
),
GestureDetector(
child: Container(
height: 275.0,
width: MediaQuery.of(context).size.width,
color: Colors.transparent,
),
onTap: _nextImage,
),
GestureDetector(
child: Container(
height: 275.0,
width: MediaQuery.of(context).size.width / 2,
color: Colors.transparent,
),
onTap: _previousImage,
),
Padding(
padding: EdgeInsets.only(right: 15.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
IconButton(
icon: Icon(Icons.arrow_back),
onPressed: () {
Navigator.pop(context);
},
),
Material(
elevation: 4.0,
color: Colors.white,
borderRadius: BorderRadius.circular(20.0),
child: Container(
width: 40.0,
height: 40.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0)),
child: Icon(Icons.favorite, color: Colors.red),
),
)
],
),
),
Positioned(
top: 240.0,
left: MediaQuery.of(context).size.width / 2 - 50.0,
child: SelectedPhoto(
numberOfDots: photos.length,
photoIndex: photoIndex,
),
)
],
),
SizedBox(
height: 30.0,
),
Padding(
padding: const EdgeInsets.only(left: 15.0),
child: Text('Alcide Number: 2323X',
style: TextStyle(
color: Colors.grey,
fontFamily: 'Quicksand',
fontSize: 15.0,
fontWeight: FontWeight.bold)),
),
SizedBox(
height: 14.0,
),
Padding(
padding: const EdgeInsets.only(left: 15.0),
child: Text('Finn Navian-Sofa',
style: TextStyle(
color: Colors.black,
fontFamily: 'Quicksand',
fontSize: 28.0,
fontWeight: FontWeight.bold)),
),
SizedBox(
height: 14.0,
),
Padding(
padding: const EdgeInsets.only(left: 15.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width / 2 + 70.0,
child: Text(
'Scandinavian small size sofa / imported full leather/Dail italia oil wax leather black',
style: TextStyle(
fontFamily: 'Montserrat',
color: Colors.grey.withOpacity(0.8),
fontWeight: FontWeight.bold,
)),
),
Padding(
padding: const EdgeInsets.only(right: 16.0),
child: Text('\$248',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
fontFamily: 'Montserrat',
fontSize: 24.0)),
)
],
),
),
SizedBox(
height: 20.0,
),
Padding(
padding: const EdgeInsets.only(left: 15.0),
child: Text('COLOUR',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
fontFamily: 'Montserrat',
fontSize: 20.0)),
),
SizedBox(
height: 20.0,
),
Row(
children: <Widget>[
colorItems(Colors.black),
colorItems(Colors.grey),
colorItems(Colors.grey[300]),
],
),
SizedBox(
height: 20.0,
),
Padding(
padding: const EdgeInsets.only(left: 15.0),
child: Text('MATERIAL',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
fontFamily: 'Montserrat',
fontSize: 20.0)),
),
SizedBox(
height: 20.0,
),
Row(
children: <Widget>[
materialItems(Icons.work, 'x30%'),
materialItems(Icons.book, 'x60%'),
materialItems(Icons.timeline, 'x10%'),
],
),
],
)
],
),
bottomNavigationBar: Material(
elevation: 7.0,
color: Colors.white,
child: Container(
height: 60.0,
width: MediaQuery.of(context).size.width,
color: Colors.white,
child:
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(width: 10.0),
Container(
height: 50.0,
width: 50.0,
color: Colors.white,
child: Icon(
Icons.shopping_cart,
color: Colors.grey,
),
),
Container(
height: 50.0,
width: 50.0,
color: Colors.white,
child: Icon(
Icons.account_box,
color: Colors.grey,
),
),
Container(
color: Colors.yellow[700],
width: MediaQuery.of(context).size.width - 150.0,
child: Center(
child: Text(
'Add to Cart',
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 19.0,
color: Colors.white,
fontWeight: FontWeight.bold),
),
),
),
]),
),
),
);
}
Widget colorItems(Color color) {
return Padding(
padding: const EdgeInsets.only(left: 15.0, right: 15.0),
child: Container(
width: 40.0,
height: 40.0,
decoration: BoxDecoration(shape: BoxShape.circle, color: color),
),
);
}
Widget materialItems(IconData icon, String percentage) {
return Padding(
padding: const EdgeInsets.only(left: 15.0, right: 15.0),
child: Row(
children: <Widget>[
Icon(
icon,
color: Colors.grey,
size: 30.0,
),
Padding(
padding: const EdgeInsets.only(right: 8.0),
),
Text(
percentage,
style: TextStyle(
fontFamily: 'Montserrat',
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 16.0),
)
],
),
);
}
}
class SelectedPhoto extends StatelessWidget {
final int numberOfDots;
final int photoIndex;
SelectedPhoto({this.numberOfDots, this.photoIndex});
Widget _inactivePhoto() {
return Container(
child: Padding(
padding: EdgeInsets.only(left: 8.0, right: 8.0),
child: Container(
width: 8.0,
height: 8.0,
decoration: BoxDecoration(
color: Colors.grey, borderRadius: BorderRadius.circular(4.0)),
),
),
);
}
Widget _activePhoto() {
return Container(
child: Padding(
padding: EdgeInsets.only(left: 8.0, right: 8.0),
child: Container(
width: 10.0,
height: 10.0,
decoration: BoxDecoration(
color: Colors.yellow,
borderRadius: BorderRadius.circular(5.0),
boxShadow: [
BoxShadow(
color: Colors.grey, spreadRadius: 0.0, blurRadius: 2.0)
]),
),
),
);
}
List<Widget> buildDots() {
List<Widget> dots = [];
for (int i = 0; i < numberOfDots; ++i) {
dots.add(i == photoIndex ? _activePhoto() : _inactivePhoto());
}
return dots;
}
@override
Widget build(BuildContext context) {
return Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center, children: buildDots()),
);
}
}
| 0 |
mirrored_repositories/Flutter-UIs-Collection/Furniture-Screens-UI | mirrored_repositories/Flutter-UIs-Collection/Furniture-Screens-UI/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:ui_shopping_cart/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-UIs-Collection/Login-Screens-UI | mirrored_repositories/Flutter-UIs-Collection/Login-Screens-UI/lib/main.dart | import 'package:flutter/material.dart';
import 'package:login_screens/screens/first_login_screen.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: FirstLoginScreen(),
);
}
} | 0 |
mirrored_repositories/Flutter-UIs-Collection/Login-Screens-UI/lib | mirrored_repositories/Flutter-UIs-Collection/Login-Screens-UI/lib/screens/first_login_screen.dart | import 'package:flutter/material.dart';
class FirstLoginScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.indigo,
body: Stack(
children: <Widget>[
Positioned(
top: 200.0,
child: ClipPath(
clipper: MyClipper(),
child: Container(
width: MediaQuery.of(context).size.width,
height: 540.0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20.0)),
),
),
),
Positioned(
top: 80.0,
left: MediaQuery.of(context).size.width - 170.0,
child: Column(
children: <Widget>[
Container(
width: 130.0,
height: 130.0,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/healthcare.png'))),
),
Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 4.0),
child: Text(
'Health',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 25.0),
),
),
Padding(
padding: const EdgeInsets.only(top: 4.0, left: 5.0),
child: Text(
'Care',
style: TextStyle(
color: Colors.red,
fontWeight: FontWeight.bold,
fontSize: 25.0),
),
),
],
)
],
),
),
Positioned(
top: 290.0,
left: 40.0,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Welcome to',
style: TextStyle(color: Colors.black, fontSize: 20.0),
),
Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 4.0),
child: Text(
'Health',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 25.0),
),
),
Padding(
padding: const EdgeInsets.only(top: 4.0, left: 5.0),
child: Text(
'Care',
style: TextStyle(
color: Colors.red,
fontWeight: FontWeight.bold,
fontSize: 25.0),
),
),
],
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Text(
'Please sign in to continue',
style: TextStyle(color: Colors.black, fontSize: 15.0),
),
),
Padding(
padding: const EdgeInsets.only(top: 12.0),
child: Container(
width: 250.0,
child: TextField(
decoration: InputDecoration(
labelText: 'Username',
hintText: 'Enter your username',
hintStyle: TextStyle(color: Colors.grey),
prefixIcon: Icon(
Icons.account_circle,
color: Colors.grey,
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0))),
),
),
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Container(
width: 250.0,
child: TextField(
decoration: InputDecoration(
labelText: 'Password',
hintText: 'Enter your password',
hintStyle: TextStyle(color: Colors.grey),
prefixIcon: Icon(
Icons.security,
color: Colors.grey,
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0))),
),
),
),
Padding(
padding: const EdgeInsets.only(top: 80.0),
child: Text(
'Forgot Password ?',
style: TextStyle(color: Colors.black, fontSize: 15.0),
),
)
],
),
),
Positioned(
top: MediaQuery.of(context).size.height / 2 + 120.0,
left: MediaQuery.of(context).size.width - 200.0,
child: Container(
width: 100.0,
height: 40.0,
child: RaisedButton(
splashColor: Colors.yellow,
color: Colors.red,
padding: EdgeInsets.all(12.0),
shape: StadiumBorder(),
onPressed: () {},
child: Text(
'LOGIN',
style: TextStyle(color: Colors.white),
),
),
),
)
],
),
);
}
}
class MyClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
Path path = Path();
path.lineTo(0.0, size.height - 80.0);
var firstControlPoint = new Offset(50.0, size.height);
var firstEndPoint = new Offset(size.width / 3.5, size.height - 45.0);
path.quadraticBezierTo(firstControlPoint.dx, firstControlPoint.dy,
firstEndPoint.dx, firstEndPoint.dy);
path.lineTo(size.width - 30.0, size.height / 2);
var secondControlPoint =
new Offset(size.width + 15.0, size.height / 2 - 60.0);
var secondEndPoint = new Offset(140.0, 50.0);
path.quadraticBezierTo(secondControlPoint.dx, secondControlPoint.dy,
secondEndPoint.dx, secondEndPoint.dy);
var thirdControlPoint = new Offset(50.0, 0.0);
var thirdEndPoint = new Offset(0.0, 100.0);
path.quadraticBezierTo(thirdControlPoint.dx, thirdControlPoint.dy,
thirdEndPoint.dx, thirdEndPoint.dy);
path.close();
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) => false;
}
| 0 |
mirrored_repositories/Flutter-UIs-Collection/Login-Screens-UI | mirrored_repositories/Flutter-UIs-Collection/Login-Screens-UI/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:login_screens/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-UIs-Collection/Flight-App-Screens-UI | mirrored_repositories/Flutter-UIs-Collection/Flight-App-Screens-UI/lib/main.dart | import 'package:flight_app_screens/screens/home_screen.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData.dark(),
home: HomeScreen(),
);
}
} | 0 |
mirrored_repositories/Flutter-UIs-Collection/Flight-App-Screens-UI/lib | mirrored_repositories/Flutter-UIs-Collection/Flight-App-Screens-UI/lib/screens/flight_screen.dart | import 'package:flight_app_screens/screens/seat_screen.dart';
import 'package:flutter/material.dart';
class FlightScreen extends StatefulWidget {
@override
FlightScreenState createState() {
return new FlightScreenState();
}
}
class FlightScreenState extends State<FlightScreen> {
Color oneWayContainerColor = Colors.white;
Color twoWayContainerColor = Colors.purple;
Color oneWayTextColor = Colors.grey;
Color twoWayTextColor = Colors.white;
bool value = true;
var classes = ["Business", "Economy"];
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: <Widget>[
Stack(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 40.0),
child: Container(
width: MediaQuery.of(context).size.width,
height: 370.0,
),
),
Padding(
padding: const EdgeInsets.only(top: 40.0),
child: Container(
width: MediaQuery.of(context).size.width,
height: 350.0,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/worldmap.jpg'),
fit: BoxFit.cover)),
),
),
Positioned(
top: 50.0,
left: 140.0,
child: Text(
'Search Flight',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 20.0),
),
),
Positioned(
top: 110.0,
left: 30.0,
child: Row(
children: <Widget>[
Column(
children: <Widget>[
Container(
width: 6.0,
height: 6.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40.0),
color: Colors.white,
),
),
Padding(
padding: const EdgeInsets.only(top: 2.0),
child: Container(
width: 2.0,
height: 70.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.0),
color: Colors.white,
),
),
),
Padding(
padding: const EdgeInsets.only(top: 2.0),
child: Container(
width: 30.0,
height: 30.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40.0),
color: Colors.transparent,
border: Border.all(
color: Colors.white, width: 1.0)),
),
),
Padding(
padding: const EdgeInsets.only(top: 2.0),
child: Container(
width: 2.0,
height: 70.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.0),
color: Colors.white,
),
),
),
Padding(
padding: const EdgeInsets.only(top: 2.0),
child: Container(
width: 6.0,
height: 6.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40.0),
color: Colors.white,
),
),
),
],
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Departure From',
style:
TextStyle(color: Colors.white, fontSize: 14.0),
),
Padding(
padding: const EdgeInsets.only(top: 4.0),
child: Text(
'SLM',
style: TextStyle(
color: Colors.white,
fontSize: 20.0,
fontWeight: FontWeight.bold),
),
),
Padding(
padding: const EdgeInsets.only(top: 4.0),
child: Text(
'Sleman,Yogyakarta',
style: TextStyle(
color: Colors.white,
fontSize: 14.0,
),
),
),
Padding(
padding: const EdgeInsets.only(top: 70.0),
child: Text(
'Arrival At',
style: TextStyle(
color: Colors.white, fontSize: 14.0),
),
),
Padding(
padding: const EdgeInsets.only(top: 4.0),
child: Text(
'BTL',
style: TextStyle(
color: Colors.white,
fontSize: 20.0,
fontWeight: FontWeight.bold),
),
),
Padding(
padding: const EdgeInsets.only(top: 4.0),
child: Text(
'Mbantul,Yogyakarta',
style: TextStyle(
color: Colors.white,
fontSize: 14.0,
),
),
),
],
),
)
],
),
),
Positioned(
top: 200.0,
left: 200.0,
child: Row(
children: <Widget>[
Container(
width: 8.0,
height: 8.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40.0),
color: Colors.white,
),
),
Container(
width: 50.0,
height: 1.0,
color: Colors.white,
),
Icon(Icons.flight_takeoff, color: Colors.white,size: 25.0,),
Container(
width: 50.0,
height: 1.0,
color: Colors.white,
),
Container(
width: 10.0,
height: 10.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40.0),
color: Colors.white,
),
),
],
),
),
Positioned(
top: 350.0,
left: 20.0,
right: 20.0,
child: Container(
width: 145.0,
height: 55.0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(30.0)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
GestureDetector(
onTap: () {
print("Tapped");
setState(() {
oneWayContainerColor = Colors.purple;
twoWayContainerColor = Colors.white;
twoWayTextColor = Colors.grey;
oneWayTextColor = Colors.white;
value = false;
});
},
child: Container(
width: 130.0,
height: 45.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30.0),
color: oneWayContainerColor,
),
child: Center(
child: Text(
'One Way',
style: TextStyle(color: oneWayTextColor),
),
),
),
),
GestureDetector(
onTap: () {
setState(() {
oneWayContainerColor = Colors.white;
twoWayContainerColor = Colors.purple;
twoWayTextColor = Colors.white;
oneWayTextColor = Colors.grey;
value = true;
});
},
child: Container(
width: 130.0,
height: 45.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30.0),
color: twoWayContainerColor,
),
child: Center(
child: Text(
'Two Way',
style: TextStyle(color: twoWayTextColor),
),
),
),
)
],
)),
),
],
),
Padding(
padding: const EdgeInsets.all(8.0),
child: tripDetailsWidget(value),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
width: 350.0,
child: RaisedButton(
padding: const EdgeInsets.all(18.0),
onPressed: (){
Navigator.push(context, new MaterialPageRoute(
builder: ((context) {
return SeatScreen();
})
));
},
color: Colors.pink,
child: Text(
'Search Flight', style: TextStyle(
color: Colors.white,
fontSize: 16.0
),),
),
),
)
],
),
);
}
Widget tripDetailsWidget(bool value) {
return Material(
elevation: 4.0,
child: value == true
? Container(
width: 350.0,
height: 300.0,
color: Colors.white,
child: Column(
children: <Widget>[
flightDetailsWidget(Icons.date_range, 'Departure Date', 0,
subtitle: 'Mon, 14 Dec'),
flightDetailsWidget(Icons.date_range, 'Arrival Date', 1,
subtitle: 'Sun, 15 Dec'),
flightDetailsWidget(Icons.people, 'Passenger', 2,
subtitle: '1 Adult 0 Child 0 Infant'),
flightDetailsWidget(Icons.people, 'Class', 3),
],
))
: Container(
width: 350.0,
height: 300.0,
color: Colors.white,
child: Column(
children: <Widget>[
flightDetailsWidget(Icons.date_range, 'Departure Date', 0,
subtitle: 'Mon, 14 Dec'),
flightDetailsWidget(Icons.people, 'Passenger', 2,
subtitle: '1 Adult 0 Child 0 Infant'),
flightDetailsWidget(Icons.people, 'Class', 3),
],
)
));
}
Widget flightDetailsWidget(IconData icon, String title, int index,
{String subtitle}) {
return ListTile(
title: Text(title, style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold)),
subtitle: index == 3
? DropdownButton<String>(
items: classes.map((String dropDownStringItem) {
return DropdownMenuItem<String>(
value: dropDownStringItem,
child: Text(
dropDownStringItem,
),
);
}).toList(),
onChanged: (String newItemSelected) {
},
style: TextStyle(
color: Colors.grey,
fontWeight: FontWeight.bold,
fontSize: 16.0),
value: classes[0],
)
: Text(subtitle,
style: TextStyle(
color: Colors.grey,
fontWeight: FontWeight.bold,
fontSize: 16.0)),
leading: Icon(
icon,
color: Colors.grey,
),
);
}
}
class MyClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
Path path = new Path();
path.lineTo(0.0, size.height - 20.0);
path.quadraticBezierTo(size.width / 2.0, 20.0, size.width, 0.0);
path.lineTo(0.0, size.height);
path.lineTo(size.width, size.height);
path.lineTo(size.width, 0.0);
path.close();
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) => false;
}
| 0 |
mirrored_repositories/Flutter-UIs-Collection/Flight-App-Screens-UI/lib | mirrored_repositories/Flutter-UIs-Collection/Flight-App-Screens-UI/lib/screens/home_screen.dart | import 'package:flight_app_screens/screens/flight_screen.dart';
import 'package:flutter/material.dart';
class HomeScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: <Widget>[
Positioned(
top: 60.0,
left: 25.0,
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Ilona',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 30.0),
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Text(
'Summer time, let\'s book a flight for \n vacation.',
style:
TextStyle(color: Colors.white, fontSize: 16.0),
),
),
],
),
Padding(
padding: const EdgeInsets.only(left: 40.0),
child: Material(
borderRadius: BorderRadius.circular(40.0),
elevation: 20.0,
child: Container(
width: 50.0,
height: 50.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40.0),
image: DecorationImage(
fit: BoxFit.cover,
image: AssetImage('assets/people.jpeg'))),
),
),
)
],
),
Padding(
padding: const EdgeInsets.only(top: 15.0),
child: Row(
children: <Widget>[
Container(
width: 155.0,
height: 50.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.0),
color: Colors.white),
child: RaisedButton.icon(
onPressed: () {},
color: Colors.white,
icon: Icon(
Icons.poll,
color: Colors.yellow,
),
label: Text(
'1130 pts',
style: TextStyle(
fontSize: 15.0,
color: Colors.black,
fontWeight: FontWeight.bold),
),
),
),
Padding(
padding: const EdgeInsets.only(left: 20.0),
child: Container(
width: 155.0,
height: 50.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.0),
color: Colors.white),
child: RaisedButton.icon(
onPressed: () {},
color: Colors.white,
icon: Icon(
Icons.account_balance_wallet,
color: Colors.indigo,
),
label: Text(
'\$ 4600',
style: TextStyle(
fontSize: 15.0,
color: Colors.black,
fontWeight: FontWeight.bold),
),
),
),
)
],
),
),
],
),
),
Padding(
padding: const EdgeInsets.only(top: 230.0),
child: Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
GestureDetector(
child: menuWidgets('Flight', Icons.flight, Colors.purple),
onTap: () {
Navigator.push(context,
new MaterialPageRoute(builder: (context) {
return FlightScreen();
}));
},
),
menuWidgets('Hotel', Icons.hotel, Colors.orange),
menuWidgets('Train', Icons.train, Colors.yellow),
menuWidgets('Bus', Icons.directions_bus, Colors.red)
],
),
Padding(
padding: const EdgeInsets.only(top: 25.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
menuWidgets('Movies', Icons.movie, Colors.green),
menuWidgets('Attractions', Icons.pages, Colors.red),
menuWidgets('Taxi', Icons.local_taxi, Colors.blue),
menuWidgets(
'Eats', Icons.confirmation_number, Colors.lightBlue)
],
),
),
],
),
),
Padding(
padding: const EdgeInsets.only(left: 20.0, top: 430.0, right: 15.0),
child: Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
'Recommmend',
style: TextStyle(color: Colors.white, fontSize: 18.0),
),
Text(
'View more',
style: TextStyle(color: Colors.pink, fontSize: 18.0),
)
],
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Container(
width: 150.0,
height: 200.0,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/operahouse.jpg'),
fit: BoxFit.cover),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
'Cheap Holiday Promo\nTo Australia',
style: TextStyle(
color: Colors.black,
fontSize: 13.0,
fontWeight: FontWeight.bold),
),
Align(
alignment: Alignment.bottomRight,
child: RaisedButton(
onPressed: () {},
color: Colors.pink[300],
child: Text(
'Book',
style: TextStyle(color: Colors.white),
),
),
)
],
),
),
),
),
Column(
children: <Widget>[
Container(
width: 180.0,
height: 90.0,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/macau.jpg'),
fit: BoxFit.cover),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
'Explore Macau for\nYour holiday',
style: TextStyle(
color: Colors.white,
fontSize: 12.0,
fontWeight: FontWeight.bold),
),
Align(
alignment: Alignment.bottomRight,
child: Padding(
padding: const EdgeInsets.only(right: 8.0),
child: RaisedButton(
onPressed: () {},
color: Colors.pink[300],
child: Text(
'Book',
style: TextStyle(color: Colors.white),
),
),
),
)
],
),
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: Container(
width: 180.0,
height: 90.0,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/beach.jpg'),
fit: BoxFit.cover),
),
child: Column(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
'Cheap Holiday Promo\nTo Australia',
style: TextStyle(
color: Colors.white,
fontSize: 13.0,
fontWeight: FontWeight.bold),
),
Align(
alignment: Alignment.bottomRight,
child: Padding(
padding:
const EdgeInsets.only(right: 8.0),
child: RaisedButton(
onPressed: () {},
color: Colors.pink[300],
child: Text(
'Book',
style: TextStyle(color: Colors.white),
),
),
),
)
],
),
),
),
],
)
],
),
)
],
),
)
],
),
);
}
Widget menuWidgets(String text, IconData icon, MaterialColor color) {
return Column(
children: <Widget>[
Container(
width: 50.0,
height: 50.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.0), color: color),
child: Center(
child: Icon(icon),
),
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Text(
text,
style: TextStyle(color: Colors.white, fontSize: 15.0),
),
)
],
);
}
}
| 0 |
mirrored_repositories/Flutter-UIs-Collection/Flight-App-Screens-UI/lib | mirrored_repositories/Flutter-UIs-Collection/Flight-App-Screens-UI/lib/screens/ticket_screen.dart | import 'package:flutter/material.dart';
class TicketScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: <Widget>[
Stack(
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
),
Padding(
padding: const EdgeInsets.only(top: 40.0),
child: Container(
width: MediaQuery.of(context).size.width,
height: 350.0,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/worldmap.jpg'),
fit: BoxFit.cover)),
),
),
Positioned(
top: 50.0,
left: 160.0,
child: Text(
'E-Ticket',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 20.0),
),
),
Positioned(
top: 200.0,
left: 60.0,
child: Row(
children: <Widget>[
Container(
width: 6.0,
height: 6.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40.0),
color: Colors.white,
),
),
Container(
width: 120.0,
height: 1.0,
color: Colors.white,
),
Icon(
Icons.flight_takeoff,
color: Colors.white,
size: 30.0,
),
Container(
width: 120.0,
height: 1.0,
color: Colors.white,
),
Container(
width: 8.0,
height: 8.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40.0),
color: Colors.white,
),
),
],
)),
Positioned(
top: 225.0,
left: 40.0,
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 4.0),
child: Text(
'STM',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 16.0),
),
),
Padding(
padding: const EdgeInsets.only(top: 4.0),
child: Text(
'Sleman',
style: TextStyle(color: Colors.white, fontSize: 14.0),
),
)
],
),
),
Positioned(
top: 225.0,
left: 310.0,
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 4.0),
child: Text(
'BTL',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 16.0),
),
),
Padding(
padding: const EdgeInsets.only(top: 4.0),
child: Text(
'Mbantul',
style: TextStyle(color: Colors.white, fontSize: 14.0),
),
)
],
),
),
Positioned(
top: 300.0,
left: 30.0,
right: 30.0,
child: ClipPath(
clipper: MyClipper(),
child: Container(
width: 200.0,
height: 450.0,
color: Colors.white,
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
width: 120.0,
height: 25.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30.0),
border: Border.all(
width: 1.0, color: Colors.green),
),
child: Center(
child: Text(
'Business Class',
style: TextStyle(color: Colors.green),
),
),
),
Row(
children: <Widget>[
Text(
'SLM',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Icon(
Icons.flight_takeoff,
color: Colors.pink,
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text(
'BTL',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold),
),
)
],
)
],
),
Padding(
padding: const EdgeInsets.only(top: 20.0),
child: Text(
'4 Flight Tickets', style: TextStyle(
color: Colors.black,
fontSize: 20.0,
fontWeight: FontWeight.bold
),
),
),
Padding(
padding: const EdgeInsets.only(top: 25.0),
child: Column(
children: <Widget>[
ticketDetailsWidget('Passengers', 'Ilona', 'Date', '24-12-2018'),
Padding(
padding: const EdgeInsets.only(top: 12.0, right: 40.0),
child: ticketDetailsWidget('Flight', '76836A45', 'Gate', '66B'),
),
Padding(
padding: const EdgeInsets.only(top: 12.0, right: 40.0),
child: ticketDetailsWidget('Class', 'Business', 'Seat', '21B'),
),
],
),
),
Padding(
padding: const EdgeInsets.only(top: 25.0),
child: Container(
width: 300.0,
height: 1.0,
color: Colors.grey,
),
),
Padding(
padding: const EdgeInsets.all(30.0),
child: Container(
width: 250.0,
height: 60.0,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/barcode.png'),
fit: BoxFit.cover
)
),
),
),
Padding(
padding: const EdgeInsets.only(top: 10.0, left: 75.0, right: 75.0),
child: Text(
'9824 0972 1742 1298', style: TextStyle(
color: Colors.black,
),
),
)
],
),
),
),
),
)
],
)
],
),
);
}
Widget ticketDetailsWidget(String firstTitle, String firstDesc, String secondTitle, String secondDesc) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
firstTitle, style: TextStyle(
color: Colors.grey,
),
),
Padding(
padding: const EdgeInsets.only(top: 4.0),
child: Text(
firstDesc, style: TextStyle(
color: Colors.black,
),
),
)
],
),
),
Padding(
padding: const EdgeInsets.only(right: 20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
secondTitle, style: TextStyle(
color: Colors.grey,
),
),
Padding(
padding: const EdgeInsets.only(top: 4.0),
child: Text(
secondDesc, style: TextStyle(
color: Colors.black,
),
),
)
],
),
)
],
);
}
}
class MyClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
Path path = Path();
path.lineTo(0.0, size.height);
path.lineTo(size.width, size.height);
path.lineTo(size.width, 0.0);
path.addOval(
Rect.fromCircle(center: Offset(0.0, size.height / 2 + 50.0), radius: 20.0));
path.addOval(Rect.fromCircle(
center: Offset(size.width, size.height / 2 + 50.0), radius: 20.0));
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) => false;
}
| 0 |
mirrored_repositories/Flutter-UIs-Collection/Flight-App-Screens-UI/lib | mirrored_repositories/Flutter-UIs-Collection/Flight-App-Screens-UI/lib/screens/seat_screen.dart | import 'package:flight_app_screens/screens/ticket_screen.dart';
import 'package:flutter/material.dart';
class SeatScreen extends StatefulWidget {
_SeatScreenState createState() => _SeatScreenState();
}
class _SeatScreenState extends State<SeatScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
elevation: 0.0,
centerTitle: true,
backgroundColor: Colors.black12,
title: Text('Select Seat', style: TextStyle(color: Colors.white)),
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(20.0),
child: Text(
'Business Class',
style: TextStyle(color: Colors.white, fontSize: 16.0),
),
),
seatWidget(),
Padding(
padding: const EdgeInsets.only(top: 15.0),
child: seatWidget(),
),
Padding(
padding: const EdgeInsets.only(top: 15.0),
child: seatWidget(),
),
Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20.0, top: 30.0),
child: Text(
'Economy Class',
style: TextStyle(color: Colors.white, fontSize: 16.0),
),
),
Padding(
padding: const EdgeInsets.only(top: 15.0),
child: seatWidget(),
),
Padding(
padding: const EdgeInsets.only(top: 15.0),
child: seatWidget(),
),
Padding(
padding: const EdgeInsets.only(top: 15.0),
child: seatWidget(),
),
Padding(
padding: const EdgeInsets.only(top: 15.0),
child: seatWidget(),
),
Padding(
padding: const EdgeInsets.only(top: 15.0),
child: seatWidget(),
),
Padding(
padding: const EdgeInsets.only(top: 15.0),
child: seatWidget(),
),
Padding(
padding: const EdgeInsets.only(top: 15.0),
child: Container(
color: Colors.white,
width: MediaQuery.of(context).size.width,
height: 180.0,
child: Column(
children: <Widget>[
ListTile(
title: Text('Selected Seat', style: TextStyle(color: Colors.grey),),
subtitle: Text(
'15A, 16F, 16E', style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 16.0
),
),
leading: Icon(Icons.airline_seat_legroom_extra, color: Colors.grey,),
trailing: Container(
width: 130.0,
height: 35.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30.0),
border: Border.all(width: 1.0, color: Colors.green),
),
child: Center(
child: Text(
'Business Class', style: TextStyle(
color: Colors.green
),
),
),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8.0, top: 15.0),
child: Container(
width: 350.0,
child: RaisedButton(
padding: const EdgeInsets.all(18.0),
onPressed: (){
Navigator.push(context, new MaterialPageRoute(
builder: ((context) {
return TicketScreen();
})
));
},
color: Colors.pink,
child: Text(
'Purchase', style: TextStyle(
color: Colors.white,
fontSize: 16.0
),),
),
),
)
],
),
),
)
],
),
);
}
Widget seatWidget() {
return Padding(
padding: const EdgeInsets.only(top: 10.0, right: 20.0, left: 20.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Icon(Icons.airline_seat_recline_normal, color: Colors.white,),
Icon(Icons.airline_seat_recline_normal, color: Colors.white,),
Icon(Icons.airline_seat_recline_normal, color: Colors.white,),
Icon(Icons.airline_seat_recline_normal, color: Colors.white,),
Icon(Icons.airline_seat_recline_normal, color: Colors.white,),
Icon(Icons.airline_seat_recline_normal, color: Colors.white,),
],
),
);
}
}
| 0 |
mirrored_repositories/Flutter-UIs-Collection/Flight-App-Screens-UI | mirrored_repositories/Flutter-UIs-Collection/Flight-App-Screens-UI/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:flight_app_screens/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-UIs-Collection/Travel-Screens-UI | mirrored_repositories/Flutter-UIs-Collection/Travel-Screens-UI/lib/main.dart | import 'package:flutter/material.dart';
import 'package:travel_app_ui/screens/home_screen.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: "Travel App UI",
home: HomeScreen(),
);
}
}
| 0 |
mirrored_repositories/Flutter-UIs-Collection/Travel-Screens-UI/lib | mirrored_repositories/Flutter-UIs-Collection/Travel-Screens-UI/lib/screens/home_screen.dart | import 'package:flutter/material.dart';
import 'package:travel_app_ui/screens/detail_screen.dart';
class HomeScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: ListView(
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
SizedBox(
height: 30.0,
),
Row(
children: <Widget>[
Image.asset(
'assets/flagfrance.png',
width: 28.0,
height: 25.0,
fit: BoxFit.cover,
),
SizedBox(
width: 12.0,
),
Text(
'France',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
fontSize: 30.0,
fontFamily: 'Cardo'),
),
SizedBox(
width: 12.0,
),
Container(
width: 18.0,
height: 18.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0),
border: Border.all(color: Colors.grey),
),
child: Center(
child: Icon(
Icons.arrow_drop_down,
color: Colors.black,
size: 14.0,
)),
),
SizedBox(width: MediaQuery.of(context).size.width - 210.0),
ClipRRect(
borderRadius: BorderRadius.circular(8.0),
child: Image.asset(
'assets/person.jpeg',
width: 35.0,
height: 35.0,
),
),
],
),
SizedBox(
height: 20.0,
),
Padding(
padding: const EdgeInsets.only(left: 18.0),
child: Text('The Eiffel Tower',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 20.0)),
),
SizedBox(
height: 8.0,
),
Padding(
padding: const EdgeInsets.only(left: 18.0),
child: Text('It is a long established fact that a reader',
style: TextStyle(color: Colors.grey, fontSize: 14.0)),
),
SizedBox(
height: 2.0,
),
Padding(
padding: const EdgeInsets.only(left: 18.0),
child: Text('will be distracted by the readable content',
style: TextStyle(color: Colors.grey, fontSize: 14.0)),
),
SizedBox(
height: 2.0,
),
Padding(
padding: const EdgeInsets.only(left: 18.0),
child: Text('of a page when looking ...',
style: TextStyle(color: Colors.grey, fontSize: 14.0)),
),
SizedBox(
height: 20.0,
),
Padding(
padding: const EdgeInsets.only(left: 18.0),
child: Stack(
children: <Widget>[
SizedBox(
width: 350.0,
height: 280.0,
),
Container(
width: 300.0,
height: 280.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.0),
image: DecorationImage(
fit: BoxFit.cover,
image: AssetImage('assets/tower.jpg'))),
),
Positioned(
top: 120.0,
left: 230.0,
child: Material(
elevation: 8.0,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(12.0),
bottomRight: Radius.circular(12.0)),
child: Container(
width: 100.0,
height: 45.0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(12.0),
bottomRight: Radius.circular(12.0)),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Icon(Icons.favorite, color: Colors.red),
Text('Like',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold))
],
),
),
),
)
],
),
),
Padding(
padding: const EdgeInsets.only(left: 18.0, top: 16.0),
child: Row(
children: <Widget>[
Text('Hot Spots',
style: TextStyle(
fontSize: 24.0,
color: Colors.black,
fontWeight: FontWeight.bold,
fontFamily: 'Cardo')),
SizedBox(width: MediaQuery.of(context).size.width - 270.0),
Row(
children: <Widget>[
Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Text('1',
style: TextStyle(
color: Colors.grey[850],
fontWeight: FontWeight.bold,
fontSize: 20.0)),
),
Padding(
padding: const EdgeInsets.only(top: 4.0),
child: Container(
width: 4.0,
height: 4.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0),
color: Colors.indigo[900]),
),
)
],
),
],
),
Padding(
padding: const EdgeInsets.only(left: 20.0),
child: Text('2',
style: TextStyle(
color: Colors.grey[700],
fontWeight: FontWeight.bold,
fontSize: 20.0)),
),
Padding(
padding: const EdgeInsets.only(left: 20.0),
child: Text('3',
style: TextStyle(
color: Colors.grey[700],
fontWeight: FontWeight.bold,
fontSize: 20.0)),
),
Padding(
padding: const EdgeInsets.only(left: 20.0),
child: Text('4',
style: TextStyle(
color: Colors.grey[700],
fontWeight: FontWeight.bold,
fontSize: 20.0)),
),
],
),
),
// Padding(
// padding: const EdgeInsets.only(top: 18.0, left: 18.0),
// child:
Padding(
padding: const EdgeInsets.only(top: 18.0, left: 18.0),
child: SizedBox(
height: 250.0,
child: ListView(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
children: <Widget>[
cardItemWidget(context, 'assets/museedu.jpg',
'Musee du Louvre', '10 BOKING'),
Padding(
padding: EdgeInsets.only(left: 12.0),
),
cardItemWidget(context, 'assets/arcdetrimp.jpg',
'Arc de Triomphe', '63 BOKING'),
Padding(
padding: EdgeInsets.only(left: 12.0),
),
cardItemWidget(context, 'assets/museedu.jpg',
'Musee du Louvre', '10 BOKING'),
Padding(
padding: EdgeInsets.only(right: 12.0),
),
],
),
),
)
//)
],
)
],
),
);
}
Widget cardItemWidget(
BuildContext context, String image, String title, String bokingQty) {
return GestureDetector(
onTap: (() {
Navigator.push(
context,
new MaterialPageRoute(
builder: (context) => DetailScreen(image, title)));
}),
child: Container(
width: 250.0,
height: 220.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.0), color: Colors.white),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Stack(
children: <Widget>[
Container(
width: 250.0,
height: 115.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.0),
image: DecorationImage(
fit: BoxFit.cover, image: AssetImage(image))),
),
Positioned(
left: 200,
top: 8.0,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text(
'1.6',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
//fontFamily: 'Cardo',
fontSize: 24.0),
),
Text('KM',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 18.0)),
SizedBox(
height: 25.0,
),
Material(
color: Colors.white,
shadowColor: Colors.grey,
elevation: 2.0,
borderRadius: BorderRadius.circular(40.0),
child: Container(
width: 50.0,
height: 50.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40.0),
color: Colors.white,
),
child: Center(
child:
Icon(Icons.favorite, color: Colors.grey[700]),
),
),
),
],
),
),
],
),
Padding(
padding: const EdgeInsets.only(top: 12.0, left: 12.0),
child: Text(title,
style: TextStyle(
color: Colors.black,
fontSize: 18.0,
fontWeight: FontWeight.bold)),
),
circleWidgets(bokingQty),
],
),
),
);
}
Widget circleWidgets(String bokingQty) {
return Padding(
padding: const EdgeInsets.only(top: 12.0, left: 12.0),
child: Row(
children: <Widget>[
Stack(
children: <Widget>[
Container(
width: 30.0,
height: 30.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40.0),
border: Border.all(color: Colors.white),
image: DecorationImage(
image: AssetImage('assets/person.jpeg'),
fit: BoxFit.cover)),
),
Positioned(
left: 20.0,
top: 1.0,
child: Stack(
children: <Widget>[
Container(
width: 30.0,
height: 30.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40.0),
color: Colors.white),
),
],
),
),
Positioned(
left: 16.0,
child: Container(
width: 30.0,
height: 30.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40.0),
border: Border.all(color: Colors.white, width: 1.5),
image: DecorationImage(
image: AssetImage('assets/person.jpeg'),
fit: BoxFit.cover)),
),
),
// Positioned(
// left: 30.0,
// top: 1.0,
// child: Stack(
// children: <Widget>[
// Container(
// width: 30.0,
// height: 30.0,
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(40.0),
// color: Colors.white),
// ),
// ],
// ),
// ),
],
),
SizedBox(
width: 90.0,
),
Text(bokingQty, style: TextStyle(color: Colors.grey, fontSize: 18.0))
],
),
);
}
}
| 0 |
mirrored_repositories/Flutter-UIs-Collection/Travel-Screens-UI/lib | mirrored_repositories/Flutter-UIs-Collection/Travel-Screens-UI/lib/screens/detail_screen.dart | import 'package:flutter/material.dart';
class DetailScreen extends StatelessWidget {
String image, title;
DetailScreen(this.image, this.title);
@override
Widget build(BuildContext context) {
return Scaffold(
body: ListView(
children: <Widget>[
Column(
children: <Widget>[
Stack(
children: <Widget>[
Container(
height: MediaQuery.of(context).size.height - 575.0,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('$image'), fit: BoxFit.cover)),
),
Padding(
padding: const EdgeInsets.only(left: 25.0, top: 45.0),
),
Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Padding(
padding:
const EdgeInsets.only(left: 25.0, top: 45.0),
child: Container(
width: 40.0,
height: 40.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40.0),
color: Colors.white,
),
child: Center(
child: GestureDetector(
onTap: (() {
Navigator.pop(context);
}),
child: Icon(Icons.keyboard_arrow_left,
color: Colors.black),
),
),
),
),
Padding(
padding:
const EdgeInsets.only(right: 25.0, top: 45.0),
child: Container(
width: 40.0,
height: 40.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40.0),
color: Colors.white,
),
child: Center(
child:
Icon(Icons.more_horiz, color: Colors.black),
),
),
)
],
),
Padding(
padding: const EdgeInsets.only(top: 120.0),
child: Stack(children: <Widget>[
Container(
height: 120.0,
decoration: BoxDecoration(
color: Colors.grey[850],
borderRadius: BorderRadius.only(
topLeft: Radius.circular(40.0),
topRight: Radius.circular(40.0))),
child: Center(
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.fromLTRB(
12.0, 15.0, 12.0, 5.0),
child: Text(title,
style: TextStyle(
color: Colors.white,
fontFamily: 'Cardo',
fontSize: 24.0,
)),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(Icons.star,
color: Colors.yellow, size: 15.0),
Icon(Icons.star,
color: Colors.yellow, size: 15.0),
Icon(Icons.star,
color: Colors.yellow, size: 15.0),
Icon(Icons.star,
color: Colors.white, size: 15.0),
Icon(Icons.star,
color: Colors.white, size: 15.0),
Padding(
padding: const EdgeInsets.all(6.0),
child: Text('600 reviews',
style: TextStyle(
color: Colors.white,
fontSize: 14.0)),
)
],
)
],
),
),
),
Padding(
padding: const EdgeInsets.only(top: 90.0),
child: Stack(
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width,
height: 400.0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(38.0),
topRight: Radius.circular(38.0))),
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(12.0),
child: Text('DESCRIPTION',
style: TextStyle(
color: Colors.black,
fontSize: 15.0,
fontWeight: FontWeight.bold)),
),
Padding(
padding: const EdgeInsets.fromLTRB(
8.0, 4.0, 8.0, 2.0),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Text(
'At the heart of the Louvre is the castle-fortress-The Great Tower',
style: TextStyle(fontSize: 12.0),
),
Text(
'of the Louvre, erected by King Philip Augustus in 1190.',
style: TextStyle(fontSize: 12.0),
),
Row(
children: <Widget>[
Text(
'One of the main purposes of the castle was to observe...',
style:
TextStyle(fontSize: 12.0),
),
Text('read more',
style: TextStyle(
decoration:
TextDecoration
.underline,
color: Colors.red,
fontSize: 13.0,
fontWeight:
FontWeight.bold))
],
),
Padding(
padding: const EdgeInsets.only(
top: 20.0),
child: Text('Travel guide',
style: TextStyle(
fontWeight:
FontWeight.bold,
color: Colors.black,
fontFamily: 'Cardo',
fontSize: 24.0)),
)
],
),
),
Expanded(
child: GridView.count(
crossAxisCount: 3,
mainAxisSpacing: 8.0,
crossAxisSpacing: 8.0,
children: <Widget>[
cardWidget(
Icons.home, 'Hotel', '20'),
cardWidget(Icons.ac_unit,
'Attractions', '06'),
cardWidget(Icons.navigation,
'Navigation', '08'),
cardWidget(Icons.comment,
'Comments', '200'),
cardWidget(Icons.photo_library,
'Photos', '1200'),
cardWidget(Icons.flight_takeoff,
'Travel', '10'),
],
),
),
],
),
),
],
),
)
]),
),
],
),
],
),
],
),
Container(
width: MediaQuery.of(context).size.width,
height: 100.0,
decoration: BoxDecoration(
color: Colors.black,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(40.0),
topRight: Radius.circular(40.0))),
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('Let\'s Go',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 20.0)),
Padding(
padding: const EdgeInsets.all(8.0),
child: Icon(Icons.arrow_forward, color: Colors.white),
)
],
),
),
)
],
),
);
}
Widget cardWidget(IconData icon, String title, String number) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Material(
elevation: 8.0,
child: Container(
width: 20.0,
height: 100.0,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(12.0),
child: Stack(
children: <Widget>[
Container(
width: 50.0,
height: 50.0,
decoration: BoxDecoration(
color: Colors.red[100],
borderRadius: BorderRadius.circular(40.0)),
),
Positioned(
left: 8.0,
top: 7.0,
child: Material(
color: Colors.white,
borderRadius: BorderRadius.circular(40.0),
elevation: 1.0,
child: Container(
width: 45.0,
height: 45.0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(40.0)),
child: Center(
child: Icon(icon, color: Colors.red),
),
),
),
)
],
),
),
Text(
title,
style: TextStyle(color: Colors.black, fontSize: 12.0),
),
Padding(
padding: const EdgeInsets.all(2.0),
child: Text(
number,
style: TextStyle(color: Colors.red, fontSize: 12.0),
),
)
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/Flutter-UIs-Collection/Travel-Screens-UI | mirrored_repositories/Flutter-UIs-Collection/Travel-Screens-UI/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:travel_app_ui/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-UIs-Collection/Bill-Payments-Screen-UI | mirrored_repositories/Flutter-UIs-Collection/Bill-Payments-Screen-UI/lib/main.dart | import 'package:flutter/material.dart';
import 'package:payments_screens/screens/home_screen.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Bill Payments Screen",
home: HomeScreen(),
);
}
}
| 0 |
mirrored_repositories/Flutter-UIs-Collection/Bill-Payments-Screen-UI/lib | mirrored_repositories/Flutter-UIs-Collection/Bill-Payments-Screen-UI/lib/screens/home_screen.dart | import 'package:flutter/material.dart';
import 'package:payments_screens/screens/detail_screen.dart';
class HomeScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: <Widget>[
Stack(
children: <Widget>[
ClipPath(
clipper: OrangeClipper(),
child: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height - 600.0,
decoration: BoxDecoration(
color: Colors.orange,
),
),
),
ClipPath(
clipper: BlackClipper(),
child: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height - 600.0,
decoration: BoxDecoration(
color: Colors.black,
),
),
),
Positioned(
top: 80.0,
left: 25.0,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'My Bills',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 24.0),
),
Padding(
padding: const EdgeInsets.only(top: 50.0),
child: Text(
'Total Bills Due',
style: TextStyle(
color: Colors.white,
// fontWeight: FontWeight.bold,
fontSize: 15.0),
),
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Text(
'\$3710.00',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 18.0),
),
),
],
),
),
Positioned(
top: 182.0,
left: 314.0,
child: Material(
elevation: 2.0,
borderRadius: BorderRadius.circular(40.0),
child: Container(
width: 45.0,
height: 45.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40.0),
color: Colors.black,
),
child: Center(
child: Icon(
Icons.more,
color: Colors.white,
size: 18.0,
),
),
),
),
)
],
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Column(
children: <Widget>[
cardWidget(
context,
'assets/kengenlogo.jpeg',
'KenGen Power',
'ID: 123456789',
'Auto Pay on 24th May 18',
'\$1240.00',
'Due in 3 days',
Colors.green),
Padding(
padding: const EdgeInsets.only(top: 12.0),
),
cardWidget(
context,
'assets/totallogo.jpg',
'Total Gas',
'ID: 123456789',
'Enable Auto Pay',
'\$1490.00',
'Due in 2 days',
Colors.grey),
Padding(
padding: const EdgeInsets.only(top: 12.0),
),
cardWidget(
context,
'assets/airtellogo.png',
'Airtel Broadband',
'ID: 123456789',
'Enable Auto Pay',
'\$1000.00',
'Due in 2 days',
Colors.grey),
],
),
),
Padding(
padding: const EdgeInsets.only(top: 50.0),
child: RaisedButton(
color: Colors.indigo[700],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.0)
),
child: Padding(
padding: const EdgeInsets.only(left: 60.0, right: 60.0, top: 15.0,bottom: 15.0),
child: Text('Pay all bills', style: TextStyle(color: Colors.white),),
),
onPressed: (){
Navigator.push(context, MaterialPageRoute(
builder: (context) => DetailScreen(),
));
},
),
)
],
),
);
}
Widget cardWidget(BuildContext context, String image, String title,
String subtitle, String desc, String amount, String days, Color color) {
return Material(
elevation: 2.0,
borderRadius: BorderRadius.circular(18.0),
child: Container(
width: MediaQuery.of(context).size.width - 30.0,
height: 130.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(18.0),
color: Colors.white,
),
child: Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Row(
children: <Widget>[
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
ListTile(
title: Text(
title,
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 15.0),
),
leading: Container(
width: 40.0,
height: 40.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
border: Border.all(color: Colors.black, width: 1),
image: DecorationImage(image: AssetImage(image))),
),
subtitle: Text(
subtitle,
style: TextStyle(color: Colors.grey, fontSize: 12.0),
),
trailing: Container(
width: 80.0,
height: 25.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0),
color: Colors.grey[300]),
child: Center(
child: Text(
'Select',
style: TextStyle(color: Colors.black, fontSize: 12.0),
),
),
),
),
Padding(
padding: const EdgeInsets.only(left: 12.0, right: 12.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
desc, style: TextStyle(
decoration: TextDecoration.underline,
color: color,
fontSize: 14.0,
fontWeight: FontWeight.bold
),
),
Column(
children: <Widget>[
Text(
amount, style: TextStyle(
color: Colors.black,
fontSize: 16.0,
fontWeight: FontWeight.bold
),
),
Text(
days, style: TextStyle(
color: Colors.grey,
fontSize: 13.0,
fontWeight: FontWeight.bold
),
),
],
)
],
),
)
],
),
),
Container(
width: 5.0,
height: 45.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.0),
color: Colors.grey,
),
)
],
),
),
),
);
}
}
class OrangeClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
Path path = Path();
path.lineTo(0.0, size.height);
path.lineTo(size.width / 2 + 85.0, size.height);
var firstControlPoint = Offset(size.width / 2 + 140.0, size.height - 105.0);
var firstEndPoint = Offset(size.width - 1.0, size.height);
path.quadraticBezierTo(firstControlPoint.dx, firstControlPoint.dy,
firstEndPoint.dx, firstEndPoint.dy);
path.lineTo(size.width, 0.0);
path.close();
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) => false;
}
class BlackClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
Path path = Path();
path.lineTo(0.0, size.height);
path.lineTo(size.width / 2 - 30.0, size.height);
var firstControlPoint =
Offset(size.width / 2 + 175.0, size.height / 2 - 30.0);
var firstEndPoint = Offset(size.width / 2, 0.0);
path.quadraticBezierTo(firstControlPoint.dx, firstControlPoint.dy,
firstEndPoint.dx, firstEndPoint.dy);
path.lineTo(size.width / 2 + 75.0, size.height / 2 - 30.0);
path.lineTo(size.width / 2, 0.0);
path.close();
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) => false;
}
| 0 |
mirrored_repositories/Flutter-UIs-Collection/Bill-Payments-Screen-UI/lib | mirrored_repositories/Flutter-UIs-Collection/Bill-Payments-Screen-UI/lib/screens/detail_screen.dart | import 'package:flutter/material.dart';
class DetailScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: <Widget>[
ClipPath(
clipper: OrangeClipper(),
child: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height - 250.0,
decoration: BoxDecoration(
color: Colors.orange,
),
),
),
ClipPath(
clipper: BlackClipper(),
child: Container(
width: MediaQuery.of(context).size.width - 230.0,
height: MediaQuery.of(context).size.height - 250.0,
decoration: BoxDecoration(
color: Colors.black,
),
),
),
Center(
child: Material(
elevation: 30.0,
color: Colors.white12,
borderRadius: BorderRadius.circular(18.0),
child: Container(
width: 320.0,
height: 330.0,
decoration: BoxDecoration(
color: Colors.white12,
borderRadius: BorderRadius.circular(18.0)),
),
),
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Center(
child: ClipPath(
clipper: ZigZagClipper(),
child: Container(
width: 330.0,
height: 530.0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(18.0)),
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Container(
width: 150.0,
height: 150.0,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/dart.jpg'))),
),
),
Text('Success!',
style: TextStyle(
fontSize: 22.0,
color: Colors.black,
fontWeight: FontWeight.bold)),
Padding(
padding: const EdgeInsets.only(top: 4.0),
child: Text('Payment is completed for 2 bills.',
style: TextStyle(fontSize: 15.0)),
),
Padding(
padding: const EdgeInsets.only(top: 12.0),
child: Container(
width: 300.0,
height: 150.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.0),
border:
Border.all(color: Colors.grey, width: 1.0)),
child: Column(
children: <Widget>[
ListTile(
leading: Icon(
Icons.check_circle,
color: Colors.green,
size: 35.0,
),
title: Text(
'KenZen Power',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 15.0),
),
subtitle: Text(
'Txn ID: 34374287',
style: TextStyle(
color: Colors.grey,
fontWeight: FontWeight.bold,
fontSize: 12.0),
),
trailing: Padding(
padding: const EdgeInsets.only(top: 20.0),
child: Text(
'\$1240.00',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 12.0),
),
),
),
Container(
width: 300.0,
height: 1.0,
color: Colors.grey,
),
ListTile(
leading: Icon(
Icons.check_circle,
color: Colors.green,
size: 35.0,
),
title: Text(
'Total Gas',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 15.0),
),
subtitle: Text(
'Txn ID: 64234285',
style: TextStyle(
color: Colors.grey,
fontWeight: FontWeight.bold,
fontSize: 12.0),
),
trailing: Padding(
padding: const EdgeInsets.only(top: 20.0),
child: Text(
'\$1490.00',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 12.0),
),
),
),
],
),
),
),
Padding(
padding: const EdgeInsets.only(top: 40.0),
child: Text(
'Total Amount',
style: TextStyle(
color: Colors.grey,
fontWeight: FontWeight.bold,
fontSize: 15.0),
),
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Text(
'\$2730.00',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 20.0),
),
)
],
),
),
),
),
Padding(
padding: const EdgeInsets.only(top: 30.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Column(
children: <Widget>[
Container(
width: 40.0,
height: 40.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40.0),
color: Colors.indigo[700]),
child: Center(
child: Icon(
Icons.share,
color: Colors.white,
size: 20.0,
),
),
),
Text(
'Share',
style: TextStyle(
color: Colors.indigo[700], fontSize: 12.0),
)
],
),
Column(
children: <Widget>[
Container(
width: 40.0,
height: 40.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40.0),
color: Colors.indigo[700]),
child: Center(
child: Icon(
Icons.print,
color: Colors.white,
size: 20.0,
),
),
),
Text(
'Print',
style: TextStyle(
color: Colors.indigo[700], fontSize: 12.0),
)
],
)
],
),
),
Padding(
padding: const EdgeInsets.only(top: 30.0),
child: InkWell(
splashColor: Colors.red,
onTap: () => Navigator.pop(context),
child: Container(
width: 300.0,
height: 50.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.0),
border: Border.all(color: Colors.indigo[700], width: 1.5),
color: Colors.white),
child: Center(
child: Text(
'Done',
style:
TextStyle(color: Colors.indigo[700], fontSize: 15.0),
),
),
),
),
)
],
),
],
),
);
}
}
class ZigZagClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
Path path = Path();
path.lineTo(3.0, size.height - 10.0);
var firstControlPoint = Offset(23.0, size.height - 40.0);
var firstEndPoint = Offset(38.0, size.height - 5.0);
path.quadraticBezierTo(firstControlPoint.dx, firstControlPoint.dy,
firstEndPoint.dx, firstEndPoint.dy);
var secondControlPoint = Offset(58.0, size.height - 40.0);
var secondEndPoint = Offset(75.0, size.height - 5.0);
path.quadraticBezierTo(secondControlPoint.dx, secondControlPoint.dy,
secondEndPoint.dx, secondEndPoint.dy);
var thirdControlPoint = Offset(93.0, size.height - 40.0);
var thirdEndPoint = Offset(110.0, size.height - 5.0);
path.quadraticBezierTo(thirdControlPoint.dx, thirdControlPoint.dy,
thirdEndPoint.dx, thirdEndPoint.dy);
var fourthControlPoint = Offset(128.0, size.height - 40.0);
var fourthEndPoint = Offset(150.0, size.height - 5.0);
path.quadraticBezierTo(fourthControlPoint.dx, fourthControlPoint.dy,
fourthEndPoint.dx, fourthEndPoint.dy);
var fifthControlPoint = Offset(168.0, size.height - 40.0);
var fifthEndPoint = Offset(185.0, size.height - 5.0);
path.quadraticBezierTo(fifthControlPoint.dx, fifthControlPoint.dy,
fifthEndPoint.dx, fifthEndPoint.dy);
var sixthControlPoint = Offset(205.0, size.height - 40.0);
var sixthEndPoint = Offset(220.0, size.height - 5.0);
path.quadraticBezierTo(sixthControlPoint.dx, sixthControlPoint.dy,
sixthEndPoint.dx, sixthEndPoint.dy);
var sevenControlPoint = Offset(240.0, size.height - 40.0);
var sevenEndPoint = Offset(255.0, size.height - 5.0);
path.quadraticBezierTo(sevenControlPoint.dx, sevenControlPoint.dy,
sevenEndPoint.dx, sevenEndPoint.dy);
var eightControlPoint = Offset(275.0, size.height - 40.0);
var eightEndPoint = Offset(290.0, size.height - 5.0);
path.quadraticBezierTo(eightControlPoint.dx, eightControlPoint.dy,
eightEndPoint.dx, eightEndPoint.dy);
var ninthControlPoint = Offset(310.0, size.height - 40.0);
var ninthEndPoint = Offset(330.0, size.height - 5.0);
path.quadraticBezierTo(ninthControlPoint.dx, ninthControlPoint.dy,
ninthEndPoint.dx, ninthEndPoint.dy);
path.lineTo(size.width, size.height - 10.0);
path.lineTo(size.width, 0.0);
path.close();
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) => false;
}
class BlackClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
Path path = Path();
path.lineTo(0.0, size.height);
path.lineTo(size.width / 2, size.height - 50.0);
path.lineTo(size.width, 0.0);
path.close();
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) => false;
}
class OrangeClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
Path path = Path();
path.lineTo(size.width - 250.0, size.height - 50.0);
path.lineTo(size.width, size.height);
path.lineTo(size.width, 0.0);
path.close();
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) => false;
}
| 0 |
mirrored_repositories/Flutter-UIs-Collection/Bill-Payments-Screen-UI | mirrored_repositories/Flutter-UIs-Collection/Bill-Payments-Screen-UI/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:payments_screens/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-UIs-Collection/profile_screen | mirrored_repositories/Flutter-UIs-Collection/profile_screen/lib/account.dart | import 'package:flutter/material.dart';
class AccountPage extends StatelessWidget {
const AccountPage();
@override
Widget build(BuildContext context) {
return Center(
child: Text('Profile Page', style:TextStyle(color:Colors.black,fontSize: 25.0)),
);
}
} | 0 |
mirrored_repositories/Flutter-UIs-Collection/profile_screen | mirrored_repositories/Flutter-UIs-Collection/profile_screen/lib/custom.dart | import 'package:flutter/material.dart';
| 0 |
mirrored_repositories/Flutter-UIs-Collection/profile_screen | mirrored_repositories/Flutter-UIs-Collection/profile_screen/lib/grid_section.dart | import 'package:flutter/material.dart';
import 'package:profile_screen/view_post.dart';
class GridSection extends StatelessWidget {
List<String> images = ["assets/list_item_one.jpg" ,
"assets/list_item_second.jpg",
"assets/list_item_third.jpg",
"assets/list_item_fourth.jpg",
"assets/list_item_fifth.jpg",
"assets/list_item_sixth.jpg",
];
GridSection();
@override
Widget build(BuildContext context) {
return GridView.count(
shrinkWrap: true,
crossAxisCount: 3,
children: List.generate(images.length, (index){
return Padding(
padding: const EdgeInsets.all(8.0),
child: GestureDetector(
onTap: (){
Navigator.push(context, MaterialPageRoute(
builder: ((context) => ViewPostPage(images[index]))
));
},
child: Container(
height: 100.0,
width: 100.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
image: DecorationImage(
fit: BoxFit.cover,
image: AssetImage(images[index]))),
),
),
);
}),
);
}
} | 0 |
mirrored_repositories/Flutter-UIs-Collection/profile_screen | mirrored_repositories/Flutter-UIs-Collection/profile_screen/lib/view_post.dart | import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class ViewPostPage extends StatelessWidget {
String post;
ViewPostPage(this.post);
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: true,
body: Stack(
children: <Widget>[
Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.center,
end: Alignment.bottomRight,
colors: [
Colors.black,
Colors.purple
]
)
),
),
Container(
height: MediaQuery.of(context).size.height * 0.65,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(30.0),
bottomRight: Radius.circular(30.0)),
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [Colors.indigo[400], Colors.purple[200]])),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Padding(
padding: EdgeInsets.only(
left: 20.0,
top: 60.0,
),
child: GestureDetector(
onTap: (){
Navigator.pop(context);
},
child: Icon(
Icons.arrow_back,
color: Colors.white,
),
)),
Padding(
padding: EdgeInsets.only(
left: 70.0,
right: 70.0,
top: 60.0,
),
child: Container(
height: 40.0,
width: 40.0,
decoration: BoxDecoration(
border: Border.all(color: Colors.white, width: 2),
borderRadius: BorderRadius.circular(100.0),
image: DecorationImage(
image: AssetImage("assets/profile_kylie.jpg"))),
),
),
Padding(
padding: EdgeInsets.only(
right: 20.0,
top: 60.0,
),
child: Icon(
Icons.more_horiz,
color: Colors.white,
),
),
],
),
Positioned(
right: 20.0,
left: 20.0,
top: 120.0,
child: Container(
height: 300.0,
width: 250.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0),
image: DecorationImage(
fit: BoxFit.cover,
image: AssetImage(post),
)),
),
),
Positioned(
top: 470.0,
left: 20.0,
right: 20.0,
child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Icon(
Icons.favorite_border,
color: Colors.black38,
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text(
'2,203',
style: TextStyle(color: Colors.white, fontSize: 15.0),
),
),
Padding(
padding: const EdgeInsets.only(left: 30.0),
child: Icon(
Icons.message,
color: Colors.black38,
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text('15',
style: TextStyle(color: Colors.white, fontSize: 15.0)),
),
SizedBox(
width: 160.0,
),
Padding(
padding: const EdgeInsets.only(right: 10.0),
child: Icon(
Icons.bookmark_border,
color: Colors.black38,
),
)
],
),
),
Positioned(
top: 550.0,
left: 10.0,
right: 10.0,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
ListTile(
leading: Container(
width: 50.0,
height: 50.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40.0),
border: Border.all(color: Colors.white , width: 2),
image: DecorationImage(
fit: BoxFit.cover,
image: AssetImage('assets/second_comment_profile_pic.jpg')
)
),
),
title: Text('Janet Martin' ,style:TextStyle(fontSize:15.0 , color: Colors.white54)),
subtitle: Text('Our blue top is available!' ,style:TextStyle(fontSize:15.0 , color: Colors.white)),
trailing: Icon(Icons.favorite_border , color: Colors.white54,),
),
ListTile(
leading: Container(
height: 50.0,
width: 50.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40.0),
border: Border.all(color: Colors.white , width: 2),
image: DecorationImage(
fit: BoxFit.cover,
image: AssetImage('assets/first_comment_profile_pic.jpg')
)
),
),
title: Text('Zarela Reed' ,style:TextStyle(fontSize:15.0 , color: Colors.white54)),
subtitle: Text('Great!' ,style:TextStyle(fontSize:15.0 , color: Colors.white)),
trailing: Icon(Icons.favorite_border , color: Colors.white54,),
),
Padding(
padding: const EdgeInsets.only(top:28.0 , left: 10.0 , right: 10.0),
child: Container(
height: 60.0,
width: 350.0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(30.0)
),
child: Padding(
padding: const EdgeInsets.only(top:8.0,left:8.0,right: 10.0),
child: TextField(
decoration: InputDecoration(
hintText: 'Add a comment...',
prefixIcon: Padding(
padding: const EdgeInsets.only(left:8.0 , bottom: 8.0 , right: 8.0),
child: Container(
height: 40.0,
width: 40.0,
decoration: BoxDecoration(
border: Border.all(color: Colors.white, width: 2),
borderRadius: BorderRadius.circular(100.0),
image: DecorationImage(
fit: BoxFit.cover,
image: AssetImage("assets/second_comment_profile_pic.jpg"))),
),
),
),
),
),
),
)
],
),
)
],
),
);
}
}
| 0 |
mirrored_repositories/Flutter-UIs-Collection/profile_screen | mirrored_repositories/Flutter-UIs-Collection/profile_screen/lib/search.dart | import 'package:flutter/material.dart';
class SearchPage extends StatelessWidget {
const SearchPage();
@override
Widget build(BuildContext context) {
return Center(
child: Text('Search Page', style:TextStyle(color:Colors.black,fontSize: 25.0)),
);
}
} | 0 |
mirrored_repositories/Flutter-UIs-Collection/profile_screen | mirrored_repositories/Flutter-UIs-Collection/profile_screen/lib/favourite.dart | import 'package:flutter/material.dart';
class FavouritePage extends StatelessWidget {
const FavouritePage();
@override
Widget build(BuildContext context) {
return Center(
child: Text('Favourite Page', style:TextStyle(color:Colors.black,fontSize: 25.0)),
);
}
} | 0 |
mirrored_repositories/Flutter-UIs-Collection/profile_screen | mirrored_repositories/Flutter-UIs-Collection/profile_screen/lib/buttonsection.dart | import 'package:flutter/material.dart';
class ButtonSection extends StatelessWidget {
const ButtonSection();
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
InkWell(
onTap: () {},
child: Container(
height: 50.0,
width: 230.0,
child: Center(
child: Text(
'Follow',
style: TextStyle(color: Colors.white, fontSize: 20.0),
)),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
gradient: LinearGradient(
colors: [Colors.blue, Colors.deepPurple[300]])),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: InkWell(
onTap: () {},
child: Container(
height: 50.0,
width: 60.0,
child: Icon(Icons.send),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
color: Colors.grey[300]),
),
),
)
],
);
}
} | 0 |
mirrored_repositories/Flutter-UIs-Collection/profile_screen | mirrored_repositories/Flutter-UIs-Collection/profile_screen/lib/main.dart | import 'package:flutter/material.dart';
import 'package:profile_screen/account.dart';
import 'package:profile_screen/favourite.dart';
import 'package:profile_screen/home.dart';
import 'package:profile_screen/search.dart';
void main() => runApp(App());
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: MainPage(),
);
}
}
class MainPage extends StatefulWidget {
@override
_MainPageState createState() => _MainPageState();
}
class _MainPageState extends State<MainPage> {
int selectedIndex = 0;
PageController pageController;
void navigationTabbed(int index) {
pageController.jumpToPage(index);
}
void onPageChanged(int index) {
setState(() {
selectedIndex = index;
});
}
@override
void initState() {
super.initState();
pageController = PageController();
}
@override
void dispose() {
super.dispose();
pageController.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: Icon(Icons.add),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
bottomNavigationBar: BottomAppBar(
shape: CircularNotchedRectangle(),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
InkWell(
onTap: () {
navigationTabbed(0);
},
child: Tab(
icon: Icon(Icons.home,
size: 30.0,
color: selectedIndex == 0 ? Colors.black : Colors.grey),
text: '',
),
),
InkWell(
onTap: () {
navigationTabbed(1);
},
child: Tab(
icon: Icon(Icons.search,
size: 30.0,
color: selectedIndex == 1 ? Colors.black : Colors.grey),
text: '',
),
),
InkWell(
onTap: () {
navigationTabbed(2);
},
child: Tab(
icon: Icon(Icons.favorite_border,
size: 30.0,
color: selectedIndex == 2 ? Colors.black : Colors.grey),
text: '',
),
),
InkWell(
onTap: () {
navigationTabbed(3);
},
child: Tab(
icon: Icon(Icons.account_box,
size: 30.0,
color: selectedIndex == 3 ? Colors.black : Colors.grey),
text: '',
),
),
],
),
),
appBar: AppBar(
elevation: 0.0,
backgroundColor: Colors.white,
leading: Icon(
Icons.arrow_back,
color: Colors.black,
),
actions: <Widget>[
Padding(
padding: const EdgeInsets.only(right: 12.0),
child: Icon(
Icons.more_horiz,
color: Colors.black,
),
)
],
title: Text(
'kylie jenner',
style: TextStyle(color: Colors.black),
)),
body: PageView(
controller: pageController,
onPageChanged: onPageChanged,
children: <Widget>[const HomePage(),
const SearchPage() ,
const FavouritePage() ,
const AccountPage()
],
),
);
}
}
| 0 |
mirrored_repositories/Flutter-UIs-Collection/profile_screen | mirrored_repositories/Flutter-UIs-Collection/profile_screen/lib/horizontal_list_section.dart | import 'package:flutter/material.dart';
class HorizontalListSection extends StatelessWidget {
final List<String> stories = ['assets/story_first.jpg' , 'assets/story_second.jpg' , 'assets/story_third.jpg' , 'assets/story_fourth.jpg' , 'assets/story_fifth.jpg'];
HorizontalListSection();
@override
Widget build(BuildContext context) {
return ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: stories.length,
shrinkWrap: true,
itemBuilder: (BuildContext context, int index) {
return Padding(
padding: const EdgeInsets.only(right: 30.0),
child: Material(
borderRadius: BorderRadius.circular(40.0),
child: Container(
height: 85.0,
width: 70.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40.0),
image: DecorationImage(
fit: BoxFit.cover,
image: AssetImage(stories[index]))),
),
),
);
},
);
}
} | 0 |
mirrored_repositories/Flutter-UIs-Collection/profile_screen | mirrored_repositories/Flutter-UIs-Collection/profile_screen/lib/home.dart | import 'package:flutter/material.dart';
import 'package:profile_screen/buttonsection.dart';
import 'package:profile_screen/grid_section.dart';
import 'package:profile_screen/horizontal_list_section.dart';
import 'package:profile_screen/statswidget.dart';
class HomePage extends StatelessWidget {
const HomePage();
@override
Widget build(BuildContext context) {
return ListView(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 40.0, top: 35.0),
child: Row(
children: <Widget>[
Material(
shadowColor: Colors.grey[300],
elevation: 40.0,
borderRadius: BorderRadius.circular(40.0),
child: Container(
height: 90.0,
width: 90.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40.0),
image: DecorationImage(
fit: BoxFit.cover,
image: AssetImage("assets/upated_pic.jpg"))),
),
),
SizedBox(
width: 30.0,
),
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text('kylie jenner',
style: TextStyle(color: Colors.black, fontSize: 25.0)),
Padding(
padding: const EdgeInsets.only(top: 5.0),
child: Text('Fashion',
style: TextStyle(
color: Colors.grey[400], fontSize: 15.0)),
),
Padding(
padding: const EdgeInsets.only(top: 5.0),
child: Text('Models',
style: TextStyle(
color: Colors.grey[700], fontSize: 15.0)),
),
Padding(
padding: const EdgeInsets.only(top: 5.0),
child: Text('www.thekyliejenner.com',
style: TextStyle(color: Colors.blue, fontSize: 12.0)),
),
],
)
],
),
),
Padding(
padding: EdgeInsets.only(top: 40.0, left: 40.0, right: 40.0),
child: Divider(
color: Colors.grey,
),
),
Padding(
padding: EdgeInsets.only(left: 20.0, right: 20.0, top: 10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: const StatsWidget(
number: '490',
title: 'Posts',
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child:
const StatsWidget(number: '120k', title: 'Followers')),
Padding(
padding: const EdgeInsets.all(8.0),
child: const StatsWidget(number: '80k', title: 'Following'))
],
),
),
Padding(
padding: EdgeInsets.only(top: 10.0, left: 40.0, right: 40.0),
child: Divider(
color: Colors.grey,
),
),
Padding(
padding: EdgeInsets.only(
top: 25.0, left: 35.0, right: 35.0, bottom: 10.0),
child: const ButtonSection(),
),
SizedBox(
height: 85.0,
width: 120.0,
child: Padding(
padding: EdgeInsets.only(
top: 20.0,
left: 20.0,
right: 20.0,
),
// child: horizontalListSection(),
child: HorizontalListSection(),
),
),
Padding(
padding: EdgeInsets.only(
top: 20.0,
left: 20.0,
right: 20.0,
),
// child: horizontalListSection(),
child: GridSection(),
),
],
);
}
} | 0 |
mirrored_repositories/Flutter-UIs-Collection/profile_screen | mirrored_repositories/Flutter-UIs-Collection/profile_screen/lib/statswidget.dart | import 'package:flutter/material.dart';
class StatsWidget extends StatelessWidget {
final number;
final title;
const StatsWidget({this.number, this.title});
@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
Text(
number,
style: TextStyle(fontSize: 25.0, color: Colors.black),
),
Padding(
padding: EdgeInsets.only(top: 8.0),
child: Text(
title,
style: TextStyle(fontSize: 15.0, color: Colors.grey),
),
)
],
);
}
} | 0 |
mirrored_repositories/Flutter-UIs-Collection/profile_screen | mirrored_repositories/Flutter-UIs-Collection/profile_screen/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:profile_screen/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-Persistent-Bottom-Navigation-Bar-Nested-Routes | mirrored_repositories/Flutter-Persistent-Bottom-Navigation-Bar-Nested-Routes/lib/mainwrapper.dart | import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_nested_persistance_navigation/navigations/updates_navigation.dart';
import 'package:flutter_nested_persistance_navigation/navigations/wishlists_navigation.dart';
class MainWrapper extends StatefulWidget {
const MainWrapper({super.key});
@override
MainWrapperState createState() => MainWrapperState();
}
class MainWrapperState extends State<MainWrapper> {
int _selectedIndex = 0;
final List<GlobalKey<NavigatorState>> _navigatorKeys = [
wishListNavigatorKey,
updatesNavigatorKey,
];
Future<bool> _systemBackButtonPressed() async {
if (_navigatorKeys[_selectedIndex].currentState?.canPop() == true) {
_navigatorKeys[_selectedIndex]
.currentState
?.pop(_navigatorKeys[_selectedIndex].currentContext);
return false;
} else {
SystemChannels.platform.invokeMethod<void>('SystemNavigator.pop');
return true; // Indicate that the back action is handled
}
}
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: _systemBackButtonPressed,
child: Scaffold(
bottomNavigationBar: NavigationBar(
onDestinationSelected: (int index) {
setState(() {
_selectedIndex = index;
});
},
selectedIndex: _selectedIndex,
destinations: const [
NavigationDestination(
selectedIcon: Icon(Icons.favorite),
icon: Icon(Icons.favorite_border),
label: 'Wishlist',
),
NavigationDestination(
selectedIcon: Icon(Icons.notifications),
icon: Icon(Icons.notifications_none),
label: 'Updates',
),
],
),
body: SafeArea(
top: false,
child: IndexedStack(
index: _selectedIndex,
children: const <Widget>[
/// First Route
Wishlist(),
/// Second Route
UpdatesNavigator(),
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/Flutter-Persistent-Bottom-Navigation-Bar-Nested-Routes | mirrored_repositories/Flutter-Persistent-Bottom-Navigation-Bar-Nested-Routes/lib/main.dart | import 'package:flutter/material.dart';
import 'package:flutter_nested_persistance_navigation/mainwrapper.dart';
//
// Created by CodeWithFlexZ
// Tutorials on my YouTube
//
//! Instagram
//! @CodeWithFlexZ
//
//? GitHub
//? AmirBayat0
//
//* YouTube
//* Programming with FlexZ
//
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(useMaterial3: true),
home: const Banner(
message: 'FlexZ',
location: BannerLocation.bottomStart,
child: MainWrapper(),
),
);
}
}
| 0 |
mirrored_repositories/Flutter-Persistent-Bottom-Navigation-Bar-Nested-Routes/lib/views | mirrored_repositories/Flutter-Persistent-Bottom-Navigation-Bar-Nested-Routes/lib/views/wishlist/wishlist.dart | import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class WishlistView extends StatelessWidget {
const WishlistView({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: const Color.fromARGB(255, 210, 52, 52),
title: const Text(
"Wishlist View",
style: TextStyle(color: Colors.white),
),
),
body: SizedBox.expand(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
CupertinoButton(
color: const Color.fromARGB(255, 210, 52, 52),
borderRadius: BorderRadius.circular(15),
child: const Text("Go To Details Wishlist"),
onPressed: () => Navigator.pushNamed(context, '/detailsWishlist'),
),
],
),
),
);
}
}
| 0 |
mirrored_repositories/Flutter-Persistent-Bottom-Navigation-Bar-Nested-Routes/lib/views | mirrored_repositories/Flutter-Persistent-Bottom-Navigation-Bar-Nested-Routes/lib/views/wishlist/details_wishlist.dart | import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class DetailsWishlistView extends StatelessWidget {
const DetailsWishlistView({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: const Icon(
CupertinoIcons.back,
color: Colors.white,
)),
title: const Text(
"Details Wishlist",
style: TextStyle(color: Colors.white),
),
backgroundColor: const Color.fromARGB(255, 210, 52, 52),
),
body: Padding(
padding: const EdgeInsets.all(10),
child: GridView.builder(
itemCount: 80,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
),
itemBuilder: (ctx, i) {
return Card(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.favorite),
const SizedBox(
height: 1,
),
const Text(
"Details Wishlist Items",
textAlign: TextAlign.center,
),
const SizedBox(
height: 8,
),
Text(
"No.$i",
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
)
],
),
);
},
),
),
);
}
}
| 0 |
mirrored_repositories/Flutter-Persistent-Bottom-Navigation-Bar-Nested-Routes/lib/views | mirrored_repositories/Flutter-Persistent-Bottom-Navigation-Bar-Nested-Routes/lib/views/updates/updates.dart | import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class UpdatesView extends StatelessWidget {
const UpdatesView({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text(
"Updates View",
style: TextStyle(color: Colors.white),
),
backgroundColor: Colors.black,
),
body: SizedBox.expand(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
CupertinoButton(
color: Colors.black,
borderRadius: BorderRadius.circular(15),
child: const Text("Go to Details Updates"),
onPressed: () => Navigator.pushNamed(context, '/detailsUpdates'),
),
],
),
),
);
}
}
| 0 |
mirrored_repositories/Flutter-Persistent-Bottom-Navigation-Bar-Nested-Routes/lib/views | mirrored_repositories/Flutter-Persistent-Bottom-Navigation-Bar-Nested-Routes/lib/views/updates/details_updates.dart | import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class DetailsUpdatesView extends StatelessWidget {
const DetailsUpdatesView({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: const Icon(
CupertinoIcons.back,
color: Colors.white,
)),
title: const Text(
"Details Updates",
style: TextStyle(color: Colors.white),
),
backgroundColor: Colors.black,
),
body: Padding(
padding: const EdgeInsets.all(10),
child: GridView.builder(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 1.5,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
),
itemBuilder: (ctx, i) {
return Card(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(
Icons.notifications,
size: 40,
),
const SizedBox(
height: 1,
),
const Text(
"Details Updates Items",
textAlign: TextAlign.center,
),
const SizedBox(
height: 8,
),
Text(
"No.$i",
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
)
],
),
);
},
),
),
);
}
}
| 0 |
mirrored_repositories/Flutter-Persistent-Bottom-Navigation-Bar-Nested-Routes/lib | mirrored_repositories/Flutter-Persistent-Bottom-Navigation-Bar-Nested-Routes/lib/navigations/wishlists_navigation.dart | import 'package:flutter/material.dart';
import 'package:flutter_nested_persistance_navigation/views/wishlist/details_wishlist.dart';
import 'package:flutter_nested_persistance_navigation/views/wishlist/wishlist.dart';
class Wishlist extends StatefulWidget {
const Wishlist({super.key});
@override
WishlistState createState() => WishlistState();
}
GlobalKey<NavigatorState> wishListNavigatorKey = GlobalKey<NavigatorState>();
class WishlistState extends State<Wishlist> {
@override
Widget build(BuildContext context) {
return Navigator(
key: wishListNavigatorKey,
onGenerateRoute: (RouteSettings settings) {
return MaterialPageRoute(
settings: settings,
builder: (BuildContext context) {
if (settings.name == "/detailsWishlist") {
return const DetailsWishlistView();
}
return const WishlistView();
});
},
);
}
}
| 0 |
mirrored_repositories/Flutter-Persistent-Bottom-Navigation-Bar-Nested-Routes/lib | mirrored_repositories/Flutter-Persistent-Bottom-Navigation-Bar-Nested-Routes/lib/navigations/updates_navigation.dart | import 'package:flutter/material.dart';
import 'package:flutter_nested_persistance_navigation/views/updates/details_updates.dart';
import 'package:flutter_nested_persistance_navigation/views/updates/updates.dart';
class UpdatesNavigator extends StatefulWidget {
const UpdatesNavigator({super.key});
@override
UpdatesNavigatorState createState() => UpdatesNavigatorState();
}
GlobalKey<NavigatorState> updatesNavigatorKey = GlobalKey<NavigatorState>();
class UpdatesNavigatorState extends State<UpdatesNavigator> {
@override
Widget build(BuildContext context) {
return Navigator(
key: updatesNavigatorKey,
onGenerateRoute: (RouteSettings settings) {
return MaterialPageRoute(
settings: settings,
builder: (BuildContext context) {
if (settings.name == "/detailsUpdates") {
return const DetailsUpdatesView();
}
return const UpdatesView();
},
);
},
);
}
}
| 0 |
mirrored_repositories/Olxi | mirrored_repositories/Olxi/lib/NavigationPage.dart | // ignore_for_file: prefer_const_constructors
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:olxi/Screen/LoginPage.dart';
import 'package:olxi/Screen/NavigationBarPage.dart';
class NavigationPage extends StatefulWidget {
const NavigationPage({super.key});
@override
State<NavigationPage> createState() => _NavigationPageState();
}
class _NavigationPageState extends State<NavigationPage> {
@override
Widget build(BuildContext context) {
return StreamBuilder(
stream: FirebaseAuth.instance.authStateChanges(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return NavigationBarPage();
} else {
return LoginPage();
}
},
);
}
}
| 0 |
mirrored_repositories/Olxi | mirrored_repositories/Olxi/lib/main.dart | // ignore_for_file: prefer_const_constructors
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:olxi/NavigationPage.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return ScreenUtilInit(
designSize: Size(720, 1280),
builder: (context, child) => MaterialApp(
debugShowCheckedModeBanner: false,
home: NavigationPage(),
),
);
}
}
| 0 |
mirrored_repositories/Olxi/lib | mirrored_repositories/Olxi/lib/Screen/SearchScreen.dart | import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:olxi/Screen/ProductPage.dart';
class SearchScreen extends StatefulWidget {
const SearchScreen({super.key});
@override
State<SearchScreen> createState() => _SearchScreenState();
}
class _SearchScreenState extends State<SearchScreen> {
final FirebaseFirestore _firestore = FirebaseFirestore.instance;
QuerySnapshot? originalQSnap;
List<QueryDocumentSnapshot<Object?>>? qSnap = [];
int counter = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: SingleChildScrollView(
child: Column(
children: [
Padding(
padding: EdgeInsets.all(8.sp),
child: TextField(
onChanged: (v) {
filterResult(v);
},
decoration: InputDecoration(
hintText: "Search here",
hintStyle: GoogleFonts.roboto(
fontSize: 30.sp,
color: Colors.black,
fontWeight: FontWeight.w600,
),
border: OutlineInputBorder(
borderSide: BorderSide(
width: 2.sp,
color: Colors.black,
),
borderRadius: BorderRadius.circular(10.r),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 2.sp,
color: Colors.black,
),
borderRadius: BorderRadius.circular(10.r),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 4.sp,
color: Colors.blueGrey.shade400,
),
borderRadius: BorderRadius.circular(10.r),
),
),
),
),
FutureBuilder(
future: _firestore.collection('data').get(),
builder: (BuildContext context,
AsyncSnapshot<QuerySnapshot> snapshot) {
if (!snapshot.hasData) {
return const Center(
child: CircularProgressIndicator(),
);
} else {
originalQSnap = snapshot.data!;
if (counter == 0) {
qSnap = originalQSnap!.docs;
}
counter = counter + 1;
if (kDebugMode) {
print('counter: $counter');
}
return GridView.builder(
gridDelegate:
const SliverGridDelegateWithFixedCrossAxisCount(
childAspectRatio: .7,
crossAxisCount: 2,
),
physics: const NeverScrollableScrollPhysics(),
itemCount: qSnap?.length,
shrinkWrap: true,
itemBuilder: (BuildContext context, int index) {
// DocumentSnapshot? dSnap = qSnap?[index];
return GestureDetector(
onTap: () {
/*
{
'name': ' new name',
'email': '[email protected]',
'phone': '8956235689',
'gender': 'male',
}
*/
// _firestore.collection('data').doc(dSnap.id).set({
// 'name': 'updatedName'
// }); // replace existing document with new map
// _firestore.collection('data').doc(dSnap?.id).set(
// {
// // 'gender': 'male',
// 'name': ' new name',
// },
// SetOptions(merge: true),
// ); // it will not replace existing document but only the field which is inside this map
},
child: Padding(
padding: EdgeInsets.only(
left: 5.w,
right: 5.w,
bottom: 20.h,
),
child: GestureDetector(
onTap: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => ProductPage(
id: snapshot.data!.docs[index].get('id'),
),
));
},
child: Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.black45, width: 2.w),
borderRadius: BorderRadius.circular(5.r),
),
child: Center(
child: Column(
children: [
SizedBox(height: 20.h),
Image.network(
snapshot.data!.docs[index]
.get('imageUrl')
.toString(),
fit: BoxFit.cover,
height: 300.h),
Text(
snapshot.data!.docs[index]
.get('name')
.toString()
.toUpperCase(),
overflow: TextOverflow.ellipsis,
textScaleFactor: 1.sp,
style: GoogleFonts.robotoFlex(
fontWeight: FontWeight.w700,
fontSize: 45,
),
),
Text(
"₹ ${snapshot.data!.docs[index].get('productprice').toString()}",
textScaleFactor: 1.sp,
overflow: TextOverflow.ellipsis,
style: GoogleFonts.robotoFlex(
fontSize: 35,
fontWeight: FontWeight.w500,
),
),
// Text(dSnap?['name'] ?? ""),
],
),
),
),
),
),
);
},
);
}
},
),
],
),
),
),
);
}
filterResult(String searchText) {
if (searchText.isNotEmpty) {
qSnap = originalQSnap!.docs;
} else {
qSnap = [];
}
qSnap?.removeWhere((element) => !element['name']
.toString()
.toLowerCase()
.contains(searchText.toLowerCase()));
// print('qSnap.lenght1: ' + qSnap!.length.toString());
// qSnap!.clear();
// print('qSnap.lenght2: ' + qSnap!.length.toString());
// for (int i = 0; i < originalQSnap!.docs.length; i++) {
// if (originalQSnap!.docs[i]['name']
// .toString()
// .toLowerCase()
// .contains(searchText.toLowerCase())) {
// qSnap!.add(originalQSnap!.docs[i]);
// }
// }
// print('qSnap.lenght3: ' + qSnap!.length.toString());
setState(() {});
}
}
| 0 |
mirrored_repositories/Olxi/lib | mirrored_repositories/Olxi/lib/Screen/FavPage.dart | // ignore_for_file: prefer_const_constructors
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:google_fonts/google_fonts.dart';
class FavPage extends StatefulWidget {
const FavPage({super.key});
@override
State<FavPage> createState() => _FavPageState();
}
class _FavPageState extends State<FavPage> {
final FirebaseFirestore _firestore = FirebaseFirestore.instance;
String email = FirebaseAuth.instance.currentUser!.email.toString();
@override
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
child: Padding(
padding: EdgeInsets.all(12.sp),
child: StreamBuilder(
stream: _firestore
.collection('favorite')
.doc(email)
.collection('Favproduct')
.snapshots(),
builder:
(BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (!snapshot.hasData) {
return Padding(
padding: EdgeInsets.only(top: 500.h),
child: Center(
child: CircularProgressIndicator(),
),
);
} else if (snapshot.data!.docs.isEmpty) {
return Padding(
padding: EdgeInsets.only(top: 500.h),
child: Center(
child: Text(
"No data Found",
textScaleFactor: 1.sp,
style: GoogleFonts.robotoFlex(
fontWeight: FontWeight.w500,
fontSize: 45,
),
),
),
);
} else {
QuerySnapshot qSnap = snapshot.data!;
return GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
childAspectRatio: .8,
crossAxisCount: 2,
),
physics: NeverScrollableScrollPhysics(),
itemCount: qSnap.docs.length,
shrinkWrap: true,
itemBuilder: (BuildContext context, int index) {
DocumentSnapshot dSnap = qSnap.docs[index];
return GestureDetector(
onTap: () {},
child: Padding(
padding: EdgeInsets.only(
left: 5.w,
right: 5.w,
bottom: 20.h,
),
child: Container(
decoration: BoxDecoration(
border:
Border.all(color: Colors.black45, width: 2.w),
borderRadius: BorderRadius.circular(5.r),
),
child: Center(
child: Column(
children: [
Image.asset("assets/images/logo.jpg"),
Text(dSnap.get('name').toString()),
],
),
),
),
),
);
},
);
}
},
),
),
),
);
}
}
| 0 |
mirrored_repositories/Olxi/lib | mirrored_repositories/Olxi/lib/Screen/Profile.dart | import 'dart:io';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:file_picker/file_picker.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:olxi/CustomWidget/CustomToast.dart';
import 'package:olxi/NavigationPage.dart';
class ProfilePage extends StatefulWidget {
const ProfilePage({super.key});
@override
State<ProfilePage> createState() => _ProfilePageState();
}
class _ProfilePageState extends State<ProfilePage> {
final TextEditingController _currentPasswordController =
TextEditingController();
final TextEditingController _newPasswordController = TextEditingController();
final FirebaseAuth _auth = FirebaseAuth.instance;
PlatformFile? pickedFile;
String imageurl = "";
UploadTask? uploadTask;
final FirebaseFirestore _firestore = FirebaseFirestore.instance;
getImage() {
var doc = _firestore
.collection('users')
.doc(_auth.currentUser!.email)
.snapshots();
return doc;
}
List<Map<String, dynamic>> profileList = [
{
"title": "Change Password",
"icon": Icons.password,
},
{
"title": "Delete Account",
"icon": Icons.edit_attributes,
},
{
"title": "Logout Account",
"icon": Icons.logout_outlined,
},
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: Padding(
padding: EdgeInsets.all(10.sp),
child: SingleChildScrollView(
physics: const NeverScrollableScrollPhysics(),
child: Center(
child: Column(
children: [
SizedBox(
height: 50.h,
),
Stack(
children: [
StreamBuilder(
stream: getImage(),
builder: (context,
AsyncSnapshot<
DocumentSnapshot<Map<String, dynamic>>>
snapshot) {
return Center(
child: snapshot.hasData &&
snapshot.data!.data()!['imageUrl'] != null
? CircleAvatar(
backgroundColor: Colors.grey,
maxRadius: 150.r,
minRadius: 100.r,
backgroundImage: NetworkImage(
snapshot.data!.data()!['imageUrl']))
: CircleAvatar(
maxRadius: 150.r,
minRadius: 100.r,
backgroundColor: Colors.grey,
backgroundImage: const AssetImage(
"assets/images/defaultuserimage.jpg",
),
),
);
}),
Positioned(
right: 50,
top: 0,
bottom: -100,
child: IconButton(
onPressed: () {
_showImageEdit(context);
},
icon: Icon(
Icons.edit,
color: Colors.black,
size: 60.sp,
),
),
)
],
),
SizedBox(
height: 30.h,
),
Text(
_auth.currentUser!.email.toString(),
textScaleFactor: 1.sp,
style: GoogleFonts.radley(
color: Colors.black,
fontSize: 45,
),
),
SizedBox(height: 50.h),
SizedBox(
height: 400.h,
width: 1000.w,
child: ListView.builder(
physics: const NeverScrollableScrollPhysics(),
itemCount: profileList.length,
itemBuilder: (context, index) {
return Column(
children: [
GestureDetector(
onTap: () {
if (index == 0) {
_showChangePassword(context);
} else if (index == 1) {
_auth.currentUser!.delete().then((value) {
Navigator.popUntil(
context, (route) => route.isFirst);
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (ctx) {
return const NavigationPage();
}),
);
}).catchError((e) {
if (kDebugMode) {
print('user delete error: $e');
}
});
} else if (index == 2) {
_auth.signOut().then((value) {
Navigator.popUntil(
context, (route) => route.isFirst);
Navigator.pushReplacement(
// ab password change krna h phn dekh
context,
MaterialPageRoute(builder: (ctx) {
return const NavigationPage();
}),
);
}).catchError((e) {
if (kDebugMode) {
print('user signout error: $e');
}
});
}
},
child: Container(
height: 100.h,
width: 700.w,
decoration: BoxDecoration(
color: Colors.grey,
borderRadius: BorderRadius.circular(30.r),
),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [
Text(profileList[index]["title"]),
Icon(
profileList[index]["icon"],
color: Colors.black,
size: 100.sp,
)
],
),
),
),
SizedBox(
height: 25.h,
),
],
);
},
),
)
],
),
),
),
),
);
}
Future _changePassword(String currentPassword, String newPassword) async {
final user = FirebaseAuth.instance.currentUser;
final cred = EmailAuthProvider.credential(
email: user!.email.toString(), password: currentPassword);
user.reauthenticateWithCredential(cred).then((value) async {
await user.updatePassword(newPassword).then((value) {
Navigator.pop(context);
toast(context, "Password Changed");
_newPasswordController.clear();
_currentPasswordController.clear();
}).catchError((error) {
if (kDebugMode) {
print('error1: $error');
}
});
}).catchError((error) {
if (kDebugMode) {
print('error2: $error');
}
});
}
Future<String?> _showChangePassword(BuildContext context) async {
return showDialog(
context: context,
builder: (ctx) {
return StatefulBuilder(builder: (ctxt, setStat) {
return AlertDialog(
title: Text(
'Change Password',
textScaleFactor: 1.sp,
style: GoogleFonts.roboto(color: Colors.black, fontSize: 40),
),
content: SizedBox(
height: 300.h,
child: Column(
children: [
TextField(
controller: _currentPasswordController,
style: GoogleFonts.roboto(
fontSize: 22.sp,
color: Colors.black,
fontWeight: FontWeight.w600,
),
cursorColor: Colors.black,
textInputAction: TextInputAction.next,
decoration: InputDecoration(
hintText: "Current Password",
hintStyle: GoogleFonts.roboto(
fontSize: 22.sp,
color: Colors.black,
fontWeight: FontWeight.w600,
),
border: OutlineInputBorder(
borderSide: BorderSide(
width: 2.sp,
color: Colors.black,
),
borderRadius: BorderRadius.circular(10.r),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 4.sp,
color: Colors.black,
),
borderRadius: BorderRadius.circular(10.r),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 4.sp,
color: Colors.blueGrey.shade400,
),
borderRadius: BorderRadius.circular(10.r),
),
),
),
SizedBox(height: 20.h),
TextField(
controller: _newPasswordController,
style: GoogleFonts.roboto(
fontSize: 22.sp,
color: Colors.black,
fontWeight: FontWeight.w600,
),
cursorColor: Colors.black,
textInputAction: TextInputAction.next,
decoration: InputDecoration(
hintText: "New Password",
hintStyle: GoogleFonts.roboto(
fontSize: 22.sp,
color: Colors.black,
fontWeight: FontWeight.w600,
),
border: OutlineInputBorder(
borderSide: BorderSide(
width: 2.sp,
color: Colors.black,
),
borderRadius: BorderRadius.circular(10.r),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 4.sp,
color: Colors.black,
),
borderRadius: BorderRadius.circular(10.r),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 4.sp,
color: Colors.blueGrey.shade400,
),
borderRadius: BorderRadius.circular(10.r),
),
),
),
],
),
),
actions: [
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: const Color.fromARGB(255, 47, 63, 71),
),
child: const Text("Cancel"),
onPressed: () {
_newPasswordController.clear();
_currentPasswordController.clear();
Navigator.pop(context);
},
),
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: const Color.fromARGB(255, 47, 63, 71),
),
child: const Text('Confirm Change'),
onPressed: () async {
if (_newPasswordController.text.isEmpty ||
_currentPasswordController.text.isEmpty) {
toast(context, "Input Data to Upload");
} else {
await _changePassword(
_currentPasswordController.text,
_newPasswordController.text,
);
}
},
),
],
);
});
},
);
}
Future<String?> _showImageEdit(BuildContext context) async {
return showDialog(
context: context,
builder: (ctx) {
return StatefulBuilder(builder: (ctxt, setStat) {
return AlertDialog(
title: Text(
'Add Profile Image',
textScaleFactor: 1.sp,
style: GoogleFonts.roboto(color: Colors.black, fontSize: 40),
),
content: SizedBox(
height: 200.h,
child: Column(
children: [
SizedBox(height: 20.h),
Row(
children: [
if (pickedFile != null)
SizedBox(
width: 200.w,
child: Text(
pickedFile!.name,
textScaleFactor: 1.sp,
overflow: TextOverflow.ellipsis,
style: GoogleFonts.roboto(
color: Colors.black,
fontSize: 25,
),
),
)
else
Text(
"No image selected ",
textScaleFactor: 1.sp,
style: GoogleFonts.roboto(
color: Colors.black, fontSize: 25),
),
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor:
const Color.fromARGB(255, 47, 63, 71),
),
onPressed: () async {
await selectFile();
setStat(() {});
},
child: const Text("Select Image"),
),
],
),
SizedBox(height: 20.h),
],
),
),
actions: [
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: const Color.fromARGB(255, 47, 63, 71),
),
child: const Text("Cancel"),
onPressed: () {
pickedFile = null;
Navigator.pop(context);
},
),
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: const Color.fromARGB(255, 47, 63, 71),
),
child: const Text('OK'),
onPressed: () async {
if (pickedFile == null) {
Navigator.pop(context);
toast(context, "Invalid to Upload");
} else {
await uploadFile();
_firestore
.collection('users')
.doc(_auth.currentUser!.email)
.set({
'imageUrl': imageurl,
}, SetOptions(merge: true)).then((value) {
Navigator.pop(context);
toast(context, "Profile Image is Updated");
pickedFile = null;
});
} ////dekh phn dekhb logout kiya ab dekh login krna
//lohin hoga but srceen pr homepage nhi ayygea dekh
},
),
],
);
});
},
);
}
Future selectFile() async {
FilePickerResult? result = await FilePicker.platform.pickFiles();
if (result != null) {
pickedFile = result.files.first;
}
}
Future uploadFile() async {
final path =
'${_auth.currentUser!.email}/profile.${pickedFile?.extension ?? 'jpeg'}';
final file = File(pickedFile?.path ?? '');
final ref = FirebaseStorage.instance.ref().child(path);
uploadTask = ref.putFile(file);
final snapshot = await uploadTask?.whenComplete(() => {});
final urlDownload = await snapshot?.ref.getDownloadURL();
imageurl = urlDownload ?? '';
if (kDebugMode) {
print("downloaded URL: $urlDownload");
}
uploadTask = null;
}
}
| 0 |
mirrored_repositories/Olxi/lib | mirrored_repositories/Olxi/lib/Screen/LoginPage.dart | // ignore_for_file: prefer_const_constructors
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:olxi/CustomWidget/CustomToast.dart';
import 'package:olxi/Screen/ResetPasswordPage.dart';
import 'package:olxi/Screen/SignUpScreen.dart';
class LoginPage extends StatefulWidget {
const LoginPage({super.key});
@override
State<LoginPage> createState() => _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
TextEditingController emailController = TextEditingController();
TextEditingController passwordController = TextEditingController();
bool isLoading = false;
@override
void dispose() {
emailController.dispose();
passwordController.dispose();
super.dispose();
}
bool obscureText = true;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: SafeArea(
child: Padding(
padding: EdgeInsets.only(left: 20.w, right: 20.w),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextField(
controller: emailController,
style: GoogleFonts.roboto(
fontSize: 30.sp,
color: Colors.black,
fontWeight: FontWeight.w600,
),
cursorColor: Colors.black,
textInputAction: TextInputAction.next,
decoration: InputDecoration(
hintText: "Email",
hintStyle: GoogleFonts.roboto(
fontSize: 30.sp,
color: Colors.black,
fontWeight: FontWeight.w600,
),
border: OutlineInputBorder(
borderSide: BorderSide(
width: 2.sp,
color: Colors.black,
),
borderRadius: BorderRadius.circular(10.r),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 4.sp,
color: Colors.black,
),
borderRadius: BorderRadius.circular(10.r),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 4.sp,
color: Colors.blueGrey.shade400,
),
borderRadius: BorderRadius.circular(10.r),
),
),
),
SizedBox(
height: 30.h,
),
TextField(
controller: passwordController,
style: GoogleFonts.roboto(
fontSize: 30.sp,
color: Colors.black,
fontWeight: FontWeight.w600,
),
cursorColor: Colors.black,
obscureText: obscureText,
decoration: InputDecoration(
suffixIcon: GestureDetector(
onTap: () {
setState(() {
obscureText = !obscureText;
});
},
child: Padding(
padding: const EdgeInsets.only(right: 10.0),
child: Icon(
obscureText
? Icons.visibility_off_outlined
: Icons.visibility_outlined,
size: 40.sp,
color: Colors.blueGrey,
),
),
),
hintText: "Password",
hintStyle: GoogleFonts.roboto(
fontSize: 30.sp,
color: Colors.black,
fontWeight: FontWeight.w600,
),
border: OutlineInputBorder(
borderSide: BorderSide(
width: 2.sp,
color: Colors.black,
),
borderRadius: BorderRadius.circular(10.r),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 4.sp,
color: Colors.black,
),
borderRadius: BorderRadius.circular(10.r),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 4.sp,
color: Colors.blueGrey.shade400,
),
borderRadius: BorderRadius.circular(10.r),
),
),
),
SizedBox(
height: 30.h,
),
isLoading
? AlertDialog(
backgroundColor: Colors.blueGrey[400],
content: Row(
children: [
CircularProgressIndicator(
color: Colors.white,
),
Container(
color: Colors.blueGrey[400],
margin: EdgeInsets.only(left: 20.w),
child: Text(
"Loading...",
style: GoogleFonts.roboto(
fontSize: 40.sp,
color: Colors.white,
fontWeight: FontWeight.w800,
),
),
),
],
),
)
: GestureDetector(
onTap: () async {
await login();
},
child: Container(
height: 100.h,
width: 700.h,
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.blueGrey[400],
border: Border.all(
width: 0,
color: Colors.transparent,
),
borderRadius: BorderRadius.circular(10.r),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.2),
blurRadius: 4.r,
offset: Offset(2.w, 7.h),
)
],
),
child: Text(
"Login",
style: GoogleFonts.roboto(
fontSize: 40.sp,
color: Colors.white,
fontWeight: FontWeight.w800,
),
),
),
),
SizedBox(height: 20.h),
GestureDetector(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(builder: (ctx) => ResetPasswordPage()),
);
},
child: Text(
"Reset Password!",
style: GoogleFonts.roboto(
fontSize: 30.sp,
color: Colors.black,
fontWeight: FontWeight.w400,
),
),
),
SizedBox(height: 30.h),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Don't have account?",
style: GoogleFonts.roboto(
fontSize: 30.sp,
color: Colors.black,
fontWeight: FontWeight.w300,
),
),
SizedBox(width: 10.w),
GestureDetector(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(builder: (ctx) => SignUpPage()),
);
},
child: Text(
"SignUp",
style: GoogleFonts.roboto(
fontSize: 30.sp,
color: Colors.black,
fontWeight: FontWeight.w600,
),
),
)
],
)
],
),
),
),
);
}
Future login() async {
if (emailController.text.isEmpty || passwordController.text.isEmpty) {
toast(context, 'All fields required');
} else {
isLoading = true;
setState(() {});
await FirebaseAuth.instance
.signInWithEmailAndPassword(
email: emailController.text.trim(),
password: passwordController.text.trim(),
)
.then((value) {
isLoading = false;
setState(() {});
FirebaseFirestore.instance
.collection("users")
.doc(emailController.text.trim())
.set({
'lastLogin': DateTime.now(),
//DateFormat('yyyy/MM/dd, hh:mm:ss').format(DateTime.now())
});
}).catchError((e) {
isLoading = false;
setState(() {});
if (kDebugMode) {
print(e);
}
toast(context, e.toString());
});
isLoading = false;
setState(() {});
}
}
}
| 0 |
mirrored_repositories/Olxi/lib | mirrored_repositories/Olxi/lib/Screen/ErrorPage.dart | import 'package:flutter/material.dart';
class ErrorPage extends StatefulWidget {
const ErrorPage({super.key});
@override
State<ErrorPage> createState() => _ErrorPageState();
}
class _ErrorPageState extends State<ErrorPage> {
@override
Widget build(BuildContext context) {
return const Scaffold(
body: Center(child: Text("error")),
);
}
}
| 0 |
mirrored_repositories/Olxi/lib | mirrored_repositories/Olxi/lib/Screen/MyAdsPage.dart | // ignore_for_file: prefer_const_constructors
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:olxi/Screen/ProductPage.dart';
class MyAdsPage extends StatefulWidget {
const MyAdsPage({super.key});
@override
State<MyAdsPage> createState() => _MyAdsPageState();
}
class _MyAdsPageState extends State<MyAdsPage> {
final FirebaseFirestore _firestore = FirebaseFirestore.instance;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(children: [
Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: EdgeInsets.only(left: 10.w, top: 20.h),
child: Text(
"My Ads",
textScaleFactor: 1.sp,
style: GoogleFonts.robotoFlex(
fontSize: 40,
fontWeight: FontWeight.w500,
),
),
),
),
SizedBox(height: 20.h),
StreamBuilder(
stream: _firestore.collection('data').snapshots(),
builder:
(BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (!snapshot.hasData) {
return Center(
child: CircularProgressIndicator(),
);
} else {
return GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
childAspectRatio: .7,
crossAxisCount: 2,
),
itemCount: snapshot.data?.docs.length,
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (BuildContext context, int index) {
return Padding(
padding: EdgeInsets.only(
left: 5.w,
right: 5.w,
bottom: 20.h,
),
child: GestureDetector(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (ctx) => ProductPage(
id: snapshot.data!.docs[index].get('id'),
),
),
);
},
child: Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.black45, width: 2.w),
borderRadius: BorderRadius.circular(5.r),
),
child: Center(
child: Stack(
children: [
Column(
children: [
SizedBox(height: 20.h),
Image.network(
snapshot.data!.docs[index]
.get('imageUrl')
.toString(),
fit: BoxFit.cover,
height: 300.h),
Text(
snapshot.data!.docs[index]
.get('name')
.toString()
.toUpperCase(),
overflow: TextOverflow.ellipsis,
textScaleFactor: 1.sp,
style: GoogleFonts.robotoFlex(
fontWeight: FontWeight.w700,
fontSize: 45,
),
),
Text(
"₹ ${snapshot.data!.docs[index].get('productprice').toString()}",
textScaleFactor: 1.sp,
overflow: TextOverflow.ellipsis,
style: GoogleFonts.robotoFlex(
fontSize: 35,
fontWeight: FontWeight.w500,
),
)
],
),
],
),
),
),
),
);
},
);
}
},
),
]),
);
}
}
| 0 |
mirrored_repositories/Olxi/lib | mirrored_repositories/Olxi/lib/Screen/ProductPage.dart | // ignore_for_file: file_names, no_leading_underscores_for_local_identifiers
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:google_fonts/google_fonts.dart';
class ProductPage extends StatefulWidget {
final String id;
const ProductPage({super.key, required this.id});
@override
State<ProductPage> createState() => _ProductPageState();
}
class _ProductPageState extends State<ProductPage> {
int? pageIndex = 0;
@override
Widget build(BuildContext context) {
final FirebaseFirestore _firestore = FirebaseFirestore.instance;
return Scaffold(
appBar: AppBar(
backgroundColor: const Color.fromARGB(179, 105, 104, 104),
),
bottomNavigationBar: Container(
height: 160.h,
width: double.infinity,
decoration: const BoxDecoration(
color: Color.fromARGB(179, 105, 104, 104),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Container(
height: 100.h,
width: 200.h,
decoration: const BoxDecoration(
color: Color.fromARGB(179, 105, 104, 104),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(10),
bottomLeft: Radius.circular(10),
bottomRight: Radius.circular(10),
),
),
child: Center(
child: Text(
"Chat",
textScaleFactor: 1.sp,
style: GoogleFonts.roboto(
fontSize: 50,
color: const Color.fromARGB(255, 47, 63, 71),
),
),
),
),
Container(
height: 100.h,
width: 200.h,
decoration: const BoxDecoration(
color: Color.fromARGB(179, 105, 104, 104),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(10),
bottomLeft: Radius.circular(10),
bottomRight: Radius.circular(10),
),
),
child: Center(
child: Text(
"Call",
textScaleFactor: 1.sp,
style: GoogleFonts.roboto(
fontSize: 50,
color: const Color.fromARGB(255, 47, 63, 71),
),
),
),
),
],
),
),
body: SingleChildScrollView(
child: SafeArea(
child: StreamBuilder(
stream: _firestore.collection('data').snapshots(),
builder:
(BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (!snapshot.hasData) {
return const Center(
child: CircularProgressIndicator(),
);
} else {
return Column(
children: [
SizedBox(height: 20.h),
Center(
child: Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.grey, width: 3.w),
),
child: Image.network(
snapshot.data!.docs
.firstWhere((element) {
return element.id == widget.id;
})
.get('imageUrl')
.toString(),
fit: BoxFit.cover,
height: 600.h,
width: 500.w,
),
),
),
SizedBox(
height: 30.h,
),
Text(
snapshot.data!.docs
.firstWhere((element) {
return element.id == widget.id;
})
.get('name')
.toString()
.toUpperCase(),
textScaleFactor: 1.sp,
style: GoogleFonts.roboto(
fontSize: 90,
color: const Color.fromARGB(255, 47, 63, 71),
),
),
Text(
"₹ ${snapshot.data!.docs.firstWhere((element) {
return element.id == widget.id;
}).get('productprice').toString()}",
textScaleFactor: 1.sp,
style: GoogleFonts.roboto(
fontSize: 50,
color: const Color.fromARGB(255, 47, 63, 71),
),
),
Padding(
padding:
EdgeInsets.only(left: 30.w, right: 30.w, top: 20.h),
child: Text(
"A product description is the marketing copy that explains what a product is and why it's worth purchasing. The purpose of a product description is to supply customers with important information about the features and benefits of the product so they're compelled to buy.",
textScaleFactor: 1.sp,
textAlign: TextAlign.justify,
style: GoogleFonts.roboto(
fontSize: 30,
color: const Color.fromARGB(255, 47, 63, 71),
),
),
),
SizedBox(height: 10.h),
],
);
}
},
),
),
),
);
}
}
| 0 |
mirrored_repositories/Olxi/lib | mirrored_repositories/Olxi/lib/Screen/SignUpScreen.dart | // ignore_for_file: prefer_const_constructors
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:olxi/CustomWidget/CustomToast.dart';
import 'package:olxi/Screen/NavigationBarPage.dart';
class SignUpPage extends StatefulWidget {
const SignUpPage({super.key});
@override
State<SignUpPage> createState() => _SignUpPageState();
}
class _SignUpPageState extends State<SignUpPage> {
TextEditingController nameController = TextEditingController();
TextEditingController emailController = TextEditingController();
TextEditingController passwordController = TextEditingController();
bool isLoading = false;
@override
void dispose() {
emailController.dispose();
passwordController.dispose();
super.dispose();
}
bool obscureText = true;
@override
Widget build(BuildContext context) {
return Scaffold(
extendBodyBehindAppBar: true,
appBar: AppBar(
iconTheme: IconThemeData(color: Colors.black),
backgroundColor: Colors.transparent,
elevation: 0,
),
backgroundColor: Color(0xFFFFFFFF),
body: SingleChildScrollView(
child: Padding(
padding: EdgeInsets.only(top: 200.h, left: 40.w, right: 40.w),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextField(
controller: nameController,
style: GoogleFonts.roboto(
fontSize: 30.sp,
color: Colors.black,
fontWeight: FontWeight.w600,
),
cursorColor: Colors.black,
decoration: InputDecoration(
hintText: "Enter Name",
hintStyle: GoogleFonts.roboto(
fontSize: 30.sp,
color: Colors.black,
fontWeight: FontWeight.w600,
),
border: OutlineInputBorder(
borderSide: BorderSide(
width: 2.sp,
color: Colors.black,
),
borderRadius: BorderRadius.circular(10.r),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 4.sp,
color: Colors.black,
),
borderRadius: BorderRadius.circular(10.r),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 4.sp,
color: Colors.blueGrey.shade400,
),
borderRadius: BorderRadius.circular(10.r),
),
),
),
SizedBox(
height: 30.h,
),
TextField(
controller: emailController,
style: GoogleFonts.roboto(
fontSize: 30.sp,
color: Colors.black,
fontWeight: FontWeight.w600,
),
cursorColor: Colors.black,
decoration: InputDecoration(
hintText: "Enter Email",
hintStyle: GoogleFonts.roboto(
fontSize: 30.sp,
color: Colors.black,
fontWeight: FontWeight.w600,
),
border: OutlineInputBorder(
borderSide: BorderSide(
width: 2.sp,
color: Colors.black,
),
borderRadius: BorderRadius.circular(10.r),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 4.sp,
color: Colors.black,
),
borderRadius: BorderRadius.circular(10.r),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 4.sp,
color: Colors.blueGrey.shade400,
),
borderRadius: BorderRadius.circular(10.r),
),
),
),
SizedBox(
height: 30.h,
),
TextField(
controller: passwordController,
style: GoogleFonts.roboto(
fontSize: 30.sp,
color: Colors.black,
fontWeight: FontWeight.w600,
),
cursorColor: Colors.black,
obscureText: obscureText,
decoration: InputDecoration(
suffixIcon: GestureDetector(
onTap: () {
setState(() {
obscureText = !obscureText;
});
},
child: Padding(
padding: const EdgeInsets.only(right: 10.0),
child: Icon(
obscureText
? Icons.visibility_off_outlined
: Icons.visibility_outlined,
size: 40.sp,
color: Colors.blueGrey,
),
),
),
hintText: "Password",
hintStyle: GoogleFonts.roboto(
fontSize: 30.sp,
color: Colors.black,
fontWeight: FontWeight.w600,
),
border: OutlineInputBorder(
borderSide: BorderSide(
width: 2.sp,
color: Colors.black,
),
borderRadius: BorderRadius.circular(10.r),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 4.sp,
color: Colors.black,
),
borderRadius: BorderRadius.circular(10.r),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 4.sp,
color: Colors.blueGrey.shade400,
),
borderRadius: BorderRadius.circular(10.r),
),
),
),
SizedBox(
height: 30.h,
),
isLoading
? AlertDialog(
content: Row(
children: [
CircularProgressIndicator(),
Container(
margin: EdgeInsets.only(left: 20.w),
child: Text("Loading..."),
),
],
),
)
: GestureDetector(
onTap: () async {
await signup();
},
child: Container(
height: 100.h,
width: 400.h,
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.blueGrey[400],
border: Border.all(
width: 0,
color: Colors.transparent,
),
borderRadius: BorderRadius.circular(10.r),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.2),
blurRadius: 4.r,
offset: Offset(2.w, 7.h),
)
],
),
child: Text(
"SignUp",
style: GoogleFonts.roboto(
fontSize: 40.sp,
color: Colors.white,
fontWeight: FontWeight.w800,
),
),
),
),
],
),
),
),
);
}
Future signup() async {
if (emailController.text.isEmpty ||
passwordController.text.isEmpty ||
nameController.text.isEmpty) {
toast(context, 'All fields required');
} else {
isLoading = true;
setState(() {});
await FirebaseAuth.instance
.createUserWithEmailAndPassword(
email: emailController.text.trim(),
password: passwordController.text.trim(),
)
.then((value) {
isLoading = false;
setState(() {});
FirebaseFirestore.instance
.collection("users")
.doc(emailController.text.trim())
.set({
'lastLogin': DateTime
.now(), //DateFormat('yyyy/MM/dd, hh:mm:ss').format(DateTime.now())
});
Navigator.of(context).push(MaterialPageRoute(
builder: (context) {
return NavigationBarPage();
},
));
}).catchError((e) {
isLoading = false;
setState(() {});
if (kDebugMode) {
print(e);
}
toast(context, e.toString());
});
isLoading = false;
setState(() {});
}
}
}
| 0 |
mirrored_repositories/Olxi/lib | mirrored_repositories/Olxi/lib/Screen/HomeScreen.dart | import 'dart:io';
import 'dart:math';
import 'package:file_picker/file_picker.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:olxi/CustomWidget/CustomToast.dart';
import 'package:olxi/Screen/NavigationBarPage.dart';
import 'package:olxi/Screen/ProductPage.dart';
class HomeSrceen extends StatefulWidget {
const HomeSrceen({super.key});
@override
State<HomeSrceen> createState() => _HomeSrceenState();
}
class _HomeSrceenState extends State<HomeSrceen> {
final _productNameController = TextEditingController();
final _productPriceController = TextEditingController();
final FirebaseFirestore _firestore = FirebaseFirestore.instance;
String email = FirebaseAuth.instance.currentUser!.email.toString();
String imageurl = "";
double? latitude;
double? longitude;
PlatformFile? pickedFile;
UploadTask? uploadTask;
List<Map<String, dynamic>> browsCategories = [
{
"name": "OLXI ATUOS(CARS)",
"icon": Icons.car_rental,
},
{
"name": "PROPERTIES",
"icon": Icons.house_rounded,
},
{
"name": "MOBILES",
"icon": Icons.phone_iphone_rounded,
},
{
"name": "JOBS",
"icon": Icons.work,
},
{
"name": "BIKES",
"icon": Icons.bike_scooter_rounded,
},
{
"name": "ELECTONICS &\n APPLIANCES",
"icon": Icons.tv_rounded,
},
{
"name": " COMMERICAL\nVEHICLES & SPARES",
"icon": Icons.spa,
},
{
"name": "FURNITURE",
"icon": Icons.chair_rounded,
},
{
"name": "FASHION",
"icon": Icons.car_crash,
},
{
"name": "BOOKS,SPORTS &\n HOBBIES",
"icon": Icons.book_rounded,
},
{
"name": "PETS",
"icon": Icons.pets,
},
{
"name": "SERVICES",
"icon": Icons.design_services_rounded,
},
];
String? id;
String name = 'OLXI';
bool isError = false;
@override
void initState() {
_getMaxId();
_loadData();
super.initState();
}
@override
void dispose() {
_productNameController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
double screenWitdh = MediaQuery.of(context).size.width;
return Scaffold(
floatingActionButton: isError
? const Text("somethhing went wrong")
: id == null
? const CircularProgressIndicator()
: FloatingActionButton(
onPressed: () {
_showTextInputDialog(context);
},
backgroundColor: const Color.fromARGB(255, 47, 63, 71),
child: const Icon(Icons.add),
),
body: SingleChildScrollView(
child: Column(
children: [
Container(
color: const Color.fromARGB(179, 105, 104, 104),
child: Column(
children: [
Padding(
padding: const EdgeInsets.only(top: 10.0, left: 10),
child: Row(
children: [
const Icon(Icons.location_on_rounded),
SizedBox(
width: 10.w,
),
const Text(
"Sehatpur, Faridabad",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16,
),
),
const Icon(
Icons.arrow_drop_down,
size: 30,
),
],
),
),
SizedBox(height: 10.h),
Padding(
padding: const EdgeInsets.only(left: 10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
GestureDetector(
onTap: () {
Navigator.popUntil(
context, (route) => route.isFirst);
Navigator.of(context)
.pushReplacement(MaterialPageRoute(
builder: (ctx) => const NavigationBarPage(
initialIndex: 1,
)));
},
behavior: HitTestBehavior.translucent,
child: Container(
height: 60.h,
width: screenWitdh - 80,
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color: Colors.black),
borderRadius: BorderRadius.circular(5)),
child: Padding(
padding: const EdgeInsets.only(left: 10.0),
child: Row(
children: [
const Icon(Icons.search),
SizedBox(width: 10.w),
Center(
child: Text(
"Find Cars, Mobile Phones and mo...",
textScaleFactor: 1.sp,
style: const TextStyle(fontSize: 25),
),
),
],
),
)),
),
SizedBox(width: 20.w),
IconButton(
onPressed: () {},
icon: const Icon(Icons.notifications_sharp),
),
],
),
),
SizedBox(height: 10.h),
],
),
),
Padding(
padding: const EdgeInsets.all(10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Browse categories",
textScaleFactor: 1.sp,
style: const TextStyle(
fontSize: 40, fontWeight: FontWeight.w500),
),
Text(
"See all",
textScaleFactor: 1.sp,
style: const TextStyle(
shadows: [
Shadow(color: Colors.black, offset: Offset(0, -2))
],
color: Colors.transparent,
fontWeight: FontWeight.w500,
fontSize: 40,
decoration: TextDecoration.underline,
decorationColor: Colors.black,
decorationThickness: 3,
),
),
],
),
),
SizedBox(
height: 10.h,
),
SizedBox(
height: 220.h,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: browsCategories.length,
itemBuilder: (cxt, index) {
return Padding(
padding: const EdgeInsets.only(left: 20.0, right: 30),
child: SizedBox(
child: Column(
children: [
Icon(
browsCategories[index]["icon"],
size: 100.sp,
color: const Color.fromARGB(255, 47, 63, 71),
),
SizedBox(height: 15.h),
Text(
browsCategories[index]["name"],
),
],
),
),
);
},
),
),
Divider(
color: Colors.black45,
thickness: 8.sp,
),
Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: EdgeInsets.only(left: 10.w, top: 20.h),
child: Text(
"Fresh Recommendations",
textScaleFactor: 1.sp,
style: const TextStyle(
fontSize: 40,
fontWeight: FontWeight.w500,
),
),
),
),
SizedBox(height: 20.h),
FutureBuilder(
future: _firestore.collection('data').get(),
builder: (context,
AsyncSnapshot<QuerySnapshot<Map<String, dynamic>>> snapshot) {
if (!snapshot.hasData) {
return Padding(
padding: EdgeInsets.only(top: 150.h),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
Text('Loading data.. '),
CircularProgressIndicator(),
],
),
);
} else if (snapshot.data!.docs.isEmpty) {
return Center(
child: Text(
"No data Found",
textScaleFactor: 1.sp,
style: GoogleFonts.robotoFlex(
fontWeight: FontWeight.w500,
fontSize: 45,
),
),
);
} else {
return FutureBuilder(
future: _firestore.collection('data').get(),
// sortByLocation(snapshot.data!.docs),
builder: (context, AsyncSnapshot ss) {
if (!ss.hasData) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
Text('Loading data.. '),
CircularProgressIndicator(),
],
);
}
// else if (!ss.hasData &&
// ss.connectionState == ConnectionState.done) {
// return const Text('Data could not be sorted');
// }
else {
var sortedList = ss.data!;
return GridView.builder(
gridDelegate:
const SliverGridDelegateWithFixedCrossAxisCount(
childAspectRatio: .7,
crossAxisCount: 2,
),
itemCount: snapshot.data!.docs.length,
// sortedList.length,
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (ctx, index) {
return Padding(
padding: EdgeInsets.only(
left: 5.w,
right: 5.w,
bottom: 20.h,
),
child: GestureDetector(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (ctx) => ProductPage(
id: snapshot.data!.docs[index]
.data()['id'],
),
),
);
},
child: Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.black45, width: 2.w),
borderRadius: BorderRadius.circular(5.r),
),
child: Center(
child: Stack(
children: [
Column(
children: [
SizedBox(height: 20.h),
Image.network(
snapshot.data!.docs[index]
.get('imageUrl')
.toString(),
fit: BoxFit.cover,
height: 300.h),
SizedBox(height: 10.h),
Text(
snapshot.data!.docs[index]
.get('name')
.toString()
.toUpperCase(),
overflow: TextOverflow.ellipsis,
textScaleFactor: 1.sp,
style: GoogleFonts.robotoFlex(
fontWeight: FontWeight.w700,
fontSize: 45,
),
),
SizedBox(height: 10.h),
Text(
"₹ ${snapshot.data!.docs[index].get('productprice').toString()}",
textScaleFactor: 1.sp,
overflow: TextOverflow.ellipsis,
style: GoogleFonts.robotoFlex(
fontSize: 35,
fontWeight: FontWeight.w500,
),
)
],
),
// StreamBuilder(
// stream: _firestore
// .collection('favorite')
// .doc(email)
// .collection('Favproduct')
// .snapshots(),
// builder: (context,
// AsyncSnapshot<QuerySnapshot> ss) {
// return IconButton(
// onPressed: () {
// if (snapshot
// .data!.docs[index].exists) {
// _firestore
// .collection('favorite')
// .doc(email)
// .collection('Favproduct')
// .doc(snapshot
// .data!.docs[index].id)
// .delete();
// } else {
// _firestore
// .collection('favorite')
// .doc(email)
// .collection('Favproduct')
// .doc(snapshot
// .data!.docs[index].id)
// .set({
// 'name': snapshot
// .data!.docs[index]
// .get('name'),
// 'id': snapshot
// .data!.docs[index]
// .get('id'),
// });
// }
// setState(() {});
// },
// icon: ss.hasData &&
// ss.data!.docs[index].exists
// ? Icon(Icons.favorite)
// : Icon(Icons.favorite_border),
// );
// },),
],
),
),
),
),
);
},
);
}
});
}
},
),
],
),
),
);
}
Future<Position> _determinePosition() async {
bool serviceEnabled;
LocationPermission permission;
// Test if location services are enabled.
serviceEnabled = await Geolocator.isLocationServiceEnabled();
if (!serviceEnabled) {
// Location services are not enabled don't continue
// accessing the position and request users of the
// App to enable the location services.
return Future.error('Location services are disabled.');
}
permission = await Geolocator.checkPermission();
if (permission == LocationPermission.denied) {
permission = await Geolocator.requestPermission();
if (permission == LocationPermission.denied) {
// Permissions are denied, next time you could try
// requesting permissions again (this is also where
// Android's shouldShowRequestPermissionRationale
// returned true. According to Android guidelines
// your App should show an explanatory UI now.
return Future.error('Location permissions are denied');
}
}
if (permission == LocationPermission.deniedForever) {
// Permissions are denied forever, handle appropriately.
return Future.error(
'Location permissions are permanently denied, we cannot request permissions.');
}
// When we reach here, permissions are granted and we can
// continue accessing the position of the device.
return await Geolocator.getCurrentPosition();
}
_loadData() {}
Future selectFile() async {
FilePickerResult? result = await FilePicker.platform.pickFiles();
if (result != null) {
pickedFile = result.files.first;
}
}
Future uploadFile() async {
final path = 'files/${pickedFile?.name ?? ''}';
final file = File(pickedFile?.path ?? '');
final ref = FirebaseStorage.instance.ref().child(path);
uploadTask = ref.putFile(file);
final snapshot = await uploadTask?.whenComplete(() => {});
final urlDownload = await snapshot?.ref.getDownloadURL();
imageurl = urlDownload ?? '';
if (kDebugMode) {
print("downloaded URL: $urlDownload");
}
uploadTask = null;
}
Future<String?> _showTextInputDialog(BuildContext context) async {
return showDialog(
context: context,
builder: (ctx) {
// bool isUploading = false;
return StatefulBuilder(builder: (ctxt, setStat) {
return SingleChildScrollView(
child: AlertDialog(
title: Text(
'Add Product For Sale',
textScaleFactor: 1.sp,
style: GoogleFonts.roboto(color: Colors.black, fontSize: 40),
),
content: SizedBox(
height: 500.h,
child: Column(
children: [
TextField(
controller: _productNameController,
style: GoogleFonts.roboto(
fontSize: 30.sp,
color: Colors.black,
fontWeight: FontWeight.w600,
),
cursorColor: Colors.black,
textInputAction: TextInputAction.next,
decoration: InputDecoration(
hintText: "Product Name",
hintStyle: GoogleFonts.roboto(
fontSize: 30.sp,
color: Colors.black,
fontWeight: FontWeight.w600,
),
border: OutlineInputBorder(
borderSide: BorderSide(
width: 2.sp,
color: Colors.black,
),
borderRadius: BorderRadius.circular(10.r),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 4.sp,
color: Colors.black,
),
borderRadius: BorderRadius.circular(10.r),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 4.sp,
color: Colors.blueGrey.shade400,
),
borderRadius: BorderRadius.circular(10.r),
),
),
),
SizedBox(height: 20.h),
TextField(
controller: _productPriceController,
style: GoogleFonts.roboto(
fontSize: 30.sp,
color: Colors.black,
fontWeight: FontWeight.w600,
),
cursorColor: Colors.black,
textInputAction: TextInputAction.next,
decoration: InputDecoration(
hintText: "Product Price",
hintStyle: GoogleFonts.roboto(
fontSize: 30.sp,
color: Colors.black,
fontWeight: FontWeight.w600,
),
border: OutlineInputBorder(
borderSide: BorderSide(
width: 2.sp,
color: Colors.black,
),
borderRadius: BorderRadius.circular(10.r),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 4.sp,
color: Colors.black,
),
borderRadius: BorderRadius.circular(10.r),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 4.sp,
color: Colors.blueGrey.shade400,
),
borderRadius: BorderRadius.circular(10.r),
),
),
),
SizedBox(height: 20.h),
Row(
children: [
if (pickedFile != null)
SizedBox(
width: 200.w,
child: Text(
pickedFile!.name,
textScaleFactor: 1.sp,
overflow: TextOverflow.ellipsis,
style: GoogleFonts.roboto(
color: Colors.black,
fontSize: 25,
),
),
)
else
Text(
"No image selected ",
textScaleFactor: 1.sp,
style: GoogleFonts.roboto(
color: Colors.black, fontSize: 25),
),
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor:
const Color.fromARGB(255, 47, 63, 71),
),
onPressed: () async {
await selectFile();
setStat(() {});
},
child: const Text("Select Image"),
),
],
),
SizedBox(height: 20.h),
// isUploading ? uploadProgress() : Center()
],
),
),
actions: [
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: const Color.fromARGB(255, 47, 63, 71),
),
child: const Text("Cancel"),
onPressed: () {
_productNameController.clear();
_productPriceController.clear();
pickedFile = null;
Navigator.pop(context);
},
),
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: const Color.fromARGB(255, 47, 63, 71),
),
child: const Text('OK'),
onPressed: () async {
if (_productNameController.text.isEmpty ||
_productPriceController.text.isEmpty ||
pickedFile == null) {
Navigator.pop(context);
toast(context, "Input Data to Upload");
} else {
await _determinePosition().then(
(position) {
if (kDebugMode) {
latitude = position.latitude;
longitude = position.longitude;
print("Geo Latitude: $latitude");
print("Geo Latitude: $longitude");
}
},
);
await uploadFile();
_firestore.collection('data').doc(id).set({
'name': _productNameController.text,
'productprice': _productPriceController.text,
'id': id,
'imageUrl': imageurl,
'latitude': latitude,
'longitude': longitude,
}).then((value) {
id = (int.parse(id!) + 1).toString();
_productNameController.clear();
_productPriceController.clear();
pickedFile = null;
Navigator.pop(context);
});
}
},
),
],
),
);
});
},
);
}
Future<List<DocumentSnapshot<Map<String, dynamic>>>> sortByLocation(
var list) async {
var tempList = list;
double? lat, lon;
await _determinePosition().then(
(value) {
if (kDebugMode) {
lat = value.latitude;
lon = value.longitude;
print("Geo Latitude: $lat");
print("Geo Latitude: $lon");
}
},
);
if (tempList.length > 1) {
for (var doc in tempList) {
int index = tempList.indexOf(doc);
double distanceFromIndex = calculateDistance(
lat!, lon!, doc.data()['latitude'], doc.data()['longitude']);
double distanceFromNextIndex = calculateDistance(
lat!,
lon!,
tempList[index + 1].data()['latitude'],
tempList[index + 1].data()['longitude'],
);
if (distanceFromIndex > distanceFromNextIndex) {
tempList.insert(index + 1, list.removeAt(index));
}
}
}
return tempList;
}
double calculateDistance(double lat1, double lon1, double lat2, double lon2) {
var p = 0.017453292519943295;
var a = 0.5 -
cos((lat2 - lat1) * p) / 2 +
cos(lat1 * p) * cos(lat2 * p) * (1 - cos((lon2 - lon1) * p)) / 2;
return 12742 * asin(sqrt(a));
}
_getMaxId() async {
int max = 0;
await _firestore.collection('data').get().then((snapshot) {
snapshot.docs;
for (int i = 0; i < snapshot.docs.length - 1; i++) {
if (int.parse(snapshot.docs[i].get('id')) <
int.parse(snapshot.docs[i + 1].get('id'))) {
max = int.parse(snapshot.docs[i + 1].get('id'));
}
}
}).catchError((e) {
isError = true;
setState(() {});
});
if (kDebugMode) {
print('max id in firestore: $max');
}
id = '${max + 1}';
setState(() {});
}
}
| 0 |
mirrored_repositories/Olxi/lib | mirrored_repositories/Olxi/lib/Screen/NavigationBarPage.dart | import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:olxi/Screen/FavPage.dart';
import 'package:olxi/Screen/HomeScreen.dart';
import 'package:olxi/Screen/Profile.dart';
import 'package:olxi/Screen/SearchScreen.dart';
class NavigationBarPage extends StatefulWidget {
final int initialIndex;
const NavigationBarPage({super.key, this.initialIndex = 0});
@override
State<NavigationBarPage> createState() => _NavigationBarPageState();
}
class _NavigationBarPageState extends State<NavigationBarPage> {
int pageIndex = 0;
final pages = [
const HomeSrceen(),
const SearchScreen(),
const FavPage(),
const ProfilePage(),
];
@override
void initState() {
pageIndex = widget.initialIndex;
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: const Color.fromARGB(179, 105, 104, 104),
),
// drawer: SafeArea(
// child: Drawer(
// child: ListView(
// children: [
// DrawerHeader(
// decoration: BoxDecoration(
// color: Color.fromARGB(179, 105, 104, 104),
// ),
// child:
// Text(FirebaseAuth.instance.currentUser!.email.toString()),
// ),
// ListTile(
// title: Text('SignOut'),
// ),
// ],
// ),
// ),
// ),
body: pages[pageIndex],
bottomNavigationBar: Container(
height: 160.h,
width: double.infinity,
decoration: const BoxDecoration(
color: Color.fromARGB(179, 105, 104, 104),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
IconButton(
enableFeedback: false,
onPressed: () {
setState(() {
pageIndex = 0;
});
},
icon: pageIndex == 0
? const Icon(
Icons.home_filled,
color: Colors.white,
size: 35,
)
: const Icon(
Icons.home_outlined,
color: Colors.black,
size: 35,
),
),
IconButton(
enableFeedback: false,
onPressed: () {
setState(() {
pageIndex = 1;
});
},
icon: pageIndex == 1
? const Icon(
Icons.search,
color: Colors.white,
size: 35,
)
: const Icon(
Icons.search,
color: Colors.black,
size: 35,
),
),
IconButton(
enableFeedback: false,
onPressed: () {
setState(() {
pageIndex = 2;
});
},
icon: pageIndex == 2
? const Icon(
Icons.favorite,
color: Colors.white,
size: 35,
)
: const Icon(
Icons.favorite_border_outlined,
color: Colors.black,
size: 35,
),
),
IconButton(
enableFeedback: false,
onPressed: () {
setState(() {
pageIndex = 3;
});
},
icon: pageIndex == 3
? const Icon(
Icons.person,
color: Colors.white,
size: 35,
)
: const Icon(
Icons.person_outlined,
color: Colors.black,
size: 35,
),
),
],
),
),
);
}
}
| 0 |
mirrored_repositories/Olxi/lib | mirrored_repositories/Olxi/lib/Screen/ResetPasswordPage.dart | import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:olxi/CustomWidget/CustomToast.dart';
import 'package:olxi/Screen/NavigationBarPage.dart';
class ResetPasswordPage extends StatefulWidget {
const ResetPasswordPage({super.key});
@override
State<ResetPasswordPage> createState() => _ResetPasswordPageState();
}
class _ResetPasswordPageState extends State<ResetPasswordPage> {
TextEditingController emailController = TextEditingController();
bool isLoading = false;
@override
void dispose() {
emailController.dispose();
super.dispose();
}
bool obscureText = true;
@override
Widget build(BuildContext context) {
return Scaffold(
extendBodyBehindAppBar: true,
appBar: AppBar(
iconTheme: const IconThemeData(color: Colors.black),
backgroundColor: Colors.transparent,
elevation: 0,
),
backgroundColor: const Color(0xFFFFFFFF),
body: Padding(
padding: EdgeInsets.only(left: 20.w, right: 20.w),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
height: 30.h,
),
TextField(
controller: emailController,
style: GoogleFonts.roboto(
fontSize: 30.sp,
color: Colors.black,
fontWeight: FontWeight.w600,
),
cursorColor: Colors.black,
decoration: InputDecoration(
hintText: "Enter Email",
hintStyle: GoogleFonts.roboto(
fontSize: 30.sp,
color: Colors.black,
fontWeight: FontWeight.w600,
),
border: OutlineInputBorder(
borderSide: BorderSide(
width: 2.sp,
color: Colors.black,
),
borderRadius: BorderRadius.circular(10.r),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 4.sp,
color: Colors.black,
),
borderRadius: BorderRadius.circular(10.r),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 4.sp,
color: Colors.blueGrey.shade400,
),
borderRadius: BorderRadius.circular(10.r),
),
),
),
SizedBox(
height: 30.h,
),
isLoading
? AlertDialog(
content: Row(
children: [
const CircularProgressIndicator(),
Container(
margin: EdgeInsets.only(left: 20.w),
child: const Text("Loading..."),
),
],
),
)
: GestureDetector(
onTap: () async {
await signup();
},
child: Container(
height: 100.h,
width: 700.h,
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.blueGrey[400],
border: Border.all(
width: 0,
color: Colors.transparent,
),
borderRadius: BorderRadius.circular(10.r),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.2),
blurRadius: 4.r,
offset: Offset(2.w, 7.h),
)
],
),
child: Text(
"Reset Password",
style: GoogleFonts.roboto(
fontSize: 30.sp,
color: Colors.white,
fontWeight: FontWeight.w500,
),
),
),
),
],
),
),
);
}
Future signup() async {
if (emailController.text.isEmpty) {
toast(context, 'All fields required');
} else {
isLoading = true;
setState(() {});
await FirebaseAuth.instance
.sendPasswordResetEmail(email: emailController.text.trim())
.then((value) {
isLoading = false;
setState(() {});
Navigator.of(context).pop();
toast(context, "Link sended to your Mail");
}).catchError((e) {
isLoading = false;
setState(() {});
if (kDebugMode) {
print(e);
}
toast(context, e.toString());
});
isLoading = false;
setState(() {});
}
}
}
| 0 |
mirrored_repositories/Olxi/lib | mirrored_repositories/Olxi/lib/CustomWidget/CustomToast.dart | import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:google_fonts/google_fonts.dart';
toast(BuildContext context, String text) {
ScaffoldMessenger.of(context).clearSnackBars();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
width: double.infinity,
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.r),
),
backgroundColor: const Color.fromARGB(255, 47, 63, 71),
content: SizedBox(
height: 75.h,
child: Center(
child: Text(
text,
textScaleFactor: 1.sp,
style: GoogleFonts.raleway(
fontSize: 25,
fontWeight: FontWeight.w500,
color: Colors.white,
),
overflow: TextOverflow.visible,
),
),
),
),
);
}
| 0 |
mirrored_repositories/Olxi | mirrored_repositories/Olxi/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:olxi/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-real-estate | mirrored_repositories/Flutter-real-estate/lib/main.dart | import 'package:flutter/material.dart';
import 'package:flutter_real_estate/ui/components/bottom_app_bar.dart';
import 'package:flutter_real_estate/ui/components/strings.dart';
import 'package:flutter_real_estate/ui/components/top_app_bar.dart';
import 'package:flutter_real_estate/ui/screens/about_screen.dart';
import 'package:flutter_real_estate/ui/screens/overview_screen.dart';
import 'package:flutter_real_estate/ui/theme/colors.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:sizer/sizer.dart';
import 'application/selected_index_provider.dart';
void main() {
runApp(const ProviderScope(child: MyApp()));
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, constraints) {
return OrientationBuilder(
builder: (context, orientation) {
SizerUtil.setScreenSize(constraints, orientation);
return MaterialApp(
theme: ThemeData(
fontFamily: 'GothamSSm',
scaffoldBackgroundColor: AppColors.lightGray,
),
home: HomePage(),
);
},
);
},
);
}
}
class HomePage extends ConsumerWidget {
final List<Widget> screens = [OverviewScreen(), AboutScreen()];
@override
Widget build(BuildContext context, WidgetRef ref) {
// Which widget to show on screen
final selectedIndex = ref.watch(selectedIndexProvider);
return Scaffold(
appBar: TopAppBar(title: Strings.appBarTitles[selectedIndex]),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: screens.elementAt(selectedIndex),
),
],
),
),
bottomNavigationBar: BottomAppBarMenu());
}
}
| 0 |
mirrored_repositories/Flutter-real-estate/lib | mirrored_repositories/Flutter-real-estate/lib/application/selected_index_provider.dart | import 'package:flutter_riverpod/flutter_riverpod.dart';
// Keeps track of the page to show
final selectedIndexProvider = StateProvider<int>((ref) => 0);
| 0 |
mirrored_repositories/Flutter-real-estate/lib | mirrored_repositories/Flutter-real-estate/lib/application/location_permissions_provider.dart | import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:geolocator/geolocator.dart';
final locationPermissionProvider = FutureProvider<bool>((ref) async {
bool serviceEnabled;
LocationPermission permission;
// Check if location services are enabled
serviceEnabled = await Geolocator.isLocationServiceEnabled();
if (!serviceEnabled) {
return false;
}
// Check if location permission denied forever
permission = await Geolocator.checkPermission();
if (permission == LocationPermission.deniedForever) {
return false;
}
switch (permission) {
case LocationPermission.denied:
var retry = await Geolocator.requestPermission();
if (retry == LocationPermission.whileInUse || retry == LocationPermission.always) {
return true;
}
case LocationPermission.deniedForever:
return false;
case LocationPermission.whileInUse:
return true;
case LocationPermission.always:
return true;
case LocationPermission.unableToDetermine:
return false;
}
return false;
});
| 0 |
mirrored_repositories/Flutter-real-estate/lib | mirrored_repositories/Flutter-real-estate/lib/application/selected_sort_provider.dart | import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../models/sort_model.dart';
// Provider to keep track of the selected sorting type and order
final selectedSortProvider = StateProvider<SortProviderModel>((ref) => SortProviderModel(id: 0, oder: Order.asc)); | 0 |
mirrored_repositories/Flutter-real-estate/lib | mirrored_repositories/Flutter-real-estate/lib/application/list_houses_provider.dart | import 'dart:convert' show json;
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:http/http.dart' as http;
import '../data/api_exception.dart';
import '../models/house_model.dart';
import '../utils/constants.dart';
import '../utils/helper.dart';
// Provider to make the API call and return the result in a list
final listHousesProvider = FutureProvider<List<HouseData>>((ref) async {
final client = http.Client();
final uri = Uri.parse(Constants.houseAPIUrl);
// Use the API key passed via --dart-define,
const apiKey = {
'Access-Key': String.fromEnvironment(
'API_KEY',
)
};
final response = await client.get(uri, headers: apiKey);
final List<HouseData> houseList = [];
switch (response.statusCode) {
case 200:
final data = json.decode(response.body);
// Map all houses to the data class and calculate the distance
for (var houseData in data) {
int latitude = houseData['latitude'];
int longitude = houseData['longitude'];
double distance = await Helper.calculateDistance(latitude.toDouble(), longitude.toDouble());
// Result from the JSON
final house = HouseData.fromJson(houseData);
// Add the distance to a new
final houseWithDistance = HouseData(
id: house.id,
price: house.price,
image: house.image,
zip: house.zip,
bathrooms: house.bathrooms,
bedrooms: house.bedrooms,
size: house.size,
city: house.city,
description: house.description,
latitude: house.latitude,
longitude: house.longitude,
distance: double.parse(distance.toStringAsFixed(1)));
houseList.add(houseWithDistance);
}
case 401:
throw InvalidApiKeyException();
case 404:
throw NotFoundException();
default:
throw UnknownException();
}
return houseList;
});
| 0 |
mirrored_repositories/Flutter-real-estate/lib | mirrored_repositories/Flutter-real-estate/lib/application/text_searchbar_provider.dart | import 'package:flutter_riverpod/flutter_riverpod.dart';
// Provider to store the value of the search bar
final textSearchBarProvider = StateProvider<String>((ref) => '');
| 0 |
mirrored_repositories/Flutter-real-estate/lib | mirrored_repositories/Flutter-real-estate/lib/models/house_model.dart | // Data class used to map the JSON from the `list_houses_provider`
class HouseData {
final int id;
final int price;
final String image;
final String zip;
final int bathrooms;
final int bedrooms;
final int size;
final String city;
final String description;
final int latitude;
final int longitude;
final double distance;
HouseData({
required this.id,
required this.price,
required this.image,
required this.zip,
required this.bathrooms,
required this.bedrooms,
required this.size,
required this.city,
required this.description,
required this.latitude,
required this.longitude,
required this.distance,
});
factory HouseData.fromJson(Map<String, dynamic> json) {
return HouseData(
id: json['id'],
price: json['price'],
image: json['image'],
zip: json['zip'],
bathrooms: json['bathrooms'],
bedrooms: json['bedrooms'],
size: json['size'],
city: json['city'],
description: json['description'],
latitude: json['latitude'],
longitude: json['longitude'],
distance: 0.0
);
}
}
| 0 |
mirrored_repositories/Flutter-real-estate/lib | mirrored_repositories/Flutter-real-estate/lib/models/sort_model.dart | enum Order { asc, desc }
// Class to keep track of the sorting type and order in the overview page
class SortProviderModel {
late final int id;
final Order oder;
SortProviderModel({required this.id, required this.oder});
}
| 0 |
mirrored_repositories/Flutter-real-estate/lib | mirrored_repositories/Flutter-real-estate/lib/data/api_exception.dart | // Exceptions for the API call
sealed class APIException implements Exception {
APIException(this.message);
final String message;
}
class InvalidApiKeyException extends APIException {
InvalidApiKeyException() : super('Invalid API key');
}
class NoInternetConnectionException extends APIException {
NoInternetConnectionException() : super('No Internet connection');
}
class NotFoundException extends APIException {
NotFoundException() : super('City not found');
}
class UnknownException extends APIException {
UnknownException() : super('Some error occurred');
} | 0 |
mirrored_repositories/Flutter-real-estate/lib | mirrored_repositories/Flutter-real-estate/lib/utils/constants.dart | class Constants {
static const dttHomeUrl = 'https://d-tt.nl';
static const baseAPIUrl = 'https://intern.d-tt.nl';
static const houseAPIUrl = '$baseAPIUrl/api/house';
static const githubUrl = 'https://github.com/Krakert';
static const linkedinUrl = 'https://www.linkedin.com/in/stefan-de-kraker/';
} | 0 |
mirrored_repositories/Flutter-real-estate/lib | mirrored_repositories/Flutter-real-estate/lib/utils/helper.dart | import 'dart:math';
import 'package:geolocator/geolocator.dart';
class Helper {
static Position? currentLocation;
static Future<double> calculateDistance(double houseLatitude, double houseLongitude) async {
// Get the current location if permission is allowed
if (currentLocation == null) {
LocationPermission permission = await Geolocator.checkPermission();
if (permission == LocationPermission.always || permission == LocationPermission.whileInUse) {
currentLocation =
await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
}
}
// Return 0 if current location is still not found
if (currentLocation == null) return 0;
// Extract latitude and longitude values
double lat1 = currentLocation!.latitude;
double lon1 = currentLocation!.longitude;
double lat2 = houseLatitude;
double lon2 = houseLongitude;
// Radius of the Earth in kilometers
const double earthRadius = 6371;
// Calculate the differences in latitude and longitude in radians
double dLat = _toRadians(lat2 - lat1);
double dLon = _toRadians(lon2 - lon1);
// Use the Haversine formula to calculate the distance
double a = sin(dLat / 2) * sin(dLat / 2) +
cos(_toRadians(lat1)) * cos(_toRadians(lat2)) * sin(dLon / 2) * sin(dLon / 2);
double c = 2 * atan2(sqrt(a), sqrt(1 - a));
// Calculate the distance in kilometers
double distance = earthRadius * c;
return distance;
}
static double _toRadians(double degree) {
return degree * pi / 180;
}
}
| 0 |
mirrored_repositories/Flutter-real-estate/lib/ui | mirrored_repositories/Flutter-real-estate/lib/ui/components/filter_card.dart | import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../application/selected_sort_provider.dart';
import '../../models/sort_model.dart';
import '../theme/colors.dart';
import '../theme/type.dart';
class FilterCard extends ConsumerWidget {
const FilterCard({required this.text, required this.cardId, required this.selectedId});
final String text;
final int cardId;
final int selectedId;
@override
Widget build(BuildContext context, WidgetRef ref) {
final selectedState = ref.watch(selectedSortProvider);
return GestureDetector(
onTap: () {
// Change the order type
if (selectedId == cardId) {
ref.read(selectedSortProvider.notifier).update((state) =>
SortProviderModel(
id: cardId, oder: state.oder == Order.asc ? Order.desc : Order.asc));
} else {
ref.read(selectedSortProvider.notifier).update((state) =>
SortProviderModel(id: cardId, oder: Order.asc));
}
},
child: Padding(
padding: const EdgeInsets.fromLTRB(5, 2, 5, 2),
child: Container(
decoration: BoxDecoration(
color: AppColors.white,
border: Border.all(
width: 2, color: cardId == selectedId ? AppColors.dttRed : AppColors.medium),
borderRadius: BorderRadius.circular(40),
),
padding: EdgeInsets.fromLTRB(10, 2, 10, 2),
child: Row(
children: [
Visibility(
visible: selectedId == cardId,
child: Icon(
// Show different Icon base on the Order type
selectedState.oder == Order.desc ? Icons.arrow_downward : Icons.arrow_upward,
color: AppColors.medium,
)),
Center(
child: Text(text,
style: AppTypography.hint.copyWith(
color: cardId == selectedId ? AppColors.dttRed : AppColors.medium))),
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/Flutter-real-estate/lib/ui | mirrored_repositories/Flutter-real-estate/lib/ui/components/top_app_bar.dart | import 'package:flutter/material.dart';
import 'package:flutter_real_estate/ui/theme/type.dart';
import 'package:sizer/sizer.dart';
class TopAppBar extends StatelessWidget implements PreferredSizeWidget {
const TopAppBar({required this.title});
final String title;
@override
Widget build(BuildContext context) {
return (AppBar(
backgroundColor: Colors.transparent,
// Set the background color to transparent
elevation: 0.0,
// Set elevation to 0.0 to remove the shadow
bottomOpacity: 0.0,
flexibleSpace: Container(
margin: EdgeInsets.only(left: 4.5.w, top: 5.h),
child: Align(
alignment: Alignment.centerLeft,
child: Text(
title,
style: AppTypography.title01
),
),
),
));
}
@override
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
} | 0 |
mirrored_repositories/Flutter-real-estate/lib/ui | mirrored_repositories/Flutter-real-estate/lib/ui/components/error_state.dart | import 'package:flutter/material.dart';
import 'package:flutter_real_estate/ui/components/strings.dart';
import 'package:flutter_real_estate/ui/theme/type.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../application/list_houses_provider.dart';
import '../theme/colors.dart';
class ErrorState extends ConsumerWidget {
const ErrorState({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
// Show this when a problem occurred when loading the data
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
Strings.errorText,
textAlign: TextAlign.center,
style: AppTypography.hint,
),
SizedBox(height: 16.0),
SizedBox(
width: 200,
child: GestureDetector(
onTap: () {
// Make the API call again to try to reload data
ref.invalidate(listHousesProvider);
},
child: Padding(
padding: const EdgeInsets.fromLTRB(5, 2, 5, 2),
child: Container(
decoration: BoxDecoration(
color: AppColors.white,
border: Border.all(width: 2, color: AppColors.dttRed),
borderRadius: BorderRadius.circular(40),
),
padding: EdgeInsets.fromLTRB(10, 2, 10, 2),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.autorenew,
size: 24,
color: AppColors.medium,
),
Text(Strings.reloadText,
style: AppTypography.hint.copyWith(color: AppColors.medium)),
],
),
),
),
),
)
],
);
}
}
| 0 |
mirrored_repositories/Flutter-real-estate/lib/ui | mirrored_repositories/Flutter-real-estate/lib/ui/components/bottom_app_bar.dart | import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../application/selected_index_provider.dart';
import '../theme/colors.dart';
class BottomAppBarMenu extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final selectedIndex = ref.watch(selectedIndexProvider);
return BottomNavigationBar(
items: [
// Icons in the bottomBar
BottomNavigationBarItem(
icon: Icon(Icons.home),
label: 'Home',
),
BottomNavigationBarItem(
icon: Icon(Icons.info),
label: 'Info',
),
],
// Get index from the provider
currentIndex: selectedIndex,
backgroundColor: AppColors.white,
selectedItemColor: AppColors.strong,
unselectedItemColor: AppColors.light,
showSelectedLabels: false,
showUnselectedLabels: false,
onTap: (index) {
// Change the index in the provider
ref.read(selectedIndexProvider.notifier).state = index;
},
);
}
}
| 0 |
mirrored_repositories/Flutter-real-estate/lib/ui | mirrored_repositories/Flutter-real-estate/lib/ui/components/strings.dart | class Strings {
Strings._();
static const appBarTitles = ['DTT REAL ESTATE', 'ABOUT'];
static const searchBarHint = 'Search for a home';
static const aboutText =
'Hello, I am Stefan de Kraker, a recently graduated Technical Informatics student with a great passion for hardware and software.'
'\n\nDuring my studie I took a minor in mobile application development. Since then, my love and passion for mobile app development has only grown.'
'\n\nAlthough developing mobile applications fell outside my regular course of study, I was determined to master new techniques and concepts. I hope my determination comes through in this app, because I haven\'t worked with Flutter before.'
'\n\nI hope that DTT can look past this and give me a chance to become a top Flutter developer and thus further strengthen the DTT team.'
'\n\nPlease also take a look at my Github for my personal projects such as my smartwatch app and LinkedIn for more information about my background.';
static const mapsText = 'Location of house';
static const mapsLocationId = 'targetMarker';
static const emptyListWaring = 'No results found! \nPerhaps try another search?';
static const errorText = 'Unable to load data \n Please check internet connection';
static const filters = ['Price', 'distance', 'bathrooms', 'bedrooms', 'surface area'];
static const sortText = 'Sort by:';
static const reloadText = 'Retry loading';
}
| 0 |
mirrored_repositories/Flutter-real-estate/lib/ui | mirrored_repositories/Flutter-real-estate/lib/ui/components/card_house.dart | import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:sizer/sizer.dart';
import '../../models/house_model.dart';
import '../../utils/constants.dart';
import '../screens/detail_screen.dart';
import '../theme/colors.dart';
import '../theme/type.dart';
class CardHouse extends StatelessWidget {
const CardHouse({required this.house, required this.showDistance});
final HouseData house;
final bool? showDistance;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
// Navigate to the DetailScreen when the card is tapped.
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1, animation2) => DetailScreen(selectedItem: house),
),
);
},
child: Padding(
padding: EdgeInsets.symmetric(vertical: 0.75.h, horizontal: 4.w),
child: Container(
decoration: BoxDecoration(
border: Border.all(
color: AppColors.lightGray,
),
borderRadius: const BorderRadius.all(Radius.circular(20)),
color: AppColors.white,
),
height: 15.5.h,
child: Padding(
padding: EdgeInsets.all(2.h),
child: Row(
children: [
// Display the house image with a hero animation.
Hero(
tag: house.id,
child: CachedNetworkImage(
imageUrl: Constants.baseAPIUrl + house.image,
placeholder: (context, url) => SizedBox(width: 22.w, height: 22.h),
imageBuilder: (context, imageProvider) => Container(
width: 22.w,
height: 22.h,
decoration: BoxDecoration(
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(8.0),
image: DecorationImage(image: imageProvider, fit: BoxFit.cover),
),
),
errorWidget: (context, url, error) => const Icon(Icons.error),
),
),
const SizedBox(width: 20.0),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Display the house price with commas.
Text(
'\$${house.price.toString().replaceAllMapped(RegExp(r'(\d{1,3})(?=(\d{3})+(?!\d))'), (Match m) => '${m[1]},')}',
style: AppTypography.title02,
),
SizedBox(height: 3.0),
// Display the house zip code and city.
Text(
'${house.zip} ${house.city}',
style: AppTypography.body,
),
SizedBox(height: 33.0),
Row(
children: [
// Display the number of bedrooms.
SvgPicture.asset(
'assets/icons/ic_bed.svg',
width: 2.h,
height: 2.h,
colorFilter: ColorFilter.mode(AppColors.medium, BlendMode.srcIn),
),
const SizedBox(width: 3.0),
Text(
house.bedrooms.toString(),
style: AppTypography.detail,
),
const SizedBox(width: 24.0),
// Display the number of bathrooms.
SvgPicture.asset(
'assets/icons/ic_bath.svg',
width: 2.h,
height: 2.h,
colorFilter: ColorFilter.mode(AppColors.medium, BlendMode.srcIn),
),
const SizedBox(width: 3.0),
Text(
house.bathrooms.toString(),
style: AppTypography.detail,
),
const SizedBox(width: 24.0),
// Display the house size.
SvgPicture.asset(
'assets/icons/ic_layers.svg',
width: 2.h,
height: 2.h,
colorFilter: ColorFilter.mode(AppColors.medium, BlendMode.srcIn),
),
const SizedBox(width: 2.0),
Expanded(
child: Text(
house.size.toString(),
overflow: TextOverflow.ellipsis,
style: AppTypography.detail,
),
),
// Display distance and location icon if showDistance is true.
Visibility(
visible: showDistance ?? false,
child: SvgPicture.asset(
'assets/icons/ic_location.svg',
width: 2.h,
height: 2.h,
colorFilter: ColorFilter.mode(AppColors.medium, BlendMode.srcIn),
),
),
const SizedBox(width: 2.0),
Visibility(
visible: showDistance ?? false,
child: Text(
'${house.distance}km',
style: AppTypography.detail,
),
)
],
),
],
),
)
],
),
),
),
),
);
}
}
| 0 |
mirrored_repositories/Flutter-real-estate/lib/ui | mirrored_repositories/Flutter-real-estate/lib/ui/components/empty_list_warning.dart | import 'package:flutter/cupertino.dart';
import 'package:flutter_real_estate/ui/components/strings.dart';
import 'package:flutter_real_estate/ui/theme/type.dart';
import 'package:sizer/sizer.dart';
class EmptyListWarning extends StatelessWidget {
const EmptyListWarning({super.key});
@override
Widget build(BuildContext context) {
// Show this when the search result is unable to find a result
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
'assets/images/search_state_empty.png',
width: 100.w,
height: 25.h,
),
const Text(
Strings.emptyListWaring,
textAlign: TextAlign.center,
style: AppTypography.hint,
),
],
),
);
}
}
| 0 |
mirrored_repositories/Flutter-real-estate/lib/ui | mirrored_repositories/Flutter-real-estate/lib/ui/components/list_card_house.dart | import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../application/location_permissions_provider.dart';
import '../../application/selected_sort_provider.dart';
import '../../application/text_searchbar_provider.dart';
import '../../models/house_model.dart';
import '../../models/sort_model.dart';
import 'card_house.dart';
import 'empty_list_warning.dart';
class ListCardHouse extends ConsumerWidget {
final List<HouseData> houseList;
const ListCardHouse({super.key, required this.houseList});
// Function to filter the list of houses based on search text.
Future<List<HouseData>> filterHouseList(String searchText) async {
if (searchText.isEmpty) {
// If searchText is empty, return the original houseList.
return houseList;
} else {
// Convert searchText to lowercase for case-insensitive comparison.
final lowerSearchText = searchText.toLowerCase();
return houseList.where((house) {
// Convert city and zip to lowercase for case-insensitive comparison.
final lowerCity = house.city.toLowerCase();
final lowerZip = house.zip.toLowerCase();
// Split searchText into an array of search terms.
final searchTextArr = lowerSearchText.split(RegExp(r'(?<=\D)\s'));
for (final text in searchTextArr) {
if (text.isEmpty) continue; // Skip empty search terms.
// Check if the current search term matches city or postal code.
if ((lowerCity.contains(text) || lowerZip.contains(text)) ||
(searchTextArr.length > 1 &&
(isIncludeNumber(text) ? lowerZip.contains(text) : lowerCity.contains(text)))) {
return true; // Return true if any search term matches.
}
}
return false; // Return false if no match is found.
}).toList();
}
}
// Function to check if a string contains a number.
bool isIncludeNumber(String str) {
RegExp regex = RegExp(r'\d');
return regex.hasMatch(str);
}
@override
Widget build(BuildContext context, WidgetRef ref) {
// Get information from various providers.
final showDistance = ref.watch(locationPermissionProvider);
final searchText = ref.watch(textSearchBarProvider);
final sortOrder = ref.watch(selectedSortProvider);
return FutureBuilder<List<HouseData>>(
future: filterHouseList(searchText),
builder: (context, snapshot) {
if (snapshot.hasError) {
return const EmptyListWarning();
} else if (snapshot.connectionState == ConnectionState.waiting) {
// Handle the case when the Future is still loading.
return Center(child: CircularProgressIndicator()); // You can use any loading indicator widget here.
} else if (!snapshot.hasData || snapshot.data!.isEmpty) {
// Handle the case when the Future completed, but data is null.
return const EmptyListWarning();
} else {
List<HouseData> filteredHouseList = snapshot.data!;
// Sort the filtered house list based on the selected sort order.
filteredHouseList.sort((a, b) {
switch (sortOrder.id) {
case 0:
return sortOrder.oder == Order.asc
? a.price.compareTo(b.price)
: b.price.compareTo(a.price);
case 1:
return sortOrder.oder == Order.asc
? a.distance.compareTo(b.distance)
: b.distance.compareTo(a.distance);
case 2:
return sortOrder.oder == Order.asc
? a.bathrooms.compareTo(b.bathrooms)
: b.bathrooms.compareTo(a.bathrooms);
case 3:
return sortOrder.oder == Order.asc
? a.bedrooms.compareTo(b.bedrooms)
: b.bedrooms.compareTo(a.bedrooms);
case 4:
return sortOrder.oder == Order.asc
? a.size.compareTo(b.size)
: b.size.compareTo(a.size);
}
// Default sorting if none of the cases match
return 0;
});
// Build a list view of filtered and sorted house items.
return ListView.builder(
itemCount: filteredHouseList.length,
itemBuilder: (BuildContext context, int index) {
final house = filteredHouseList[index];
return CardHouse(house: house, showDistance: showDistance.value);
},
);
}
},
);
}
}
| 0 |
mirrored_repositories/Flutter-real-estate/lib/ui | mirrored_repositories/Flutter-real-estate/lib/ui/theme/colors.dart | import 'package:flutter/material.dart';
class AppColors{
static const dttRed = Color(0xFFE65541);
static const white = Color(0xFFFFFFFF);
static const lightGray = Color(0xFFF7F7F7);
static const darkGray = Color(0xFFEBEBEB);
static const strong = Color(0xCC000000);
static const medium = Color(0x66000000);
static const light = Color(0x33000000);
} | 0 |
mirrored_repositories/Flutter-real-estate/lib/ui | mirrored_repositories/Flutter-real-estate/lib/ui/theme/type.dart | import 'package:flutter/material.dart';
import 'package:flutter_real_estate/ui/theme/colors.dart';
// Setup of font types based on input from design theme
class AppTypography {
static const title01 = TextStyle(
fontFamily: "GothamSSm",
fontSize: 18,
fontWeight: FontWeight.w400,
color: AppColors.strong,
);
static const title02 = TextStyle(
fontFamily: "GothamSSm",
fontSize: 16,
fontWeight: FontWeight.w400,
color: AppColors.strong,
);
static const title03 = TextStyle(
fontFamily: "GothamSSm",
fontSize: 16,
fontWeight: FontWeight.w500,
color: AppColors.strong,
);
static const body = TextStyle(
fontFamily: "GothamSSm",
fontSize: 12,
fontWeight: FontWeight.w300,
color: AppColors.medium,
);
static const input = TextStyle(
fontFamily: "GothamSSm",
fontSize: 18,
fontWeight: FontWeight.w300,
color: AppColors.strong
);
static const hint = TextStyle(
fontFamily: "GothamSSm",
fontSize: 16,
fontWeight: FontWeight.w300,
color: AppColors.medium,
);
static const subtitle = TextStyle(
fontFamily: "GothamSSm",
fontSize: 10,
fontWeight: FontWeight.w300,
color: AppColors.strong,
);
static const detail = TextStyle(
fontFamily: "GothamSSm",
fontSize: 12,
fontWeight: FontWeight.w400,
color: AppColors.medium,
);
}
| 0 |
mirrored_repositories/Flutter-real-estate/lib/ui | mirrored_repositories/Flutter-real-estate/lib/ui/screens/about_screen.dart | import 'package:flutter/material.dart';
import 'package:flutter_real_estate/ui/theme/type.dart';
import 'package:sizer/sizer.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../utils/constants.dart';
import '../components/strings.dart';
class AboutScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(children: [
Expanded(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 4.5.w, vertical: 0.5.h),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
Strings.aboutText,
style: AppTypography.body,
),
SizedBox(height: 4.h),
InkWell(
child: Text(
"Github repository",
style: AppTypography.body.copyWith(
color: Colors.blueAccent,
),
),
onTap: () => launchUrl(Uri.parse(Constants.githubUrl))),
InkWell(
child: Text(
"LinkedIn",
style: AppTypography.body.copyWith(
color: Colors.blueAccent,
),
),
onTap: () => launchUrl(Uri.parse(Constants.linkedinUrl))),
SizedBox(height: 4.h),
const Text(
"Design and Development",
style: AppTypography.title02,
),
SizedBox(height: 2.h),
Row(children: [
Container(
alignment: Alignment.center,
child: Image.asset(
'assets/images/dtt_banner/xxhdpi/dtt_banner.png',
fit: BoxFit.contain,
width: 150,
),
),
SizedBox(width: 6.w),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text("by DTT", style: AppTypography.input),
SizedBox(height: 0.3.h),
Center(
child: InkWell(
child: Text(
"d-tt.nl",
style: AppTypography.body.copyWith(
color: Colors.blueAccent,
),
),
onTap: () => launchUrl(Uri.parse(Constants.dttHomeUrl))),
)
],
),
]),
],
),
),
),
]);
}
}
| 0 |
mirrored_repositories/Flutter-real-estate/lib/ui | mirrored_repositories/Flutter-real-estate/lib/ui/screens/overview_screen.dart | import 'package:flutter/material.dart';
import 'package:flutter_real_estate/ui/components/error_state.dart';
import 'package:flutter_real_estate/ui/components/list_card_house.dart';
import 'package:flutter_real_estate/ui/components/strings.dart';
import 'package:flutter_real_estate/ui/theme/type.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:sizer/sizer.dart';
import '../../application/list_houses_provider.dart';
import '../../application/selected_sort_provider.dart';
import '../../application/text_searchbar_provider.dart';
import '../components/filter_card.dart';
import '../theme/colors.dart';
class OverviewScreen extends ConsumerWidget {
// Controller for the search bar input field.
final searchController = TextEditingController();
@override
Widget build(BuildContext context, WidgetRef ref) {
// Watch the list of houses from the provider.
final houseDataValue = ref.watch(listHousesProvider);
// A provider for tracking if the search bar is empty or not.
final textSearchBarIsEmptyProvider = StateProvider<bool>((ref) => true);
return Column(children: [
// Search bar section
Padding(
padding: EdgeInsets.only(top: 0.75.h, bottom: 1.5.h, right: 4.2.w, left: 4.2.w),
child: Container(
decoration: BoxDecoration(
color: AppColors.darkGray,
borderRadius: BorderRadius.circular(8.0),
),
child: Padding(
padding: EdgeInsets.only(left: 4.w, top: 0.4.h),
child: TextField(
controller: searchController,
cursorColor: AppColors.medium,
style: AppTypography.input,
decoration: InputDecoration(
hintText: Strings.searchBarHint,
hintStyle: AppTypography.hint,
suffixIcon: Consumer(
builder: (context, ref, _) =>
// Show search or clear button based on textSearchbarIsEmptyProvider.
ref.watch(textSearchBarIsEmptyProvider)
? IconButton(
icon: const Icon(Icons.search, color: AppColors.medium),
onPressed: () {},
)
: IconButton(
icon: const Icon(Icons.clear, color: AppColors.strong),
onPressed: () {
// Clear the search text when the clear button is pressed.
ref.read(textSearchBarProvider.notifier).update((_) => '');
searchController.clear();
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
ref.read(textSearchBarIsEmptyProvider.notifier).update((state) => true);
}
},
),
),
border: InputBorder.none,
),
onSubmitted: (value) {
// Update the search text when the user presses enter.
ref.read(textSearchBarProvider.notifier).update((_) => value);
},
onChanged: (value) {
// Update the state of the search bar.
ref.read(textSearchBarIsEmptyProvider.notifier).update((state) => value.isEmpty);
},
),
),
),
),
// House list section
Padding(
padding: EdgeInsets.symmetric(horizontal: 4.w),
child: SizedBox(
// Change your height based on preference
height: 40,
width: double.infinity,
child: Row(
children: [
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: const Text(Strings.sortText, textAlign: TextAlign.left),
),
Expanded(
child: Consumer(
builder: (context, ref, _) => ListView(
// Set the scroll direction to horizontal
scrollDirection: Axis.horizontal,
children: <Widget>[
for (final (index, item) in Strings.filters.indexed)
FilterCard(
text: item,
cardId: index,
selectedId: ref.watch(selectedSortProvider).id)
],
),
),
),
],
),
),
),
Expanded(
child: houseDataValue.when(
// This is set to `false` to make sure the loading state is shown when
// the data is refreshed or tried to load again
skipLoadingOnRefresh: false,
data: (houses) => ListCardHouse(houseList: houses),
loading: () => Center(child: CircularProgressIndicator()),
error: (e, __) => Center(child: ErrorState()),
),
),
]);
}
}
| 0 |
mirrored_repositories/Flutter-real-estate/lib/ui | mirrored_repositories/Flutter-real-estate/lib/ui/screens/detail_screen.dart | import 'dart:io';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_real_estate/models/house_model.dart';
import 'package:flutter_real_estate/ui/components/strings.dart';
import 'package:flutter_real_estate/ui/components/top_app_bar.dart';
import 'package:flutter_real_estate/ui/theme/type.dart';
import 'package:flutter_svg/svg.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:sizer/sizer.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../utils/constants.dart';
import '../theme/colors.dart';
class DetailScreen extends StatelessWidget {
// Constructor to initialize the DetailScreen widget with the selected property.
DetailScreen({Key? key, required this.selectedItem}) : super(key: key);
// Property data for the selected property.
final HouseData selectedItem;
// Function to open the maps app with a given latitude and longitude.
void launchMapsApp(double latitude, double longitude) async {
String mapsUrl;
if (Platform.isAndroid) {
mapsUrl = 'https://www.google.com/maps/dir/?api=1&destination=$latitude,$longitude';
} else if (Platform.isIOS) {
mapsUrl = 'http://maps.apple.com/?daddr=$latitude,$longitude';
} else {
throw 'Platform not supported.';
}
Uri uri = Uri.parse(mapsUrl);
await launchUrl(uri);
}
@override
Widget build(BuildContext context) {
return Scaffold(
extendBodyBehindAppBar: true,
appBar: TopAppBar(
title: '',
),
body: Stack(children: [
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
// Display the property image with a hero tag.
SizedBox(
height: MediaQuery.of(context).orientation == Orientation.portrait ? 250 : 200,
child: SingleChildScrollView(
child: Hero(
tag: selectedItem.id,
child: CachedNetworkImage(
imageUrl: Constants.baseAPIUrl + selectedItem.image,
fit: BoxFit.contain,
// Placeholder for the image while loading.
placeholder: (context, url) => const Center(
child: CircularProgressIndicator(),
),
// Widget displayed when an error occurs while loading the image.
errorWidget: (context, url, error) => const Icon(Icons.error),
),
),
),
),
Expanded(
child: Container(
// Decorative container for property details.
transform: Matrix4.translationValues(0.0, -10.0, 0.0),
decoration: const BoxDecoration(
color: AppColors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(12.0),
topRight: Radius.circular(12.0),
),
),
child: Padding(
padding: EdgeInsets.only(left: 6.w, right: 6.w, top: 4.h, bottom: 1.h),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expanded(
child: Text(
// Format the property price with commas.
'\$${selectedItem.price.toString().replaceAllMapped(RegExp(r'(\d{1,3})(?=(\d{3})+(?!\d))'), (Match m) => '${m[1]},')}',
style: AppTypography.title01,
)),
// Add all icons with their associated values
SizedBox(width: 1.w),
Row(mainAxisAlignment: MainAxisAlignment.end, children: [
SvgPicture.asset(
'assets/icons/ic_bed.svg',
width: 2.h,
height: 2.h,
colorFilter: ColorFilter.mode(AppColors.medium, BlendMode.srcIn),
),
SizedBox(width: 1.w),
Text(
selectedItem.bedrooms.toString(),
style: AppTypography.detail,
),
SizedBox(width: 4.w),
SvgPicture.asset(
'assets/icons/ic_bath.svg',
width: 2.h,
height: 2.h,
colorFilter: ColorFilter.mode(AppColors.medium, BlendMode.srcIn),
),
SizedBox(width: 1.w),
Text(
selectedItem.bathrooms.toString(),
style: AppTypography.detail,
),
SizedBox(width: 4.w),
SvgPicture.asset(
'assets/icons/ic_layers.svg',
width: 2.h,
height: 2.h,
colorFilter: ColorFilter.mode(AppColors.medium, BlendMode.srcIn),
),
SizedBox(width: 1.w),
Text(
selectedItem.size.toString(),
style: AppTypography.detail,
),
SizedBox(width: 4.w),
Visibility(
visible: selectedItem.distance == 0.0 ? false : true,
child: SvgPicture.asset(
'assets/icons/ic_location.svg',
width: 2.h,
height: 2.h,
colorFilter:
ColorFilter.mode(AppColors.medium, BlendMode.srcIn),
),
),
SizedBox(width: 1.w),
Visibility(
visible: selectedItem.distance == 0.0 ? false : true,
child: Text(
'${selectedItem.distance} km',
style: AppTypography.detail,
),
),
]),
],
),
SizedBox(height: 4.h),
const Text(
"Description",
style: AppTypography.title02,
),
SizedBox(height: 2.h),
// Display the property description.
Text(
selectedItem.description,
style: AppTypography.body,
),
SizedBox(height: 2.h),
const Text(
"Location",
style: AppTypography.title02,
),
SizedBox(height: 2.h),
SizedBox(
height: 34.h,
child: GoogleMap(
// Display the property location on a map.
initialCameraPosition: CameraPosition(
target: LatLng(selectedItem.latitude.toDouble(),
selectedItem.longitude.toDouble()),
zoom: 12,
),
zoomControlsEnabled: false,
mapToolbarEnabled: false,
markers: {
// Place a marker at the property location.
Marker(
markerId: const MarkerId(Strings.mapsLocationId),
position: LatLng(selectedItem.latitude.toDouble(),
selectedItem.longitude.toDouble()),
infoWindow: const InfoWindow(title: Strings.mapsText),
onTap: () {
launchMapsApp(selectedItem.latitude.toDouble(),
selectedItem.longitude.toDouble());
}),
},
),
),
],
),
),
),
),
),
],
),
]));
}
}
| 0 |
mirrored_repositories/Flutter-real-estate | mirrored_repositories/Flutter-real-estate/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_real_estate/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/DRAW | mirrored_repositories/DRAW/lib/draw.dart | // Copyright (c) 2017, the Dart Reddit API Wrapper project authors.
// Please see the AUTHORS file for details. All rights reserved.
// Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
library draw;
export 'package:draw/src/reddit.dart';
export 'package:draw/src/auth.dart';
export 'package:draw/src/base.dart';
export 'package:draw/src/exceptions.dart';
export 'package:draw/src/frontpage.dart';
export 'package:draw/src/objector.dart';
export 'package:draw/src/user.dart';
export 'package:draw/src/models/comment.dart';
export 'package:draw/src/models/comment_forest.dart' hide setSubmission;
export 'package:draw/src/models/flair.dart'
hide flairPositionToString, stringToFlairPosition;
export 'package:draw/src/models/inbox.dart';
export 'package:draw/src/listing/mixins/base.dart'
show BaseListingMixin, Sort, TimeFilter;
export 'package:draw/src/listing/mixins/gilded.dart';
export 'package:draw/src/listing/mixins/redditor.dart';
export 'package:draw/src/listing/mixins/rising.dart';
export 'package:draw/src/listing/mixins/subreddit.dart';
export 'package:draw/src/models/message.dart';
export 'package:draw/src/models/multireddit.dart'
hide iconNameToString, visibilityToString, weightingSchemeToString;
export 'package:draw/src/models/redditor.dart';
export 'package:draw/src/models/submission.dart';
export 'package:draw/src/models/subreddit.dart'
hide searchSyntaxToString, modmailSortToString, modmailStateToString;
export 'package:draw/src/models/subreddit_moderation.dart'
hide
buildModeratorAction,
moderatorActionTypesToString,
stringToModeratorActionType,
stringToSubredditType,
subredditTypeToString;
export 'package:draw/src/models/trophy.dart';
export 'package:draw/src/models/user_content.dart';
export 'package:draw/src/models/mixins/editable.dart';
export 'package:draw/src/models/mixins/gildable.dart';
export 'package:draw/src/models/mixins/inboxable.dart';
export 'package:draw/src/models/mixins/inboxtoggleable.dart';
export 'package:draw/src/models/mixins/messageable.dart';
export 'package:draw/src/models/mixins/replyable.dart';
export 'package:draw/src/models/mixins/reportable.dart';
export 'package:draw/src/models/mixins/saveable.dart';
export 'package:draw/src/models/mixins/user_content_mixin.dart';
export 'package:draw/src/models/mixins/user_content_moderation.dart'
show DistinctionType, UserContentModerationMixin;
export 'package:draw/src/models/mixins/voteable.dart';
export 'package:draw/src/modmail.dart';
export 'package:draw/src/models/wikipage.dart' hide revisionGenerator;
| 0 |
mirrored_repositories/DRAW/lib | mirrored_repositories/DRAW/lib/src/config_file_reader_unsupported.dart | /// Copyright (c) 2019, the Dart Reddit API Wrapper project authors.
/// Please see the AUTHORS file for details. All rights reserved.
/// Use of this source code is governed by a BSD-style license that
/// can be found in the LICENSE file.
class ConfigFileReader {
ConfigFileReader(String? configUrl);
/// Loads file from [_localConfigPath] or [_userConfigPath].
Null loadCorrectFile() => null;
}
| 0 |
mirrored_repositories/DRAW/lib | mirrored_repositories/DRAW/lib/src/modmail.dart | // Copyright (c) 2018, the Dart Reddit API Wrapper project authors.
// Please see the AUTHORS file for details. All rights reserved.
// Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
import 'dart:async';
import 'dart:convert';
import 'package:draw/src/api_paths.dart';
import 'package:draw/src/base_impl.dart';
import 'package:draw/src/exceptions.dart';
import 'package:draw/src/getter_utils.dart';
import 'package:draw/src/models/comment_impl.dart';
import 'package:draw/src/models/redditor.dart';
import 'package:draw/src/models/submission_impl.dart';
import 'package:draw/src/models/subreddit.dart';
import 'package:draw/src/reddit.dart';
import 'package:draw/src/util.dart';
/// A lazily initialized class which represents a Modmail conversation. Can be
/// promoted to a [ModmailConversation].
class ModmailConversationRef extends RedditBase {
static final _kIdRegExp = RegExp(r'{id}');
/// A unique ID for this conversation.
final String? id;
/// THe subject line of this conversation.
///
/// May be null.
final String? subject;
final bool _markRead;
@override
String get infoPath =>
apiPath['modmail_conversation'].replaceAll(_kIdRegExp, id);
@override
Map<String, String>? get infoParams => <String, String>{
'markRead': _markRead.toString(),
};
/// Promotes this [ModmailConversationRef] into a populated
/// [ModmailConversation].
Future<ModmailConversation> populate() async => ModmailConversation(reddit,
data: (await fetch()) as Map<dynamic, dynamic>?);
ModmailConversationRef(Reddit reddit, this.id, {bool markRead = false})
: _markRead = markRead,
subject = null,
super(reddit);
ModmailConversationRef._(Reddit reddit, this._markRead)
: id = null,
subject = null,
super(reddit);
ModmailConversationRef._withSubject(Reddit reddit, this.id, this.subject)
: _markRead = false,
super(reddit);
}
/// A fully initialized class which represents a Modmail conversation.
class ModmailConversation extends ModmailConversationRef
with RedditBaseInitializedMixin {
static final _kIdRegExp = RegExp(r'{id}');
static final _kConvKey = 'conversation';
@override
String get id => data![_kConvKey]['id'];
/// An ordered list of [Redditor]s who have participated in the conversation.
List<Redditor> get authors =>
(data![_kConvKey]['authors'] as List).cast<Redditor>();
/// Whether or not the current conversation highlighted.
bool get isHighlighted => data![_kConvKey]['isHighlighted'];
/// Whether or not this is a private moderator conversation.
bool get isInternal => data![_kConvKey]['isInternal'];
/// The date and time the conversation was last updated by a moderator.
DateTime? get lastModUpdate =>
GetterUtils.dateTimeOrNullFromString(data![_kConvKey]['lastModUpdate']);
/// The date and time the conversation was last updated.
DateTime get lastUpdated =>
GetterUtils.dateTimeOrNullFromString(data![_kConvKey]['lastUpdated'])!;
/// The date and time the conversation was last updated by a non-moderator
/// user.
DateTime? get lastUserUpdate =>
GetterUtils.dateTimeOrNullFromString(data![_kConvKey]['lastUserUpdate']);
/// The messages from this conversation.
List<ModmailMessage> get messages => data!['messages'].cast<ModmailMessage>();
/// A list of all moderator actions made on this conversation.
List<ModmailAction> get modActions =>
data!['modActions'].cast<ModmailAction>();
/// The number of messages in this conversation.
int get numMessages => data![_kConvKey]['numMessages'];
// TODO(bkonyi): find better representation of this
List<Map> get objectIds => (data![_kConvKey]['objIds'] as List).cast<Map>();
/// The subreddit associated with this conversation.
SubredditRef get owner => data![_kConvKey]['owner'];
RedditorRef get participant => data![_kConvKey]['participant'];
/// The subject line of the conversation.
@override
String? get subject => data![_kConvKey]['subject'];
ModmailConversation(Reddit reddit,
{String? id, bool markRead = false, Map? data})
: super._(reddit, markRead) {
if ((id == null) && (data == null)) {
throw DRAWArgumentError("Either 'id' or 'data' must be provided");
}
data ??= {
_kConvKey: {},
};
if (id != null) {
data[_kConvKey]['id'] = id;
} else if ((id == null) &&
(!data.containsKey(_kConvKey) || !data[_kConvKey].containsKey('id'))) {
throw DRAWArgumentError(
"Either 'id' must be provided or 'data[\"conversation\"]' must contain key 'id'");
}
setData(this, data);
}
factory ModmailConversation.parse(Reddit reddit, Map<String, dynamic> data,
{bool convertObjects = true}) {
final conversation = data['conversation'];
conversation['authors'] = (conversation['authors'] as List)
.map((a) => reddit.objector.objectify(snakeCaseMapKeys(a)))
.toList();
conversation['owner'] =
reddit.subreddit(conversation['owner']['displayName']);
final participant = conversation['participant'] as Map?;
if ((participant != null) && participant.isNotEmpty) {
conversation['participant'] = reddit.objector
.objectify(snakeCaseMapKeys(participant as Map<String, dynamic>));
}
if (data.containsKey('user')) {
_convertUserSummary(reddit, data['user']);
}
if (convertObjects) {
final converted = _convertConversationObjects(reddit, data);
data.addEntries(converted.entries);
}
return ModmailConversation(reddit, data: data);
}
String _buildConversationList(List<ModmailConversation>? otherConversations) {
final conversations = <ModmailConversation>[this];
if (otherConversations != null) {
conversations.addAll(otherConversations);
}
return conversations.map((c) => c.id).join(',');
}
void _internalUpdate(Map newData) {
newData[_kConvKey] = newData['conversations'];
newData.remove('conversations');
newData[_kConvKey]['id'] = id;
setData(this, newData);
}
static void _convertUserSummary(Reddit reddit, Map<String, dynamic> data) {
// Recent Comments
final recentComments = <Comment>[];
final rawRecentComments = data['recentComments'] as Map?;
if (rawRecentComments != null) {
rawRecentComments.forEach((k, v) {
recentComments.add(Comment.parse(reddit, v));
});
data['recentComments'] = recentComments;
}
// Modmail Conversations
final conversations = <ModmailConversationRef>[];
final rawConversations = data['recentConvos'] as Map?;
if (rawConversations != null) {
rawConversations.forEach((k, v) {
conversations.add(ModmailConversationRef._withSubject(
reddit, data['id'], data['subject']));
});
data['recentConvos'] = recentComments;
}
// Submissions
final submissions = <Submission>[];
final rawSubmissions = data['recentPosts'] as Map?;
if (rawSubmissions != null) {
rawSubmissions.forEach((k, v) {
submissions.add(Submission.parse(reddit, v));
});
data['recentPosts'] = submissions;
}
}
static Map<String, List<dynamic>> _convertConversationObjects(
Reddit reddit, Map<String, dynamic> data) {
final result = {
'messages': <ModmailMessage?>[],
'modActions': [],
};
for (final t in data['conversation']['objIds']) {
final key = t['key'];
final tData = data[key][t['id']];
result[key]!.add(reddit.objector.objectify(tData));
}
return result;
}
/// Archive the conversation.
Future<void> archive() async => _internalUpdate((await reddit.post(
apiPath['modmail_archive'].replaceAll(_kIdRegExp, id),
<String, String>{})) as Map<dynamic, dynamic>);
/// Highlight the conversation.
Future<void> highlight() async => _internalUpdate((await reddit.post(
apiPath['modmail_highlight'].replaceAll(_kIdRegExp, id),
<String, String>{})) as Map<dynamic, dynamic>);
/// Mute the user (non-moderator) associated with the conversation.
Future<void> mute() async => _internalUpdate((await reddit.post(
apiPath['modmail_mute'].replaceAll(_kIdRegExp, id),
<String, String>{})) as Map<dynamic, dynamic>);
/// Mark the conversation as read.
///
/// If `otherConversations` is provided, those conversations will also be
/// marked as read.
Future<void> read({List<ModmailConversation>? otherConversations}) async {
final data = <String, String>{
'conversationIds': _buildConversationList(otherConversations),
};
await reddit.post(apiPath['modmail_read'].replaceAll(_kIdRegExp, id), data);
}
/// Reply to the conversation.
///
/// `body`: the markdown formatted content of the reply.
/// `authorHidden`: when true, the author is hidden from non-moderators. This
/// is the same as replying as a subreddit.
/// `internal`: when true, the reply will be an internal moderator note on
/// the conversation that is not visible to non-moderators.
///
/// Returns a [ModmailMessage] for the new message.
Future<ModmailMessage> reply(String body,
{bool authorHidden = false, bool internal = false}) async {
final data = <String, String>{
'body': body,
'isAuthorHidden': authorHidden.toString(),
'isInternal': internal.toString(),
};
final response = await reddit.post(
apiPath['modmail_conversation'].replaceAll(_kIdRegExp, id), data,
objectify: false);
final msgId = ((response['conversation']['objIds'] as List).last)['id'];
final message = response['messages'][msgId];
return ModmailMessage.parse(reddit, message);
}
/// Unarchive the conversation.
Future<void> unarchive() async => _internalUpdate((await reddit.post(
apiPath['modmail_unarchive'].replaceAll(_kIdRegExp, id),
<String, String>{})) as Map<dynamic, dynamic>);
/// Unhighlight the conversation.
Future<void> unhighlight() async => _internalUpdate((await reddit.delete(
apiPath['modmail_highlight'].replaceAll(_kIdRegExp, id),
)) as Map<dynamic, dynamic>);
/// Unmute the conversation.
Future<void> unmute() async => _internalUpdate((await reddit.post(
apiPath['modmail_unmute'].replaceAll(_kIdRegExp, id),
<String, String>{})) as Map<dynamic, dynamic>);
/// Mark the conversation as unread.
///
/// If `otherConversations` is provided, those conversations will also be
/// marked as unread.
Future<void> unread({List? otherConversations}) async {
final data = <String, String>{
'conversationIds': _buildConversationList(
otherConversations as List<ModmailConversation>?),
};
return await reddit.post(
apiPath['modmail_unread'].replaceAll(_kIdRegExp, id), data);
}
}
/// A class that represents a message from a [ModmailConversation].
class ModmailMessage {
final Reddit reddit;
final Map<String, dynamic>? data;
ModmailMessage.parse(this.reddit, this.data);
/// The [Redditor] who composed this message.
Redditor get author =>
Redditor.parse(reddit, snakeCaseMapKeys(data!['author']));
/// The HTML body of the message.
String get body => data!['body'];
/// The body of the message in Markdown format.
String get bodyMarkdown => data!['bodyMarkdown'];
/// The date and time the message was sent.
DateTime get date => GetterUtils.dateTimeOrNullFromString(data!['date'])!;
/// A unique ID associated with this message.
String get id => data!['id'];
/// True if the account that authored this message has been deleted.
bool get isDeleted => data!['author']['isDeleted'];
/// True if the message was sent on behalf of a subreddit.
bool get isHidden => data!['author']['isHidden'];
/// True if the message is only visible to moderators.
bool get isInternal => data!['isInternal'];
/// True if this message was written by the author of the thread.
bool get isOriginalPoster => data!['author']['isOp'];
/// True if the author of this message has participated in the conversation.
bool get isParticipant => data!['author']['isParticipant'];
@override
String toString() => JsonEncoder.withIndent(' ').convert(data);
}
ModmailActionType _modmailActionTypeFromInt(int i) {
switch (i) {
case 0:
return ModmailActionType.highlight;
case 1:
return ModmailActionType.unhighlight;
case 2:
return ModmailActionType.archive;
case 3:
return ModmailActionType.unarchive;
case 4:
return ModmailActionType.reportedToAdmins;
case 5:
return ModmailActionType.mute;
case 6:
return ModmailActionType.unmute;
default:
return ModmailActionType.unknown;
}
}
/// All possible actions that can be made in a [ModmailConversation].
enum ModmailActionType {
highlight,
unhighlight,
archive,
unarchive,
reportedToAdmins,
mute,
unmute,
unknown
}
/// A class that represents an action taken by a moderator in a
/// [ModmailConversation].
class ModmailAction {
final Reddit reddit;
final Map<String, dynamic> data;
ModmailAction.parse(this.reddit, this.data);
/// The type of moderator action taken.
ModmailActionType get actionType =>
_modmailActionTypeFromInt(data['actionTypeId']);
/// The [Redditor] who applied the moderator action.
Redditor get author =>
Redditor.parse(reddit, snakeCaseMapKeys(data['author']));
/// The date the action was made.
DateTime get date => GetterUtils.dateTimeOrNullFromString(data['date'])!;
/// A unique ID associated with this action.
String get id => data['id'];
@override
String toString() => JsonEncoder.withIndent(' ').convert(data);
}
| 0 |
mirrored_repositories/DRAW/lib | mirrored_repositories/DRAW/lib/src/logging.dart | // Copyright (c) 2018, the Dart Reddit API Wrapper project authors.
// Please see the AUTHORS file for details. All rights reserved.
// Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
import 'dart:convert';
import 'package:logging/logging.dart';
export 'package:logging/logging.dart' show Level, Logger;
const JsonEncoder e = JsonEncoder.withIndent(' ');
abstract class DRAWLoggingUtils {
static void initialize() {
Logger.root.level = Level.OFF;
Logger.root.onRecord.listen((LogRecord rec) {
print('${rec.level.name} (${rec.loggerName}): ${rec.message}');
});
}
static void setLogLevel(Level l) => Logger.root.level = l;
static String jsonify(jObj) => e.convert(jObj);
}
| 0 |
mirrored_repositories/DRAW/lib | mirrored_repositories/DRAW/lib/src/exceptions.dart | // Copyright (c) 2017, the Dart Reddit API Wrapper project authors.
// Please see the AUTHORS file for details. All rights reserved.
// Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
/// Thrown when there is an error during the authentication flow.
class DRAWAuthenticationError implements Exception {
DRAWAuthenticationError(this.message);
final String message;
@override
String toString() => 'DRAWAuthenticationError: $message';
}
/// Thrown due to invalid arguments being provided to a DRAW method.
class DRAWArgumentError implements Exception {
DRAWArgumentError(this.message);
final String message;
@override
String toString() => 'DRAWArgumentError: $message';
}
/// Thrown due to a fatal error encountered inside DRAW. If you're not adding
/// functionality to DRAW you should never see this. Otherwise, please file a
/// bug at github.com/draw-dev/DRAW/issues.
class DRAWInternalError implements Exception {
DRAWInternalError(this.message);
final String message;
@override
String toString() => 'DRAWInternalError: $message';
}
/// Thrown due to a error on the side of the client due to incorrect integration of DRAW.
class DRAWClientError implements Exception {
DRAWClientError(this.message);
final String message;
@override
String toString() =>
'DRAWClientError: $message This is likely due to issues with your ini file.';
}
/// Thrown when a redirect is requested after a network call. Used to notify
/// various APIs that additional work needs to be done.
class DRAWRedirectResponse implements Exception {
final String path;
final response;
DRAWRedirectResponse(this.path, this.response);
@override
String toString() => 'DRAWRedirectResponse: Unexpected redirect to $path.';
}
/// Thrown if a call to gild a [Comment], [Redditor], or [Submission] fails.
class DRAWGildingException implements Exception {
final Map<String, String> response;
DRAWGildingException(this.response);
String? get explanation => response['explanation'];
String? get message => response['message'];
String? get reason => response['reason'];
@override
String toString() => 'DRAWGildingException: $explanation (reason: $reason)';
}
/// Thrown by unfinished code that hasn't yet implemented all the features it
/// needs.
class DRAWUnimplementedError extends UnimplementedError {
DRAWUnimplementedError([String? message]) : super(message);
}
/// Thrown when a Reddit object could not be found.
class DRAWNotFoundException implements Exception {
final String? reason;
final String? message;
DRAWNotFoundException(this.reason, this.message);
@override
String toString() =>
'DRAWNotFoundException(Reason: "$reason", Message: "$message")';
}
/// Thrown when a request is made with an invalid comment ID.
class DRAWInvalidCommentException implements Exception {
final String commentId;
DRAWInvalidCommentException(this.commentId);
@override
String toString() =>
'DRAWInvalidCommentException: "$commentId" is not a valid comment ID.';
}
/// Thrown when a request is made with an invalid Redditor name.
class DRAWInvalidRedditorException implements Exception {
final String redditorName;
DRAWInvalidRedditorException(this.redditorName);
@override
String toString() =>
'DRAWInvalidRedditorException: "$redditorName" is not a valid redditor.';
}
/// Thrown when a request is made with an invalid submission ID.
class DRAWInvalidSubmissionException implements Exception {
final String submissionId;
DRAWInvalidSubmissionException(this.submissionId);
@override
String toString() =>
'DRAWInvalidSubmissionException: "$submissionId" is not a valid submission ID.';
}
/// Thrown when a request is made with an invalid Subreddit name.
class DRAWInvalidSubredditException implements Exception {
final String subredditName;
DRAWInvalidSubredditException(this.subredditName);
@override
String toString() =>
'DRAWInvalidSubredditException: "$subredditName" is not a valid subreddit.';
}
/// Thrown due to an unexpected response from Reddit. If you're not adding
/// functionality to DRAW you should never see this. Otherwise, please file a
/// bug at github.com/draw-dev/DRAW/issues.
class DRAWUnknownResponseException implements Exception {
final int status;
final String message;
DRAWUnknownResponseException(this.status, this.message);
@override
String toString() => 'DRAWUnknownResponse: $message (status: $status)';
}
/// Thrown if an image upload fails.
class DRAWImageUploadException implements Exception {
final String error;
final String message;
DRAWImageUploadException(this.error, this.message);
@override
String toString() => 'DRAWImageUploadException: ($error) $message';
}
| 0 |
mirrored_repositories/DRAW/lib | mirrored_repositories/DRAW/lib/src/frontpage.dart | // Copyright (c) 2019, the Dart Reddit API Wrapper project authors.
// Please see the AUTHORS file for details. All rights reserved.
// Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
import 'package:draw/draw.dart';
import 'package:draw/src/base.dart';
import 'package:draw/src/listing/listing_generator.dart';
import 'package:draw/src/listing/mixins/base.dart';
import 'package:draw/src/listing/mixins/gilded.dart';
import 'package:draw/src/listing/mixins/rising.dart';
import 'package:draw/src/reddit.dart';
/// The [FrontPage] class provides methods to access listings of content on the
/// Reddit front page.
class FrontPage extends RedditBase
with BaseListingMixin, GildedListingMixin, RisingListingMixin {
@override
String path = '/';
FrontPage(Reddit reddit) : super(reddit);
/// Returns a [UserContent] that is "best".
///
/// `limit` is the maximum number of objects returned by Reddit per request
/// (the default is 100). If provided, `after` specifies from which point
/// Reddit will return objects of the requested type. `params` is a set of
/// additional parameters that will be forwarded along with the request.
Stream<UserContent> best(
{int? limit, String? after, Map<String, String>? params}) =>
ListingGenerator.createBasicGenerator(reddit, path + 'best',
limit: limit, after: after, params: params);
}
| 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.