repo_id
stringlengths
21
168
file_path
stringlengths
36
210
content
stringlengths
1
9.98M
__index_level_0__
int64
0
0
mirrored_repositories/facebook_flutter/lib/layout/home
mirrored_repositories/facebook_flutter/lib/layout/home/home_cubit/home_states.dart
abstract class HomeStates{} class InitialHomeState extends HomeStates{} class ChangeSizePost extends HomeStates{}
0
mirrored_repositories/facebook_flutter/lib/web
mirrored_repositories/facebook_flutter/lib/web/widgets/widget.dart
import 'package:facebook/shared/style/color.dart'; import 'package:flutter/material.dart'; class DefaultTextFormFieldWeb extends StatelessWidget { final String hint; final TextEditingController controller; final TextInputType? textInputType; final bool isHide; final Widget? suffixIcon; final Widget? prefixIcon; final FormFieldValidator<String>? validator; final ValueChanged<String>? onChanged; DefaultTextFormFieldWeb({ required this.hint, required this.controller, this.isHide = false, this.suffixIcon, this.prefixIcon, this.validator, this.onChanged, this.textInputType, }); @override Widget build(BuildContext context) { return TextFormField( controller: controller, validator: validator, textAlign: TextAlign.end, onChanged: onChanged, style: TextStyle(), decoration: InputDecoration( hintText: '$hint', suffixIcon: suffixIcon, prefixIcon: prefixIcon, hintStyle: TextStyle( fontWeight: FontWeight.w500, fontSize: 18, color: Colors.grey[600], ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(5), borderSide: BorderSide( color: Colors.blue, width: 1.0, ), ), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(5), borderSide: BorderSide( color: Colors.grey.shade300, width: 1.0, ), ), ), keyboardType: textInputType, obscureText: isHide, ); } } class DefaultButtonWeb extends StatelessWidget { final VoidCallback onPressed; final String text; final double? height; final Color color; final double width; DefaultButtonWeb({ required this.onPressed, required this.text, this.height, this.color = primaryColor, this.width = double.infinity, }); @override Widget build(BuildContext context) { return Container( width: width, height: height, decoration: BoxDecoration( borderRadius: BorderRadius.circular(5.0), ), clipBehavior: Clip.antiAlias, child: MaterialButton( onPressed: onPressed, child: Text( '$text', style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, ), ), color: color, ), ); } }
0
mirrored_repositories/facebook_flutter/lib/web/modul
mirrored_repositories/facebook_flutter/lib/web/modul/home_page/home_page_screen.dart
import 'package:facebook/model/local_data.dart'; import 'package:facebook/shared/components/constant.dart'; import 'package:facebook/shared/style/color.dart'; import 'package:facebook/shared/style/custom_icons_icons.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:stack_percentage/stack_percentage.dart'; class HomePageScreenWeb extends StatelessWidget { final TextEditingController controller = TextEditingController(); final String email = 'hamada.devlop@gmail.com'; final String test = 'https://gdj-inr5u0ip5pewom.stackpathdns.com/wp-content/uploads/2012/01/9extremely-creative-photo.jpg'; final List<LocalData> persons = [ LocalData( name: 'sara ahmed', url: 'https://images.unsplash.com/photo-1438761681033-6461ffad8d80?ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8cGVyc29ufGVufDB8fDB8fA%3D%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1100&q=60', message: 'hi i am sara fsdjkfdsdsdsdsdjkg', story: 'https://cdn.eso.org/images/thumb300y/eso1907a.jpg', ), LocalData( name: 'Mounir said', url: 'https://upload.wikimedia.org/wikipedia/commons/a/a0/Pierre-Person.jpg', message: 'It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout', story: 'https://res.cloudinary.com/grand-canyon-university/image/fetch/w_750,h_564,c_fill,g_faces/https://www.gcu.edu/sites/default/files/2020-09/programming.jpg', ), LocalData( name: 'alien', url: 'https://mlhmvq6amqed.i.optimole.com/HIId8M4.WANK~27a14/w:940/h:788/q:auto/https://hackspirit.com/wp-content/uploads/2021/06/Copy-of-Copy-of-Copy-of-Rustic-Female-Teen-Magazine-Cover-52.jpg', message: 'The point of using Lorem Ipsum is that it has a more', story: 'https://st3.depositphotos.com/18340478/36792/i/450/depositphotos_367922774-stock-photo-programmer-girl-works-computer-information.jpg', ), LocalData( name: 'mona', url: 'https://miro.medium.com/max/1200/1*gBQxShAkxBp_YPb14CN0Nw.jpeg', message: 'There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form', story: 'https://psmag.com/.image/t_share/MTMxODI3Mjk4OTkwMDgyMDU4/shutterstock_125158133jpg.jpg', ), LocalData( name: 'samir', url: 'https://1.bp.blogspot.com/-ndm33aqcslo/XsoU6May3lI/AAAAAAAAAUo/buf59MZ3JTIf1qRc7xOuUas3D6mxcVjBACK4BGAsYHg/images%2B%252822%2529.jpeg', message: 'If you are going to use a passage of Lorem Ipsum, you need to be sure there isn\'anything embarrassing ', story: 'https://gdj-inr5u0ip5pewom.stackpathdns.com/wp-content/uploads/2012/01/9extremely-creative-photo.jpg', ), ]; @override Widget build(BuildContext context) { return LayoutBuilder( builder: (context, constraints) { print(constraints.minWidth); if (constraints.minWidth >= 614) return Container( child: Row( mainAxisAlignment: constraints.minWidth >= 900 ? MainAxisAlignment.start : MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ // ** جهات الاتصال if (constraints.minWidth >= 900) Container( color: Colors.grey[300], width: 300, padding: EdgeInsets.all(20), height: double.infinity, child: SingleChildScrollView( child: Column( children: [ Row( children: [ Expanded( flex: 1, child: IconButton( onPressed: () {}, icon: Icon( Icons.more_horiz_rounded, color: Colors.black54, ), ), ), Expanded( flex: 1, child: IconButton( onPressed: () {}, icon: Icon( Icons.search, color: Colors.black54, ), ), ), Expanded( flex: 1, child: IconButton( onPressed: () {}, icon: Icon( Icons.video_call, color: Colors.black54, ), ), ), Expanded( flex: 3, child: Text( 'جهات الاتصال', style: TextStyle( fontSize: 20, fontWeight: FontWeight.w600, color: Colors.black54, ), textAlign: TextAlign.center, ), ), ], ), SizedBox( height: 20, ), MaterialButton( onPressed: () {}, child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ Text( persons[0].name, ), SizedBox( width: 10, ), CircleAvatar( radius: 20, backgroundImage: NetworkImage( '${persons[0].url}', ), ), ], ), ), SizedBox( height: 20, ), MaterialButton( onPressed: () {}, child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ Text( persons[1].name, ), SizedBox( width: 10, ), CircleAvatar( radius: 20, backgroundImage: NetworkImage( '${persons[1].url}', ), ), ], ), ), SizedBox( height: 20, ), MaterialButton( onPressed: () {}, child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ Text( persons[2].name, ), SizedBox( width: 10, ), CircleAvatar( radius: 20, backgroundImage: NetworkImage( '${persons[2].url}', ), ), ], ), ), SizedBox( height: 20, ), MaterialButton( onPressed: () {}, child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ Text( persons[3].name, ), SizedBox( width: 10, ), CircleAvatar( radius: 20, backgroundImage: NetworkImage( '${persons[3].url}', ), ), ], ), ), SizedBox( height: 20, ), MaterialButton( onPressed: () {}, child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ Text( persons[4].name, ), SizedBox( width: 10, ), CircleAvatar( radius: 20, backgroundImage: NetworkImage( '${persons[4].url}', ), ), ], ), ), ], ), ), ), // ** الصفحة الرئيسية Expanded( child: Container( color: Colors.grey[300], width: 614, child: SingleChildScrollView( child: Column( children: [ //** الصفحة الاساسية الثابته Container( width: 614, color: Colors.grey[300], child: Column( children: [ //** part stories** Stack( children: [ Padding( padding: const EdgeInsets.all(20.0), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Expanded( child: Container( height: 160, child: Stack( children: [ Card( color: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular( 10), ), clipBehavior: Clip.antiAlias, child: Column( children: [ Expanded( flex: 2, child: Container( decoration: BoxDecoration( image: DecorationImage( image: NetworkImage( '${persons[0].story}'), fit: BoxFit.cover, )), ), ), ], ), ), Padding( padding: const EdgeInsets.all( 10.0), child: Align( alignment: AlignmentDirectional .topEnd, child: Container( width: 40, height: 40, decoration: BoxDecoration( borderRadius: BorderRadius .circular(20), color: Colors.blue, border: Border.all( color: primaryColor, width: 2.3, ), image: DecorationImage( image: NetworkImage( '${persons[0].url}', ), fit: BoxFit .cover), ), ), ), ), Align( alignment: AlignmentDirectional .bottomCenter, child: Padding( padding: const EdgeInsets.all( 15.0), child: Text( '${persons[0].name}', maxLines: 1, overflow: TextOverflow .ellipsis, style: TextStyle( color: Colors.white, fontWeight: FontWeight.w500, ), ), ), ), ], ), ), ), Expanded( child: Container( height: 160, child: Stack( children: [ Card( color: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular( 10), ), clipBehavior: Clip.antiAlias, child: Column( children: [ Expanded( flex: 2, child: Container( decoration: BoxDecoration( image: DecorationImage( image: NetworkImage( '${persons[0].story}'), fit: BoxFit.cover, )), ), ), ], ), ), Padding( padding: const EdgeInsets.all( 10.0), child: Align( alignment: AlignmentDirectional .topEnd, child: Container( width: 40, height: 40, decoration: BoxDecoration( borderRadius: BorderRadius .circular(20), color: Colors.blue, border: Border.all( color: primaryColor, width: 2.3, ), image: DecorationImage( image: NetworkImage( '${persons[0].url}', ), fit: BoxFit .cover), ), ), ), ), Align( alignment: AlignmentDirectional .bottomCenter, child: Padding( padding: const EdgeInsets.all( 15.0), child: Text( '${persons[0].name}', maxLines: 1, overflow: TextOverflow .ellipsis, style: TextStyle( color: Colors.white, fontWeight: FontWeight.w500, ), ), ), ), ], ), ), ), Expanded( child: Container( height: 160, child: Stack( alignment: AlignmentDirectional .bottomCenter, children: [ Card( color: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular( 10), ), clipBehavior: Clip.antiAlias, child: Column( children: [ Expanded( flex: 2, child: Container( decoration: BoxDecoration( image: DecorationImage( image: NetworkImage( '${persons[0].story}'), fit: BoxFit.cover, )), ), ), ], ), ), Padding( padding: const EdgeInsets.all( 10.0), child: Align( alignment: AlignmentDirectional .topEnd, child: Container( width: 40, height: 40, decoration: BoxDecoration( borderRadius: BorderRadius .circular(20), color: Colors.blue, border: Border.all( color: primaryColor, width: 2.3, ), image: DecorationImage( image: NetworkImage( '${persons[0].url}', ), fit: BoxFit .cover), ), ), ), ), Padding( padding: const EdgeInsets.all( 15.0), child: Text( '${persons[0].name}', maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( color: Colors.white, fontWeight: FontWeight.w500, ), ), ), ], ), ), ), Expanded( child: Container( height: 160, child: Stack( alignment: AlignmentDirectional .bottomCenter, children: [ Card( color: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular( 10), ), clipBehavior: Clip.antiAlias, child: Column( children: [ Expanded( flex: 2, child: Container( decoration: BoxDecoration( image: DecorationImage( image: NetworkImage( '${persons[0].story}'), fit: BoxFit.cover, )), ), ), ], ), ), Padding( padding: const EdgeInsets.all( 10.0), child: Align( alignment: AlignmentDirectional .topEnd, child: Container( width: 40, height: 40, decoration: BoxDecoration( borderRadius: BorderRadius .circular(20), color: Colors.blue, border: Border.all( color: primaryColor, width: 2.3, ), image: DecorationImage( image: NetworkImage( '${persons[0].url}', ), fit: BoxFit .cover), ), ), ), ), Padding( padding: const EdgeInsets.all( 15.0), child: Text( '${persons[0].name}', maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( color: Colors.white, fontWeight: FontWeight.w500, ), ), ), ], ), ), ), Expanded( child: Container( height: 160, child: Stack( alignment: AlignmentDirectional .bottomCenter, children: [ Card( color: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular( 10), ), clipBehavior: Clip.antiAlias, child: Column( children: [ Expanded( flex: 2, child: Container( decoration: BoxDecoration( image: DecorationImage( image: NetworkImage( '${persons[0].story}'), fit: BoxFit.cover, )), ), ), ], ), ), Padding( padding: const EdgeInsets.all( 10.0), child: Align( alignment: AlignmentDirectional .topEnd, child: Container( width: 40, height: 40, decoration: BoxDecoration( borderRadius: BorderRadius .circular(20), color: Colors.blue, border: Border.all( color: primaryColor, width: 2.3, ), image: DecorationImage( image: NetworkImage( '${persons[0].url}', ), fit: BoxFit .cover), ), ), ), ), Padding( padding: const EdgeInsets.all( 15.0), child: Text( '${persons[0].name}', maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( color: Colors.white, fontWeight: FontWeight.w500, ), ), ), ], ), ), ), Expanded( child: Container( height: 160, child: Stack( alignment: AlignmentDirectional .bottomCenter, children: [ Card( color: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular( 10), ), clipBehavior: Clip.antiAlias, child: Column( children: [ Expanded( flex: 2, child: Container( decoration: BoxDecoration( image: DecorationImage( image: NetworkImage( 'https://images.unsplash.com/photo-1503023345310-bd7c1de61c7d?ixid=MnwxMjA3fDB8MHxzZWFyY2h8M3x8aHVtYW58ZW58MHx8MHx8&ixlib=rb-1.2.1&w=1000&q=80'), fit: BoxFit.cover, )), ), ), Expanded( child: Align( alignment: AlignmentDirectional .bottomCenter, child: Padding( padding: const EdgeInsets .all(3.0), child: Text( 'إنشاء قصة', style: TextStyle( fontWeight: FontWeight .w500, ), ), ), ), ), ], ), ), PositionedDirectional( top: Percent .widgetVerticalPosition( ratio: 50, heightChild: 40, heightParent: 200, ), child: Center( child: Container( width: 40, height: 40, decoration: BoxDecoration( borderRadius: BorderRadius .circular(20), color: Colors.blue, border: Border.all( color: Colors.white, width: 2.3, ), ), child: Icon( Icons.add, color: Colors.white, size: 30, ), ), ), ), ], ), ), ), ], ), ), Positioned( top: 80, child: Container( width: 40, height: 40, decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: Colors.white, ), child: Icon( Icons.arrow_back, color: Colors.black54, size: 22, ), ), ), ], ), //** part 'what do you think' and [live, image, room] Padding( padding: const EdgeInsets.symmetric( horizontal: 15), child: Card( elevation: 5, color: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(9), ), child: Container( width: 550, height: 130, child: Column( children: [ Padding( padding: const EdgeInsets.symmetric( horizontal: 20, vertical: 15), child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( child: Container( margin: EdgeInsetsDirectional .only( top: 1.5, ), height: 38, decoration: BoxDecoration( borderRadius: BorderRadius.circular( 20), color: Colors.grey[300], ), child: Padding( padding: const EdgeInsets .symmetric( vertical: 5, horizontal: 20, ), child: Text( 'بم تفكر؟', textAlign: TextAlign.end, style: TextStyle( fontSize: 17, fontWeight: FontWeight.w500, color: Colors.black, ), ), ), ), ), SizedBox( width: 10, ), CircleAvatar( radius: 19, backgroundColor: Colors.blue, backgroundImage: NetworkImage( 'https://images.unsplash.com/photo-1503023345310-bd7c1de61c7d?ixid=MnwxMjA3fDB8MHxzZWFyY2h8M3x8aHVtYW58ZW58MHx8MHx8&ixlib=rb-1.2.1&w=1000&q=80', ), ), ], ), ), Padding( padding: const EdgeInsets.symmetric( horizontal: 20), child: Container( height: 0.5, width: double.infinity, color: Colors.grey, ), ), SizedBox( height: 15, ), Row( children: [ Expanded( child: MaterialButton( onPressed: () {}, child: Row( mainAxisAlignment: MainAxisAlignment .center, children: [ Text( 'غرفة', style: TextStyle( fontSize: 16, ), ), Icon( Icons.video_call, color: Colors .deepPurpleAccent, size: 22, ), ], ), ), ), Expanded( child: MaterialButton( onPressed: () {}, child: Row( mainAxisAlignment: MainAxisAlignment .center, children: [ Text( 'صورة', style: TextStyle( fontSize: 16, ), ), Icon( CustomIcons.gallery, color: Colors.lightGreen, size: 18, ), ], ), ), ), Expanded( child: MaterialButton( onPressed: () {}, child: Row( mainAxisAlignment: MainAxisAlignment .center, children: [ Text( 'بث مباشر', style: TextStyle( fontSize: 16, ), ), Icon( Icons.missed_video_call, color: Colors.pinkAccent, size: 22, ), ], ), ), ), ], ), ], ), ), ), ), //** part posts Padding( padding: const EdgeInsets.symmetric( horizontal: 15), child: Card( elevation: 5, color: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(9), ), child: Wrap( alignment: WrapAlignment.end, children: [ Container( padding: EdgeInsetsDirectional.only( end: 15.0), child: Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ Row( children: [ IconButton( padding: EdgeInsetsDirectional .zero, onPressed: () {}, icon: Icon( Icons.more_horiz_rounded, color: Colors.grey[700], ), ), Spacer(), Column( crossAxisAlignment: CrossAxisAlignment.end, mainAxisSize: MainAxisSize.min, children: [ Text( 'Sara Ahmed', style: TextStyle( fontWeight: FontWeight.bold, ), ), Row( children: [ Padding( padding: const EdgeInsets .symmetric( horizontal: 4.0), child: Icon( Icons .public_rounded, color: Colors .grey[700], size: 16, ), ), Text( 'أمس الساعة 9:13 م', style: TextStyle( fontSize: 12, ), ), ], ), ], ), Padding( padding: const EdgeInsetsDirectional .only(start: 15), child: Align( alignment: AlignmentDirectional .topEnd, child: Container( width: 40, height: 40, decoration: BoxDecoration( borderRadius: BorderRadius .circular(20), color: Colors.blue, border: Border.all( color: primaryColor, width: 2.3, ), image: DecorationImage( image: NetworkImage( 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRmiipzUG3KoBS7uiWIx9M7Z-VUTdT0w-Cn-g&usqp=CAU', ), fit: BoxFit .cover), ), ), ), ), ], ), Text( 'الزمالك هذا الموسم \nبطل الدورى لكرة القدم\n بطل الدورى المصرى لكرة اليد\n بطل دورى السوبر المصري لكرة السلة \n', textDirection: TextDirection.rtl, style: TextStyle( fontWeight: FontWeight.w500, fontSize: 14, ), ), ], ), ), Image( image: NetworkImage( 'https://cdn.eso.org/images/thumb300y/eso1907a.jpg', ), ), Padding( padding: const EdgeInsets.all(12.0), child: Container( width: double.infinity, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Row( children: [ Text( '${arabicNumber.convert(4777)} مشاركة ', textDirection: TextDirection.rtl, style: TextStyle( color: Colors.grey, ), ), SizedBox( width: 5, ), Text( '${arabicNumber.convert(4777)} تعليقا ', textDirection: TextDirection.rtl, style: TextStyle( color: Colors.grey, ), ), Spacer(), Container( width: 85, child: Stack( children: [ Row( children: [ Text( '${arabicNumber.convert(43576)}', textDirection: TextDirection .rtl, style: TextStyle( color: Colors .grey, ), ), ], ), PositionedDirectional( end: 0, child: Container( height: 20, width: 20, decoration: BoxDecoration( border: Border.all( color: Colors .white, width: 1.5), borderRadius: BorderRadius .circular( 18)), child: SvgPicture .asset( 'assets/icons/facebook_love.svg', ), ), ), PositionedDirectional( end: 16, child: Container( height: 20, width: 20, decoration: BoxDecoration( border: Border.all( color: Colors .white, width: 1.5), borderRadius: BorderRadius .circular( 18)), child: SvgPicture .asset( 'assets/icons/care.svg', ), ), ), PositionedDirectional( end: 32, child: Container( height: 20, width: 20, decoration: BoxDecoration( border: Border.all( color: Colors .white, width: 1.5), borderRadius: BorderRadius .circular( 18)), child: SvgPicture .asset( 'assets/icons/facebook_like.svg', ), ), ), ], ), ), ], ), SizedBox( height: 15, ), Row( children: [ Expanded( child: Container( child: Row( mainAxisAlignment: MainAxisAlignment .center, children: [ Text( 'مشاركة', style: TextStyle( color: Colors.grey, fontWeight: FontWeight .w600, ), ), Icon( CustomIcons .arrow_curved_to_the_left_svgrepo_com, color: Colors.grey, ), ], ), ), ), Expanded( child: Container( child: Row( mainAxisAlignment: MainAxisAlignment .center, children: [ Text( 'تعليق', style: TextStyle( color: Colors.grey, fontWeight: FontWeight .w600, ), ), Icon( CustomIcons .comment_svgrepo_com, color: Colors.grey, ), ], ), ), ), Expanded( child: Container( child: Row( mainAxisAlignment: MainAxisAlignment .center, children: [ Text( 'أعجبنى', style: TextStyle( color: Colors.grey, fontWeight: FontWeight .w600, ), ), SizedBox( width: 10, ), Icon( CustomIcons .like_svgrepo_com, color: Colors.grey, size: 20, ), ], ), ), ), ], ), ], ), ), ), ], ), ), ), ], ), ), ], ), ), ), ), // ** القائمة الاعدادات if (constraints.minWidth >= 1100) Container( color: Colors.grey[300], width: 300, padding: EdgeInsets.all(20), height: double.infinity, child: SingleChildScrollView( child: Column( children: [ MaterialButton( onPressed: () {}, child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ Text( persons[0].name, ), SizedBox( width: 10, ), CircleAvatar( radius: 20, backgroundImage: NetworkImage( '${persons[0].url}', ), ), ], ), ), SizedBox( height: 20, ), MaterialButton( onPressed: () {}, child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ Text( 'الأصدقاء', style: TextStyle( fontSize: 18, fontWeight: FontWeight.w500, color: Colors.black54, ), ), SizedBox( width: 10, ), Image( image: AssetImage( 'assets/images/friends.png', ), ), ], ), ), SizedBox( height: 20, ), MaterialButton( onPressed: () {}, child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ Text( 'الذكريات', style: TextStyle( fontSize: 18, fontWeight: FontWeight.w500, color: Colors.black54, ), ), SizedBox( width: 10, ), Image( image: AssetImage( 'assets/images/clock.png', ), ), ], ), ), SizedBox( height: 20, ), MaterialButton( onPressed: () {}, child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ Text( 'Watch', style: TextStyle( fontSize: 18, fontWeight: FontWeight.w500, color: Colors.black54, ), ), SizedBox( width: 10, ), Image( image: AssetImage( 'assets/images/television.png', ), ), ], ), ), SizedBox( height: 20, ), MaterialButton( onPressed: () {}, child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ Text( 'العناصر المحفوظة', style: TextStyle( fontSize: 18, fontWeight: FontWeight.w500, color: Colors.black54, ), ), SizedBox( width: 10, ), Image( image: AssetImage( 'assets/images/bookmark.png', ), ), ], ), ), SizedBox( height: 20, ), MaterialButton( onPressed: () {}, child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ Text( 'المفضلة', style: TextStyle( fontSize: 18, fontWeight: FontWeight.w500, color: Colors.black54, ), ), SizedBox( width: 10, ), Image( image: AssetImage( 'assets/images/favourite.png', ), ), ], ), ), SizedBox( height: 20, ), MaterialButton( onPressed: () {}, child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ Text( 'الصفحات', style: TextStyle( fontSize: 18, fontWeight: FontWeight.w500, color: Colors.black54, ), ), SizedBox( width: 10, ), Image( image: AssetImage( 'assets/images/flag.png', ), ), ], ), ), ], ), ), ), ], ), ); else return Container( color: Colors.grey[300], child: SingleChildScrollView( child: Column( children: [ //** part stories** Stack( children: [ Padding( padding: const EdgeInsets.all(20.0), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Expanded( child: Container( height: 160, child: Stack( children: [ Card( color: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), clipBehavior: Clip.antiAlias, child: Column( children: [ Expanded( flex: 2, child: Container( decoration: BoxDecoration( image: DecorationImage( image: NetworkImage( '${persons[0].story}'), fit: BoxFit.cover, )), ), ), ], ), ), Padding( padding: const EdgeInsets.all(10.0), child: Align( alignment: AlignmentDirectional.topEnd, child: Container( width: 40, height: 40, decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: Colors.blue, border: Border.all( color: primaryColor, width: 2.3, ), image: DecorationImage( image: NetworkImage( '${persons[0].url}', ), fit: BoxFit.cover), ), ), ), ), Align( alignment: AlignmentDirectional.bottomCenter, child: Padding( padding: const EdgeInsets.all(15.0), child: Text( '${persons[0].name}', maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( color: Colors.white, fontWeight: FontWeight.w500, ), ), ), ), ], ), ), ), Expanded( child: Container( height: 160, child: Stack( children: [ Card( color: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), clipBehavior: Clip.antiAlias, child: Column( children: [ Expanded( flex: 2, child: Container( decoration: BoxDecoration( image: DecorationImage( image: NetworkImage( '${persons[0].story}'), fit: BoxFit.cover, )), ), ), ], ), ), Padding( padding: const EdgeInsets.all(10.0), child: Align( alignment: AlignmentDirectional.topEnd, child: Container( width: 40, height: 40, decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: Colors.blue, border: Border.all( color: primaryColor, width: 2.3, ), image: DecorationImage( image: NetworkImage( '${persons[0].url}', ), fit: BoxFit.cover), ), ), ), ), Align( alignment: AlignmentDirectional.bottomCenter, child: Padding( padding: const EdgeInsets.all(15.0), child: Text( '${persons[0].name}', maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( color: Colors.white, fontWeight: FontWeight.w500, ), ), ), ), ], ), ), ), Expanded( child: Container( height: 160, child: Stack( alignment: AlignmentDirectional.bottomCenter, children: [ Card( color: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), clipBehavior: Clip.antiAlias, child: Column( children: [ Expanded( flex: 2, child: Container( decoration: BoxDecoration( image: DecorationImage( image: NetworkImage( '${persons[0].story}'), fit: BoxFit.cover, )), ), ), ], ), ), Padding( padding: const EdgeInsets.all(10.0), child: Align( alignment: AlignmentDirectional.topEnd, child: Container( width: 40, height: 40, decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: Colors.blue, border: Border.all( color: primaryColor, width: 2.3, ), image: DecorationImage( image: NetworkImage( '${persons[0].url}', ), fit: BoxFit.cover), ), ), ), ), Padding( padding: const EdgeInsets.all(15.0), child: Text( '${persons[0].name}', maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( color: Colors.white, fontWeight: FontWeight.w500, ), ), ), ], ), ), ), Expanded( child: Container( height: 160, child: Stack( alignment: AlignmentDirectional.bottomCenter, children: [ Card( color: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), clipBehavior: Clip.antiAlias, child: Column( children: [ Expanded( flex: 2, child: Container( decoration: BoxDecoration( image: DecorationImage( image: NetworkImage( '${persons[0].story}'), fit: BoxFit.cover, )), ), ), ], ), ), Padding( padding: const EdgeInsets.all(10.0), child: Align( alignment: AlignmentDirectional.topEnd, child: Container( width: 40, height: 40, decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: Colors.blue, border: Border.all( color: primaryColor, width: 2.3, ), image: DecorationImage( image: NetworkImage( '${persons[0].url}', ), fit: BoxFit.cover), ), ), ), ), Padding( padding: const EdgeInsets.all(15.0), child: Text( '${persons[0].name}', maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( color: Colors.white, fontWeight: FontWeight.w500, ), ), ), ], ), ), ), Expanded( child: Container( height: 160, child: Stack( alignment: AlignmentDirectional.bottomCenter, children: [ Card( color: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), clipBehavior: Clip.antiAlias, child: Column( children: [ Expanded( flex: 2, child: Container( decoration: BoxDecoration( image: DecorationImage( image: NetworkImage( '${persons[0].story}'), fit: BoxFit.cover, )), ), ), ], ), ), Padding( padding: const EdgeInsets.all(10.0), child: Align( alignment: AlignmentDirectional.topEnd, child: Container( width: 40, height: 40, decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: Colors.blue, border: Border.all( color: primaryColor, width: 2.3, ), image: DecorationImage( image: NetworkImage( '${persons[0].url}', ), fit: BoxFit.cover), ), ), ), ), Padding( padding: const EdgeInsets.all(15.0), child: Text( '${persons[0].name}', maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( color: Colors.white, fontWeight: FontWeight.w500, ), ), ), ], ), ), ), Expanded( child: Container( height: 160, child: Stack( alignment: AlignmentDirectional.bottomCenter, children: [ Card( color: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), clipBehavior: Clip.antiAlias, child: Column( children: [ Expanded( flex: 2, child: Container( decoration: BoxDecoration( image: DecorationImage( image: NetworkImage( 'https://images.unsplash.com/photo-1503023345310-bd7c1de61c7d?ixid=MnwxMjA3fDB8MHxzZWFyY2h8M3x8aHVtYW58ZW58MHx8MHx8&ixlib=rb-1.2.1&w=1000&q=80'), fit: BoxFit.cover, )), ), ), Expanded( child: Align( alignment: AlignmentDirectional .bottomCenter, child: Padding( padding: const EdgeInsets.all(3.0), child: Text( 'إنشاء قصة', style: TextStyle( fontWeight: FontWeight.w500, ), ), ), ), ), ], ), ), PositionedDirectional( top: Percent.widgetVerticalPosition( ratio: 50, heightChild: 40, heightParent: 200, ), child: Center( child: Container( width: 40, height: 40, decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: Colors.blue, border: Border.all( color: Colors.white, width: 2.3, ), ), child: Icon( Icons.add, color: Colors.white, size: 30, ), ), ), ), ], ), ), ), ], ), ), Positioned( top: 80, child: Container( width: 40, height: 40, decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: Colors.white, ), child: Icon( Icons.arrow_back, color: Colors.black54, size: 22, ), ), ), ], ), //** part 'what do you think' and [live, image, room] Padding( padding: const EdgeInsets.symmetric(horizontal: 15), child: Card( elevation: 5, color: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(9), ), child: Container( width: 550, height: 130, child: Column( children: [ Padding( padding: const EdgeInsets.symmetric( horizontal: 20, vertical: 15), child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( child: Container( margin: EdgeInsetsDirectional.only( top: 1.5, ), height: 38, decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: Colors.grey[300], ), child: Padding( padding: const EdgeInsets.symmetric( vertical: 5, horizontal: 20, ), child: Text( 'بم تفكر؟', textAlign: TextAlign.end, style: TextStyle( fontSize: 17, fontWeight: FontWeight.w500, color: Colors.black, ), ), ), ), ), SizedBox( width: 10, ), CircleAvatar( radius: 19, backgroundColor: Colors.blue, backgroundImage: NetworkImage( 'https://images.unsplash.com/photo-1503023345310-bd7c1de61c7d?ixid=MnwxMjA3fDB8MHxzZWFyY2h8M3x8aHVtYW58ZW58MHx8MHx8&ixlib=rb-1.2.1&w=1000&q=80', ), ), ], ), ), Padding( padding: const EdgeInsets.symmetric(horizontal: 20), child: Container( height: 0.5, width: double.infinity, color: Colors.grey, ), ), SizedBox( height: 15, ), Row( children: [ Expanded( child: MaterialButton( onPressed: () {}, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'غرفة', style: TextStyle( fontSize: 16, ), ), Icon( Icons.video_call, color: Colors.deepPurpleAccent, size: 22, ), ], ), ), ), Expanded( child: MaterialButton( onPressed: () {}, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'صورة', style: TextStyle( fontSize: 16, ), ), Icon( CustomIcons.gallery, color: Colors.lightGreen, size: 18, ), ], ), ), ), Expanded( child: MaterialButton( onPressed: () {}, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'بث مباشر', style: TextStyle( fontSize: 16, ), ), Icon( Icons.missed_video_call, color: Colors.pinkAccent, size: 22, ), ], ), ), ), ], ), ], ), ), ), ), //** part posts Padding( padding: const EdgeInsets.symmetric(horizontal: 15), child: Card( elevation: 5, color: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(9), ), child: Wrap( alignment: WrapAlignment.end, children: [ Container( padding: EdgeInsetsDirectional.only(end: 15.0), child: Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ Row( children: [ IconButton( padding: EdgeInsetsDirectional.zero, onPressed: () {}, icon: Icon( Icons.more_horiz_rounded, color: Colors.grey[700], ), ), Spacer(), Column( crossAxisAlignment: CrossAxisAlignment.end, mainAxisSize: MainAxisSize.min, children: [ Text( 'Sara Ahmed', style: TextStyle( fontWeight: FontWeight.bold, ), ), Row( children: [ Padding( padding: const EdgeInsets.symmetric( horizontal: 4.0), child: Icon( Icons.public_rounded, color: Colors.grey[700], size: 16, ), ), Text( 'أمس الساعة 9:13 م', style: TextStyle( fontSize: 12, ), ), ], ), ], ), Padding( padding: const EdgeInsetsDirectional.only( start: 15), child: Align( alignment: AlignmentDirectional.topEnd, child: Container( width: 40, height: 40, decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: Colors.blue, border: Border.all( color: primaryColor, width: 2.3, ), image: DecorationImage( image: NetworkImage( 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRmiipzUG3KoBS7uiWIx9M7Z-VUTdT0w-Cn-g&usqp=CAU', ), fit: BoxFit.cover), ), ), ), ), ], ), Text( 'الزمالك هذا الموسم \nبطل الدورى لكرة القدم\n بطل الدورى المصرى لكرة اليد\n بطل دورى السوبر المصري لكرة السلة \n', textDirection: TextDirection.rtl, style: TextStyle( fontWeight: FontWeight.w500, fontSize: 14, ), ), ], ), ), Image( image: NetworkImage( 'https://cdn.eso.org/images/thumb300y/eso1907a.jpg', ), ), Padding( padding: const EdgeInsets.all(12.0), child: Container( width: double.infinity, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Row( children: [ Text( '${arabicNumber.convert(4777)} مشاركة ', textDirection: TextDirection.rtl, style: TextStyle( color: Colors.grey, ), ), SizedBox( width: 5, ), Text( '${arabicNumber.convert(4777)} تعليقا ', textDirection: TextDirection.rtl, style: TextStyle( color: Colors.grey, ), ), Spacer(), Container( width: 85, child: Stack( children: [ Row( children: [ Text( '${arabicNumber.convert(43576)}', textDirection: TextDirection.rtl, style: TextStyle( color: Colors.grey, ), ), ], ), PositionedDirectional( end: 0, child: Container( height: 20, width: 20, decoration: BoxDecoration( border: Border.all( color: Colors.white, width: 1.5), borderRadius: BorderRadius.circular( 18)), child: SvgPicture.asset( 'assets/icons/facebook_love.svg', ), ), ), PositionedDirectional( end: 16, child: Container( height: 20, width: 20, decoration: BoxDecoration( border: Border.all( color: Colors.white, width: 1.5), borderRadius: BorderRadius.circular( 18)), child: SvgPicture.asset( 'assets/icons/care.svg', ), ), ), PositionedDirectional( end: 32, child: Container( height: 20, width: 20, decoration: BoxDecoration( border: Border.all( color: Colors.white, width: 1.5), borderRadius: BorderRadius.circular( 18)), child: SvgPicture.asset( 'assets/icons/facebook_like.svg', ), ), ), ], ), ), ], ), SizedBox( height: 15, ), Row( children: [ Expanded( child: Container( child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'مشاركة', style: TextStyle( color: Colors.grey, fontWeight: FontWeight.w600, ), ), Icon( CustomIcons .arrow_curved_to_the_left_svgrepo_com, color: Colors.grey, ), ], ), ), ), Expanded( child: Container( child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'تعليق', style: TextStyle( color: Colors.grey, fontWeight: FontWeight.w600, ), ), Icon( CustomIcons.comment_svgrepo_com, color: Colors.grey, ), ], ), ), ), Expanded( child: Container( child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'أعجبنى', style: TextStyle( color: Colors.grey, fontWeight: FontWeight.w600, ), ), SizedBox( width: 10, ), Icon( CustomIcons.like_svgrepo_com, color: Colors.grey, size: 20, ), ], ), ), ), ], ), ], ), ), ), ], ), ), ), ], ), ), ); }, ); } }
0
mirrored_repositories/facebook_flutter/lib/web/modul
mirrored_repositories/facebook_flutter/lib/web/modul/login/login_screen.dart
import 'package:conditional_builder_null_safety/conditional_builder_null_safety.dart'; import 'package:facebook/layout/home/home_screen.dart'; import 'package:facebook/modul/login/login_cubit/login_cubit.dart'; import 'package:facebook/modul/login/login_cubit/login_states.dart'; import 'package:facebook/modul/register/register_screen.dart'; import 'package:facebook/shared/components/component.dart'; import 'package:facebook/shared/style/color.dart'; import 'package:facebook/web/layout/app_layout.dart'; import 'package:facebook/web/widgets/widget.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:stack_percentage/stack_percentage.dart'; import 'dart:math'; class LoginScreenWeb extends StatefulWidget { @override State<LoginScreenWeb> createState() => _LoginScreenWebState(); } class _LoginScreenWebState extends State<LoginScreenWeb> { final TextEditingController emailController = TextEditingController(); final TextEditingController passwordController = TextEditingController(); final ScrollController scrollController = ScrollController(); @override void initState() { super.initState(); WidgetsBinding.instance!.addPostFrameCallback((_) { if (scrollController.hasClients) scrollController.jumpTo(50.0); }); } @override Widget build(BuildContext context) { return BlocConsumer<LoginCubit, LoginStates>( listener: (context, state) { if (state is LoginSuccessState) navigateAndFinish(context: context, widget: AppLayout()); }, builder: (context, states) { var loginCubit = LoginCubit.get(context); return LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { if (constraints.minWidth >= 900) return Scaffold( backgroundColor: Colors.grey[200], body: Padding( padding: EdgeInsetsDirectional.only( start: Percent.widgetHorizontalPosition( widthChild: constraints.minWidth, ratio: 10, widthParent: constraints.minWidth, ).abs().round() - 320, ), child: Row( children: [ SizedBox( height: double.infinity, ), Card( elevation: 10, child: Container( width: 400, height: 360, padding: EdgeInsetsDirectional.all(20), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10.0), color: Colors.white, ), clipBehavior: Clip.antiAlias, child: SingleChildScrollView( scrollDirection: Axis.vertical, child: Column( children: [ DefaultTextFormFieldWeb( hint: 'البريد الأكترونى أو الهاتف', controller: emailController, textInputType: TextInputType.emailAddress, ), SizedBox( height: 10.0, ), DefaultTextFormFieldWeb( hint: 'كلمة السر', controller: passwordController, textInputType: TextInputType.visiblePassword, ), SizedBox( height: 15.0, ), DefaultButtonWeb( onPressed: () { loginCubit.loginWithEmail( email: emailController.text, password: passwordController.text, ); }, text: 'تسجيل الدخول', height: 45, ), SizedBox( height: 15.0, ), TextButton( onPressed: () {}, child: Text( 'هل نسيت كلمة السر؟', style: TextStyle( color: primaryColor, ), ), ), SizedBox( height: 15.0, ), Row( children: [ Expanded( child: Container( height: 1, color: Colors.grey[300], ), ), ], ), SizedBox( height: 25.0, ), DefaultButtonWeb( onPressed: () {}, text: 'إنشاء حساب جديد', height: 45, width: 140, color: color2, ), ], ), ), ), ), Expanded( child: Container( child: SingleChildScrollView( scrollDirection: Axis.vertical, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( width: double.infinity, height: 30, ), Text( 'facebook', style: TextStyle( color: primaryColor, fontSize: 58, letterSpacing: -0.8, fontWeight: FontWeight.w900, ), ), SizedBox( height: 15, ), Text( 'يمنحك فيسبوك إمكانية التواصل مع الأشخاص \nومشاركة ماتريد معهم', textDirection: TextDirection.rtl, textAlign: TextAlign.center, style: TextStyle( color: Colors.black, fontSize: 22, fontWeight: FontWeight.w300, ), ), ], ), ), ), ), ], ), ), ); else return Scaffold( backgroundColor: Colors.grey[200], body: SingleChildScrollView( child: Column( children: [ SizedBox( width: double.infinity, height: 30, ), Text( 'facebook', style: TextStyle( color: primaryColor, fontSize: 58, letterSpacing: -0.8, fontWeight: FontWeight.w900, ), ), SizedBox( height: 15, ), Text( 'يمنحك فيسبوك إمكانية التواصل مع الأشخاص \nومشاركة ماتريد معهم', textDirection: TextDirection.rtl, textAlign: TextAlign.center, style: TextStyle( color: Colors.black, fontSize: 22, fontWeight: FontWeight.w300, ), ), SizedBox( height: 35, ), Card( elevation: 10, child: Container( width: 400, height: 360, padding: EdgeInsetsDirectional.all(20), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10.0), color: Colors.white, ), clipBehavior: Clip.antiAlias, child: Column( children: [ DefaultTextFormFieldWeb( hint: 'البريد الأكترونى أو الهاتف', controller: emailController, textInputType: TextInputType.emailAddress, ), SizedBox( height: 10.0, ), DefaultTextFormFieldWeb( hint: 'كلمة السر', controller: passwordController, textInputType: TextInputType.visiblePassword, ), SizedBox( height: 15.0, ), DefaultButtonWeb( onPressed: () { loginCubit.loginWithEmail( email: emailController.text, password: passwordController.text, ); }, text: 'تسجيل الدخول', height: 45, ), SizedBox( height: 15.0, ), TextButton( onPressed: () {}, child: Text( 'هل نسيت كلمة السر؟', style: TextStyle( color: primaryColor, ), ), ), SizedBox( height: 15.0, ), Row( children: [ Expanded( child: Container( height: 1, color: Colors.grey[300], ), ), ], ), SizedBox( height: 25.0, ), DefaultButtonWeb( onPressed: () {}, text: 'إنشاء حساب جديد', height: 45, width: 140, color: color2, ), ], ), ), ), SizedBox( height: 15, ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'لفرق موسيقية أو مشاهير أو أنشطة تجارية', textDirection: TextDirection.rtl, textAlign: TextAlign.center, style: TextStyle( color: Colors.black, fontSize: 12, ), ), TextButton( onPressed: () {}, child: Text( 'إنشاء صفحة', textDirection: TextDirection.rtl, textAlign: TextAlign.center, style: TextStyle( color: Colors.black, fontSize: 14, fontWeight: FontWeight.w800, ), ), ), ], ), SizedBox( height: 105, ), Container( width: double.infinity, height: 250, padding: EdgeInsetsDirectional.all(20), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10.0), color: Colors.white, ), clipBehavior: Clip.antiAlias, ), ], ), ), ); }, ); }, ); } @override void dispose() { super.dispose(); emailController.dispose(); passwordController.dispose(); scrollController.dispose(); } }
0
mirrored_repositories/facebook_flutter/lib/web
mirrored_repositories/facebook_flutter/lib/web/layout/app_layout.dart
import 'package:facebook/layout/home/home_cubit/home_cubit.dart'; import 'package:facebook/layout/home/home_cubit/home_states.dart'; import 'package:facebook/modul/home_page/home_page_screen.dart'; import 'package:facebook/shared/style/color.dart'; import 'package:facebook/shared/style/custom_icons_icons.dart'; import 'package:facebook/shared/style/icon_broken.dart'; import 'package:facebook/web/modul/home_page/home_page_screen.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_svg/flutter_svg.dart'; class AppLayout extends StatefulWidget { @override _AppLayoutState createState() => _AppLayoutState(); } class _AppLayoutState extends State<AppLayout> with SingleTickerProviderStateMixin { TabController? tabController; ScrollController? _scrollController; @override void initState() { super.initState(); tabController = TabController(vsync: this, length: 6, initialIndex: 5); _scrollController =ScrollController(); } @override Widget build(BuildContext context) { return BlocProvider( create: (context) { return HomeCubit(); }, child: BlocConsumer<HomeCubit, HomeStates>( listener: (context, state) {}, builder: (context, state) { return Scaffold( body: NestedScrollView( controller: _scrollController, floatHeaderSlivers: true, headerSliverBuilder: ( context, innerBoxIsScrolled){ return [ SliverAppBar( systemOverlayStyle: SystemUiOverlayStyle( statusBarColor: Colors.white, statusBarIconBrightness: Brightness.dark, ), backwardsCompatibility: false, title: Row( children: [ CircleAvatar( radius: 20, backgroundColor: Colors.grey[200], child: IconButton( onPressed: () {}, icon: Icon( CustomIcons.mess_icon, color: Colors.black, size: 20, ), ), ), SizedBox( width: 14.0, ), CircleAvatar( backgroundColor: Colors.grey[200], radius: 20, child: IconButton( onPressed: () {}, icon: Icon( IconBroken.Search, color: Colors.black, size: 20, ), ), ), ], ), actions: [ Padding( padding: const EdgeInsetsDirectional.only( end: 20.0, ), child: Center( child: Text( 'facebook', style: TextStyle( color: primaryColor, fontSize: 28, letterSpacing: -0.8, fontWeight: FontWeight.bold, ), ), ), ), ], pinned: true, floating: true, forceElevated: innerBoxIsScrolled, elevation: 0.0, backgroundColor: Colors.white, bottom: TabBar( unselectedLabelColor: Colors.grey, controller: tabController, labelColor: Colors.blue, labelPadding: EdgeInsets.symmetric(horizontal: 0.0), tabs: [ Tab( child: Icon( Icons.menu, ), ), Tab( child: Icon( CustomIcons.bell_noti, ), ), Tab( child: Icon( CustomIcons.store, ), ), Tab( child: Icon( CustomIcons.facebook, ), ), Tab( child: Icon( CustomIcons.group, ), ), Tab( child: Icon( IconBroken.Home, ), ), ], onTap: (value) {}, ), ), ]; }, body: TabBarView( controller: tabController, children: [ TextButton( onPressed: () {}, child: Text('hello'), ), TextButton( onPressed: () {}, child: Text('hello'), ), TextButton( onPressed: () {}, child: Text('hello'), ), TextButton( onPressed: () {}, child: Text('hello'), ), TextButton( onPressed: () {}, child: Text('hello'), ), HomePageScreenWeb(), ], ), ), ); }, ), ); } }
0
mirrored_repositories/facebook_flutter
mirrored_repositories/facebook_flutter/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility 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:facebook/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/Shop-App-UI-Design-in-Flutter
mirrored_repositories/Shop-App-UI-Design-in-Flutter/lib/main.dart
import 'package:flutter/material.dart'; import 'package:splash_screen_ui_design_in_flutter/screens/splash_screen.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: "Ecommerce Sopping", debugShowCheckedModeBanner: false, theme: ThemeData( primaryColor: Color(0xFFEF6969), ), home: SplashScreen(), ); } }
0
mirrored_repositories/Shop-App-UI-Design-in-Flutter/lib
mirrored_repositories/Shop-App-UI-Design-in-Flutter/lib/screens/onboarding_screen.dart
import 'package:flutter/material.dart'; import 'package:introduction_screen/introduction_screen.dart'; import 'package:splash_screen_ui_design_in_flutter/screens/home_screen.dart'; class OnboardingScreen extends StatelessWidget { final introKey = GlobalKey<IntroductionScreenState>(); @override Widget build(BuildContext context) { final pageDecoration = PageDecoration( titleTextStyle: TextStyle( fontSize: 28, fontWeight: FontWeight.w700, ), bodyTextStyle: TextStyle(fontSize: 19), bodyPadding: EdgeInsets.fromLTRB(16, 0, 16, 16), pageColor: Colors.white, imagePadding: EdgeInsets.zero, ); return IntroductionScreen( key: introKey, pages: [ PageViewModel( title: "Shop Now", body: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s", image: Image.asset( "assets/images/splash1.png", width: 200, ), decoration: pageDecoration, ), PageViewModel( title: "Big Discount", body: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s", image: Image.asset( "assets/images/splash2.png", width: 200, ), decoration: pageDecoration, ), PageViewModel( title: " Free Delivery", body: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s", image: Image.asset( "assets/images/splash3.png", width: 200, ), decoration: pageDecoration, footer: Padding( padding: EdgeInsets.only(left: 15, right: 15, top: 50), child: ElevatedButton( onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (context) => HomeScreen(), )); }, child: Text( "Let's a shop", style: TextStyle(fontSize: 18), ), style: ElevatedButton.styleFrom( minimumSize: Size.fromHeight(55), backgroundColor: Color(0xFEFFF6969)), ), ), ), ], showSkipButton: false, showDoneButton: false, showBackButton: true, back: Text( "Back", style: TextStyle(fontWeight: FontWeight.w600, color: Color(0xFEFFF6969)), ), next: Text( "Next", style: TextStyle(fontWeight: FontWeight.w600, color: Color(0xFEFFF6969)), ), onDone: () {}, onSkip: () {}, dotsDecorator: DotsDecorator( size: Size.square(10), activeSize: Size(20, 10), activeColor: Color(0xFEFFF6969), color: Colors.black26, spacing: EdgeInsets.symmetric(horizontal: 3), activeShape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(25), ), ), // Pass the page decoration to the IntroductionScreen ); } }
0
mirrored_repositories/Shop-App-UI-Design-in-Flutter/lib
mirrored_repositories/Shop-App-UI-Design-in-Flutter/lib/screens/home_screen.dart
import 'package:flutter/material.dart'; class HomeScreen extends StatelessWidget { const HomeScreen({super.key}); @override Widget build(BuildContext context) { return const Scaffold(); } }
0
mirrored_repositories/Shop-App-UI-Design-in-Flutter/lib
mirrored_repositories/Shop-App-UI-Design-in-Flutter/lib/screens/splash_screen.dart
import 'dart:async'; import 'package:flutter/material.dart'; import 'package:splash_screen_ui_design_in_flutter/screens/home_screen.dart'; import 'package:splash_screen_ui_design_in_flutter/screens/onboarding_screen.dart'; class SplashScreen extends StatefulWidget { const SplashScreen({super.key}); @override State<SplashScreen> createState() => _SplashScreenState(); } class _SplashScreenState extends State<SplashScreen> { @override void initState() { super.initState(); Timer( Duration(seconds: 3), () => Navigator.push( context, MaterialPageRoute( builder: (context) => OnboardingScreen(), ))); } @override Widget build(BuildContext context) { return Material( child: Container( height: MediaQuery.of(context).size.height, width: MediaQuery.of(context).size.width, decoration: BoxDecoration( color: Colors.black, image: DecorationImage( image: AssetImage("assets/images/image2.jpg"), fit: BoxFit.cover, opacity: 0.4, ), ), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( Icons.shopping_cart, size: 200, color: Color.fromARGB(255, 238, 80, 80), ), Text( "DP Shop", style: TextStyle( color: Colors.white, fontSize: 40, fontWeight: FontWeight.bold, fontStyle: FontStyle.italic), ), ], ), ), ); } }
0
mirrored_repositories/Shop-App-UI-Design-in-Flutter
mirrored_repositories/Shop-App-UI-Design-in-Flutter/test/widget_test.dart
0
mirrored_repositories/E_Wallet
mirrored_repositories/E_Wallet/lib/main.dart
import 'package:e_wallet/router/router_config.dart'; import 'package:flutter/material.dart'; void main() { runApp(const MainApp()); } class MainApp extends StatelessWidget { const MainApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp.router( debugShowCheckedModeBanner: false, routeInformationParser: router.routeInformationParser, routeInformationProvider: router.routeInformationProvider, routerDelegate: router.routerDelegate, theme: ThemeData(brightness: Brightness.dark), ); } }
0
mirrored_repositories/E_Wallet/lib/features
mirrored_repositories/E_Wallet/lib/features/statistics/statistics_screen.dart
import 'package:e_wallet/common/common_color.dart'; import 'package:e_wallet/common/common_textstyle.dart'; import 'package:e_wallet/features/statistics/screen/month_tab.dart'; import 'package:e_wallet/features/statistics/screen/week_tab.dart'; import 'package:e_wallet/features/statistics/screen/year_tab.dart'; import 'package:e_wallet/features/wallet/screen/card_tab.dart'; import 'package:flutter/material.dart'; class StatisticsScreen extends StatefulWidget { const StatisticsScreen({super.key}); @override State<StatisticsScreen> createState() => _StatisticsScreenState(); } class _StatisticsScreenState extends State<StatisticsScreen> with SingleTickerProviderStateMixin { late TabController controller; @override void initState() { // TODO: implement initState super.initState(); controller = TabController(length: 3, vsync: this); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: CommonColor().backgorund1, body: CustomScrollView(slivers: <Widget>[ SliverAppBar( actions: [ const SizedBox( width: 10, ), Image.asset( "assets/images/icons/Arrow - Left 2.png", scale: 0.8, ), SizedBox( width: 120, ), const Text( "Statistics", style: TextStyle( fontSize: 22, fontFamily: 'Poppins', fontWeight: FontWeight.w600, color: Colors.white), ), const Spacer(), const SizedBox( width: 10, ) ], backgroundColor: CommonColor().backgorund1, snap: true, floating: true, expandedHeight: 130.0, bottom: TabBar( unselectedLabelStyle: TextStyle(), padding: EdgeInsets.only(left: 10, right: 10), dividerHeight: 0, indicatorPadding: EdgeInsets.all(10), tabAlignment: TabAlignment.fill, indicatorSize: TabBarIndicatorSize.tab, labelStyle: CommonTextStyle().style1, indicatorWeight: 2, indicator: BoxDecoration( borderRadius: BorderRadius.circular(20), border: Border.all(color: CommonColor().shine), gradient: LinearGradient( colors: [CommonColor().backgorund1, CommonColor().shine]), ), tabs: [ const Tab(text: 'Week'), const Tab(text: 'Month'), const Tab(text: 'Year'), ], controller: controller, )), SliverFillRemaining( child: TabBarView( controller: controller, children: <Widget>[WeekTab(), MonthTab(), YearTab()], ), ), ]), ); } }
0
mirrored_repositories/E_Wallet/lib/features/statistics
mirrored_repositories/E_Wallet/lib/features/statistics/screen/week_tab.dart
import 'package:e_wallet/common/common_color.dart'; import 'package:e_wallet/common/common_textstyle.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; class WeekTab extends StatefulWidget { const WeekTab({super.key}); @override State<WeekTab> createState() => _WeekTabState(); } class _WeekTabState extends State<WeekTab> with SingleTickerProviderStateMixin { late TabController controller; @override void initState() { // TODO: implement initState super.initState(); controller = TabController(length: 2, vsync: this); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: CommonColor().backgorund1, body: Column(children: [ Padding( padding: const EdgeInsets.only(top: 35), child: Container( child: const Column( children: [ Text( "Total Spendings", style: TextStyle( fontSize: 18, fontFamily: 'Poppins', fontStyle: FontStyle.normal, color: Color(0xFF7B78AA)), ), Text( "\$3,660.00", style: TextStyle( fontSize: 25, fontFamily: 'Poppins', fontWeight: FontWeight.w600, color: Colors.white), ) ], ), ), ), const SizedBox( height: 75, ), Container( width: MediaQuery.sizeOf(context).width, height: MediaQuery.sizeOf(context).height * 0.5 + 5, decoration: BoxDecoration( color: CommonColor().backgorund1.withOpacity(0.9), border: Border.all(color: CommonColor().shine.withOpacity(0.2)), boxShadow: [ BoxShadow( color: CommonColor().shine, blurRadius: 70, blurStyle: BlurStyle.outer, spreadRadius: 3) ], borderRadius: const BorderRadius.only( topLeft: Radius.circular(30), topRight: Radius.circular(30))), child: CustomScrollView(slivers: <Widget>[ SliverAppBar( elevation: 0, titleSpacing: 0, forceMaterialTransparency: true, backgroundColor: CommonColor().backgorund1, bottom: PreferredSize( preferredSize: Size.zero, child: TabBar( indicatorColor: CommonColor().shine, indicatorSize: TabBarIndicatorSize.tab, labelStyle: CommonTextStyle().style1, tabs: [ Tab(text: 'Income'), const Tab(text: 'Outcome'), ], controller: controller, ), )), SliverFillRemaining( child: TabBarView( controller: controller, children: [Income(), Outcome()], ), ), ]), ) ])); } } class Income extends StatefulWidget { const Income({super.key}); @override State<Income> createState() => _IncomeState(); } class _IncomeState extends State<Income> { int selected = 0; List<String> days = ['Mon', 'Tue', 'Wen', 'Thus', "Fri", 'Sat', 'Sun']; @override Widget build(BuildContext context) { return Container( height: MediaQuery.sizeOf(context).height, width: MediaQuery.sizeOf(context).width, child: Stack( children: [ Positioned( top: 10, left: 20, child: Padding( padding: const EdgeInsets.only(right: 300, top: 10), child: Text( "Overview", style: TextStyle( fontSize: 18, fontFamily: 'Poppins', fontWeight: FontWeight.w600, color: Colors.white), ), ), ), Positioned( top: 50, bottom: 0, left: 0, right: 0, child: Image.asset( "assets/images/Statistics.png", scale: 0.5, ), ), Positioned( bottom: 1, child: SizedBox( height: 30, width: 400, child: ListView.builder( padding: EdgeInsets.symmetric( horizontal: 10, ), scrollDirection: Axis.horizontal, itemCount: days.length, itemBuilder: (context, index) { var data = days[index]; return Padding( padding: const EdgeInsets.only(right: 35), child: GestureDetector( onTap: () { setState(() { selected = index; }); }, child: AnimatedContainer( duration: Duration( milliseconds: 350, ), child: Text( data, style: TextStyle( fontSize: 13, fontFamily: 'Poppins', fontStyle: FontStyle.normal, color: index == selected ? CommonColor().shine : Color(0xFF7B78AA)), ), ), ), ); }, ), ), ) ], ), ); } } class Outcome extends StatefulWidget { const Outcome({super.key}); @override State<Outcome> createState() => _OutcomeState(); } class _OutcomeState extends State<Outcome> { int selected = 0; List<String> days = ['Mon', 'Tue', 'Wen', 'Thus', "Fri", 'Sat', 'Sun']; @override Widget build(BuildContext context) { return Container( height: MediaQuery.sizeOf(context).height, width: MediaQuery.sizeOf(context).width, child: Stack( children: [ Positioned( top: 10, left: 20, child: Padding( padding: const EdgeInsets.only(right: 300, top: 10), child: Text( "Overview", style: TextStyle( fontSize: 18, fontFamily: 'Poppins', fontWeight: FontWeight.w600, color: Colors.white), ), ), ), Positioned( top: 50, bottom: 0, left: 0, right: 0, child: Image.asset( "assets/images/Statistics.png", scale: 0.5, ), ), Positioned( bottom: 1, child: SizedBox( height: 30, width: 400, child: ListView.builder( padding: EdgeInsets.symmetric( horizontal: 10, ), scrollDirection: Axis.horizontal, itemCount: days.length, itemBuilder: (context, index) { var data = days[index]; return Padding( padding: const EdgeInsets.only(right: 35), child: GestureDetector( onTap: () { setState(() { selected = index; }); }, child: AnimatedContainer( duration: Duration( milliseconds: 350, ), child: Text( data, style: TextStyle( fontSize: 13, fontFamily: 'Poppins', fontStyle: FontStyle.normal, color: index == selected ? CommonColor().shine : Color(0xFF7B78AA)), ), ), ), ); }, ), ), ) ], ), ); } }
0
mirrored_repositories/E_Wallet/lib/features/statistics
mirrored_repositories/E_Wallet/lib/features/statistics/screen/year_tab.dart
import 'package:e_wallet/common/common_color.dart'; import 'package:e_wallet/common/common_textstyle.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; class YearTab extends StatefulWidget { const YearTab({super.key}); @override State<YearTab> createState() => _YearTabState(); } class _YearTabState extends State<YearTab> with SingleTickerProviderStateMixin { late TabController controller; @override void initState() { // TODO: implement initState super.initState(); controller = TabController(length: 2, vsync: this); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: CommonColor().backgorund1, body: Column(children: [ Padding( padding: const EdgeInsets.only(top: 35), child: Container( child: const Column( children: [ Text( "Total Spendings", style: TextStyle( fontSize: 18, fontFamily: 'Poppins', fontStyle: FontStyle.normal, color: Color(0xFF7B78AA)), ), Text( "\$125,280.00", style: TextStyle( fontSize: 25, fontFamily: 'Poppins', fontWeight: FontWeight.w600, color: Colors.white), ) ], ), ), ), const SizedBox( height: 75, ), Container( width: MediaQuery.sizeOf(context).width, height: MediaQuery.sizeOf(context).height * 0.5 + 5, decoration: BoxDecoration( color: CommonColor().backgorund1.withOpacity(0.9), border: Border.all(color: CommonColor().shine.withOpacity(0.2)), boxShadow: [ BoxShadow( color: CommonColor().shine, blurRadius: 70, blurStyle: BlurStyle.outer, spreadRadius: 3) ], borderRadius: const BorderRadius.only( topLeft: Radius.circular(30), topRight: Radius.circular(30))), child: CustomScrollView(slivers: <Widget>[ SliverAppBar( elevation: 0, titleSpacing: 0, forceMaterialTransparency: true, backgroundColor: CommonColor().backgorund1, bottom: PreferredSize( preferredSize: Size.zero, child: TabBar( indicatorColor: CommonColor().shine, indicatorSize: TabBarIndicatorSize.tab, labelStyle: CommonTextStyle().style1, tabs: [ Tab(text: 'Income'), const Tab(text: 'Outcome'), ], controller: controller, ), )), SliverFillRemaining( child: TabBarView( controller: controller, children: [Income(), Outcome()], ), ), ]), ) ])); } } class Income extends StatefulWidget { const Income({super.key}); @override State<Income> createState() => _IncomeState(); } class _IncomeState extends State<Income> { int selected = 0; List<String> days = ['Mon', 'Tue', 'Wen', 'Thus', "Fri", 'Sat', 'Sun']; @override Widget build(BuildContext context) { return Container( height: MediaQuery.sizeOf(context).height, width: MediaQuery.sizeOf(context).width, child: Stack( children: [ Positioned( top: 10, left: 20, child: Padding( padding: const EdgeInsets.only(right: 300, top: 10), child: Text( "Overview", style: TextStyle( fontSize: 18, fontFamily: 'Poppins', fontWeight: FontWeight.w600, color: Colors.white), ), ), ), Positioned( top: 50, bottom: 0, left: 0, right: 0, child: Image.asset( "assets/images/Statistics.png", scale: 0.5, ), ), Positioned( bottom: 1, child: SizedBox( height: 30, width: 400, child: ListView.builder( padding: EdgeInsets.symmetric( horizontal: 10, ), scrollDirection: Axis.horizontal, itemCount: days.length, itemBuilder: (context, index) { var data = days[index]; return Padding( padding: const EdgeInsets.only(right: 35), child: GestureDetector( onTap: () { setState(() { selected = index; }); }, child: AnimatedContainer( duration: Duration( milliseconds: 350, ), child: Text( data, style: TextStyle( fontSize: 13, fontFamily: 'Poppins', fontStyle: FontStyle.normal, color: index == selected ? CommonColor().shine : Color(0xFF7B78AA)), ), ), ), ); }, ), ), ) ], ), ); } } class Outcome extends StatefulWidget { const Outcome({super.key}); @override State<Outcome> createState() => _OutcomeState(); } class _OutcomeState extends State<Outcome> { int selected = 0; List<String> days = ['Mon', 'Tue', 'Wen', 'Thus', "Fri", 'Sat', 'Sun']; @override Widget build(BuildContext context) { return Container( height: MediaQuery.sizeOf(context).height, width: MediaQuery.sizeOf(context).width, child: Stack( children: [ Positioned( top: 10, left: 20, child: Padding( padding: const EdgeInsets.only(right: 300, top: 10), child: Text( "Overview", style: TextStyle( fontSize: 18, fontFamily: 'Poppins', fontWeight: FontWeight.w600, color: Colors.white), ), ), ), Positioned( top: 50, bottom: 0, left: 0, right: 0, child: Image.asset( "assets/images/Statistics.png", scale: 0.5, ), ), Positioned( bottom: 1, child: SizedBox( height: 30, width: 400, child: ListView.builder( padding: EdgeInsets.symmetric( horizontal: 10, ), scrollDirection: Axis.horizontal, itemCount: days.length, itemBuilder: (context, index) { var data = days[index]; return Padding( padding: const EdgeInsets.only(right: 35), child: GestureDetector( onTap: () { setState(() { selected = index; }); }, child: AnimatedContainer( duration: Duration( milliseconds: 350, ), child: Text( data, style: TextStyle( fontSize: 13, fontFamily: 'Poppins', fontStyle: FontStyle.normal, color: index == selected ? CommonColor().shine : Color(0xFF7B78AA)), ), ), ), ); }, ), ), ) ], ), ); } }
0
mirrored_repositories/E_Wallet/lib/features/statistics
mirrored_repositories/E_Wallet/lib/features/statistics/screen/month_tab.dart
import 'package:e_wallet/common/common_color.dart'; import 'package:e_wallet/common/common_textstyle.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; class MonthTab extends StatefulWidget { const MonthTab({super.key}); @override State<MonthTab> createState() => _MonthTabState(); } class _MonthTabState extends State<MonthTab> with SingleTickerProviderStateMixin { late TabController controller; @override void initState() { // TODO: implement initState super.initState(); controller = TabController(length: 2, vsync: this); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: CommonColor().backgorund1, body: Column(children: [ Padding( padding: const EdgeInsets.only(top: 35), child: Container( child: const Column( children: [ Text( "Total Spendings", style: TextStyle( fontSize: 18, fontFamily: 'Poppins', fontStyle: FontStyle.normal, color: Color(0xFF7B78AA)), ), Text( "\$10,650.00", style: TextStyle( fontSize: 25, fontFamily: 'Poppins', fontWeight: FontWeight.w600, color: Colors.white), ) ], ), ), ), const SizedBox( height: 75, ), Container( width: MediaQuery.sizeOf(context).width, height: MediaQuery.sizeOf(context).height * 0.5 + 5, decoration: BoxDecoration( color: CommonColor().backgorund1.withOpacity(0.9), border: Border.all(color: CommonColor().shine.withOpacity(0.2)), boxShadow: [ BoxShadow( color: CommonColor().shine, blurRadius: 70, blurStyle: BlurStyle.outer, spreadRadius: 3) ], borderRadius: const BorderRadius.only( topLeft: Radius.circular(30), topRight: Radius.circular(30))), child: CustomScrollView(slivers: <Widget>[ SliverAppBar( elevation: 0, titleSpacing: 0, forceMaterialTransparency: true, backgroundColor: CommonColor().backgorund1, bottom: PreferredSize( preferredSize: Size.zero, child: TabBar( indicatorColor: CommonColor().shine, indicatorSize: TabBarIndicatorSize.tab, labelStyle: CommonTextStyle().style1, tabs: [ Tab(text: 'Income'), const Tab(text: 'Outcome'), ], controller: controller, ), )), SliverFillRemaining( child: TabBarView( controller: controller, children: [Income(), Outcome()], ), ), ]), ) ])); } } class Income extends StatefulWidget { const Income({super.key}); @override State<Income> createState() => _IncomeState(); } class _IncomeState extends State<Income> { int selected = 0; List<String> days = ['Mon', 'Tue', 'Wen', 'Thus', "Fri", 'Sat', 'Sun']; @override Widget build(BuildContext context) { return Container( height: MediaQuery.sizeOf(context).height, width: MediaQuery.sizeOf(context).width, child: Stack( children: [ Positioned( top: 10, left: 20, child: Padding( padding: const EdgeInsets.only(right: 300, top: 10), child: Text( "Overview", style: TextStyle( fontSize: 18, fontFamily: 'Poppins', fontWeight: FontWeight.w600, color: Colors.white), ), ), ), Positioned( top: 50, bottom: 0, left: 0, right: 0, child: Image.asset( "assets/images/Statistics.png", scale: 0.5, ), ), Positioned( bottom: 1, child: SizedBox( height: 30, width: 400, child: ListView.builder( padding: EdgeInsets.symmetric( horizontal: 10, ), scrollDirection: Axis.horizontal, itemCount: days.length, itemBuilder: (context, index) { var data = days[index]; return Padding( padding: const EdgeInsets.only(right: 35), child: GestureDetector( onTap: () { setState(() { selected = index; }); }, child: AnimatedContainer( duration: Duration( milliseconds: 350, ), child: Text( data, style: TextStyle( fontSize: 13, fontFamily: 'Poppins', fontStyle: FontStyle.normal, color: index == selected ? CommonColor().shine : Color(0xFF7B78AA)), ), ), ), ); }, ), ), ) ], ), ); } } class Outcome extends StatefulWidget { const Outcome({super.key}); @override State<Outcome> createState() => _OutcomeState(); } class _OutcomeState extends State<Outcome> { int selected = 0; List<String> days = ['Mon', 'Tue', 'Wen', 'Thus', "Fri", 'Sat', 'Sun']; @override Widget build(BuildContext context) { return Container( height: MediaQuery.sizeOf(context).height, width: MediaQuery.sizeOf(context).width, child: Stack( children: [ Positioned( top: 10, left: 20, child: Padding( padding: const EdgeInsets.only(right: 300, top: 10), child: Text( "Overview", style: TextStyle( fontSize: 18, fontFamily: 'Poppins', fontWeight: FontWeight.w600, color: Colors.white), ), ), ), Positioned( top: 50, bottom: 0, left: 0, right: 0, child: Image.asset( "assets/images/Statistics.png", scale: 0.5, ), ), Positioned( bottom: 1, child: SizedBox( height: 30, width: 400, child: ListView.builder( padding: EdgeInsets.symmetric( horizontal: 10, ), scrollDirection: Axis.horizontal, itemCount: days.length, itemBuilder: (context, index) { var data = days[index]; return Padding( padding: const EdgeInsets.only(right: 35), child: GestureDetector( onTap: () { setState(() { selected = index; }); }, child: AnimatedContainer( duration: Duration( milliseconds: 350, ), child: Text( data, style: TextStyle( fontSize: 13, fontFamily: 'Poppins', fontStyle: FontStyle.normal, color: index == selected ? CommonColor().shine : Color(0xFF7B78AA)), ), ), ), ); }, ), ), ) ], ), ); } }
0
mirrored_repositories/E_Wallet/lib/features/account
mirrored_repositories/E_Wallet/lib/features/account/screen/account_screen.dart
import 'package:e_wallet/common/common_color.dart'; import 'package:e_wallet/common/common_textstyle.dart'; import 'package:e_wallet/features/wallet/screen/CustomAccountCard.dart'; import 'package:flutter/material.dart'; class AccountScreen extends StatelessWidget { const AccountScreen({super.key}); @override Widget build(BuildContext context) { return Scaffold( backgroundColor: CommonColor().backgorund1, body: Column( children: [ SizedBox( height: 80, ), Row( children: [ const SizedBox( width: 10, ), Image.asset( "assets/images/icons/Arrow - Left 2.png", scale: 0.8, ), SizedBox( width: 120, ), const Text( "Account", style: TextStyle( fontSize: 23, fontFamily: 'Poppins', fontWeight: FontWeight.w600, color: Colors.white), ), const Spacer(), const SizedBox( width: 10, ) ], ), SizedBox( height: 50, ), Container( height: 200, width: 200, clipBehavior: Clip.antiAlias, decoration: BoxDecoration( shape: BoxShape.circle, border: Border.all(color: CommonColor().shine)), child: Image.asset( "assets/images/girl_profile.jpeg", scale: 1, fit: BoxFit.cover, ), ), SizedBox( height: 20, ), Text( "Aditi Sharma", style: TextStyle( fontSize: 23, fontFamily: 'Poppins', fontWeight: FontWeight.w600, color: Colors.white), ), Padding( padding: const EdgeInsets.only(left: 150, top: 10), child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( "Card limit : ", style: TextStyle( fontSize: 13, fontFamily: 'Poppins', fontStyle: FontStyle.normal, color: Color(0xFF7B78AA)), ), Text( "\$ 10000", style: TextStyle( fontSize: 13, fontFamily: 'Poppins', fontWeight: FontWeight.bold, fontStyle: FontStyle.normal, color: Colors.white), ), ], ), ), SizedBox( height: 30, ), CustomAccountCard( image: "assets/images/girl_profile.jpeg", name: "Aditi Sharma", value: true), CustomAccountCard( image: "assets/images/Ellipse 249.png", name: "Sandy Chungus", value: false), CustomAccountCard( image: "assets/images/actress1.jpeg", name: "Gautam Yadav", value: false), CustomAccountCard( image: "assets/images/WhatsApp Image 2023-10-16 at 9.47.48 PM.jpeg", name: "Aditya Chauhan", value: false), ], )); } }
0
mirrored_repositories/E_Wallet/lib/features/home
mirrored_repositories/E_Wallet/lib/features/home/model/transaction_model.dart
// ignore_for_file: public_member_api_docs, sort_constructors_first class TransactionModel { String image; String name; String date; String ammount; TransactionModel({ required this.image, required this.name, required this.date, required this.ammount, }); }
0
mirrored_repositories/E_Wallet/lib/features/home
mirrored_repositories/E_Wallet/lib/features/home/screen/home_screen.dart
import 'package:e_wallet/common/common_color.dart'; import 'package:e_wallet/common/common_textstyle.dart'; import 'package:e_wallet/features/home/model/transaction_model.dart'; import 'package:e_wallet/features/home/widget/card.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; class HomeScreen extends StatefulWidget { const HomeScreen({super.key}); @override State<HomeScreen> createState() => _HomeScreenState(); } class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateMixin { late AnimationController _controller; late Animation<double> _animation; @override void initState() { super.initState(); _controller = AnimationController( vsync: this, duration: const Duration(seconds: 10), ); _animation = Tween<double>(begin: 1, end: 0).animate(_controller); _controller.addListener(() { if (mounted && context.mounted) { setState(() {}); } }); WidgetsBinding.instance.addPostFrameCallback((timeStamp) { _controller.repeat(); }); } @override void dispose() { _controller.dispose(); // Dispose of the AnimationController properly. super.dispose(); } @override Widget build(BuildContext context) { List<TransactionModel> list = [ TransactionModel( image: "assets/images/Amazon.png", name: "Amazon", date: "May 24,2022", ammount: "-\$103.56"), TransactionModel( image: "assets/images/Logo.png", name: "Mcdonalds", date: "May 12,2022", ammount: "-\$34.16"), TransactionModel( image: "assets/images/Logo 3.png", name: "Apple ", date: "May 8,2022", ammount: "-\$1000.92"), TransactionModel( image: "assets/images/Logo 2.png", name: "Starbucks", date: "May 5,2022", ammount: "-\$1200.18"), TransactionModel( image: "assets/images/Logo 4.png", name: "Mastercard", date: "May 3,2022", ammount: "-\$1000.56"), TransactionModel( image: "assets/images/briefcase.png", name: "Freelancer", date: "May 1,2022", ammount: "-\$3300.81"), ]; return Scaffold( backgroundColor: CommonColor().backgorund1, body: SingleChildScrollView( child: Column( children: [ const SizedBox( height: 50, ), Padding( padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 20), child: Row( children: [ Image.asset("assets/images/Ellipse 249.png"), const SizedBox( width: 20, ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "Welcome Back!", style: CommonTextStyle().style1, ), Text( "Sandy Chungus", style: CommonTextStyle().style2, ), ], ), const Spacer(), InkWell( onTap: () { print("object"); }, splashColor: CommonColor().background2, borderRadius: BorderRadius.circular(100), child: Image.asset( "assets/images/icons/Huge-icon.png", scale: 0.8, ), ), const SizedBox( width: 10, ), InkWell( onTap: () { print("object"); }, splashColor: CommonColor().background2, borderRadius: BorderRadius.circular(100), child: Image.asset( "assets/images/icons/More_Vertical.png", scale: 0.8, ), ), ], ), ), Container( height: MediaQuery.sizeOf(context).height, width: MediaQuery.sizeOf(context).width, child: Stack( children: [ Positioned( top: 110, left: 10, right: 10, child: Column( children: [ const Text( "\$5,643.50", style: TextStyle( fontSize: 20, fontFamily: 'Poppins', fontWeight: FontWeight.w600, color: Colors.white), ), Text( "Available balance", style: CommonTextStyle().style2, ) ], ), ), Positioned( top: 10, left: 90, right: 80, child: AnimatedRotation( turns: _animation.value, duration: Duration(milliseconds: 0), child: Image.asset( "assets/images/Balance.png", scale: 0.8, ), )), Positioned( top: 200, left: 0, right: 0, child: Image.asset( "assets/images/Base.png", scale: 0.9, ), ), const Positioned( top: 310, left: 10, child: Text( "My Transaction", style: TextStyle( fontSize: 15, fontFamily: 'Poppins', fontWeight: FontWeight.w600, color: Colors.white), ), ), const Positioned( top: 310, right: 10, child: Text( "This Month", style: TextStyle( fontSize: 15, fontFamily: 'Poppins', fontWeight: FontWeight.w600, color: Colors.white), ), ), Positioned( top: 350, child: Container( height: 400, width: 430, decoration: BoxDecoration( color: CommonColor().bluebg, borderRadius: BorderRadius.circular(10), // Add a border radius ), child: ListView.builder( physics: RangeMaintainingScrollPhysics(), itemCount: list.length, itemBuilder: (context, index) { var data = list[index]; return CupertinoContextMenu( actions: [ CupertinoContextMenuAction( onPressed: () { GoRouter.of(context).pop(); }, child: Text( "View Deatils", style: TextStyle( fontSize: 16, fontFamily: 'Poppins', fontWeight: FontWeight.w400, color: Colors.black), )), CupertinoContextMenuAction( onPressed: () { GoRouter.of(context).pop(); }, child: Text( "Back", style: TextStyle( fontSize: 16, fontFamily: 'Poppins', fontWeight: FontWeight.w400, color: Colors.black), )) ], child: Padding( padding: const EdgeInsets.only( left: 15, right: 15, top: 10), child: CustomCard( image: data.image, name: data.name, date: data.date, ammount: data.ammount, ), ), ); }, ), ), ) ], ), ) ], ), )); } }
0
mirrored_repositories/E_Wallet/lib/features/home
mirrored_repositories/E_Wallet/lib/features/home/widget/card.dart
// ignore_for_file: public_member_api_docs, sort_constructors_first import 'package:e_wallet/common/common_color.dart'; import 'package:e_wallet/common/common_textstyle.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class CustomCard extends StatelessWidget { const CustomCard({ Key? key, required this.image, required this.name, required this.date, required this.ammount, }) : super(key: key); final String image; final String name; final String date; final String ammount; @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 30), child: ClipRRect( // borderRadius: BorderRadius.circular(60), child: CupertinoContextMenu( enableHapticFeedback: true, actions: const [ CupertinoContextMenuAction(child: Text("Ok")), CupertinoContextMenuAction(child: Text("")), CupertinoContextMenuAction(child: Text("Ok")), CupertinoContextMenuAction(child: Text("Ok")), ], child: Material( color: Colors.transparent, child: Container( height: 80, width: 350, decoration: BoxDecoration( color: CommonColor().backgorund1, border: Border.all(color: const Color(0xFF19173D)), // borderRadius: BorderRadius.circular(60), ), child: Row( children: [ const SizedBox( width: 20, ), Image.asset(image), const SizedBox( width: 20, ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Spacer(), Text( name, style: CommonTextStyle().style1, ), const SizedBox( height: 2, ), Text( date, style: CommonTextStyle().style2, ), const Spacer() ], ), const Spacer(), Container( height: 44, width: 90, decoration: BoxDecoration( border: Border.all(color: CommonColor().bluebg), boxShadow: [ BoxShadow( color: Colors.grey.shade50, spreadRadius: 0.1, blurRadius: 0.4) ], borderRadius: BorderRadius.circular(60), color: CommonColor().backgorund1), child: Center( child: FittedBox( child: Text( ammount, style: CommonTextStyle().style1, ), ), ), ), const SizedBox( width: 15, ) ], ), ), ), ), ), ); } }
0
mirrored_repositories/E_Wallet/lib/features
mirrored_repositories/E_Wallet/lib/features/wallet/wallet_page.dart
import 'package:e_wallet/common/common_color.dart'; import 'package:e_wallet/common/common_textstyle.dart'; import 'package:e_wallet/features/wallet/screen/account.dart'; import 'package:e_wallet/features/wallet/screen/card_tab.dart'; import 'package:flutter/material.dart'; class WalletScreen extends StatefulWidget { const WalletScreen({super.key}); @override State<WalletScreen> createState() => _WalletScreenState(); } class _WalletScreenState extends State<WalletScreen> with SingleTickerProviderStateMixin { late TabController controller; @override void initState() { // TODO: implement initState super.initState(); controller = TabController(length: 2, vsync: this); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: CommonColor().backgorund1, body: CustomScrollView(slivers: <Widget>[ SliverAppBar( actions: [ const SizedBox( width: 10, ), Image.asset( "assets/images/icons/Arrow - Left 2.png", scale: 0.8, ), const Spacer(), const Text( "Wallet", style: TextStyle( fontSize: 20, fontFamily: 'Poppins', fontWeight: FontWeight.w600, color: Colors.white), ), const Spacer(), Image.asset( "assets/images/icons/More_Vertical.png", scale: 0.8, ), const SizedBox( width: 10, ) ], backgroundColor: CommonColor().backgorund1, // pinned: true, snap: true, floating: true, expandedHeight: 130.0, bottom: TabBar( indicatorColor: CommonColor().shine, indicatorSize: TabBarIndicatorSize.tab, labelStyle: CommonTextStyle().style1, tabs: [ Tab(text: 'Cards'), const Tab(text: 'Account'), ], controller: controller, )), SliverFillRemaining( child: TabBarView( controller: controller, children: <Widget>[CardTab(), AccountTab()], ), ), ]), ); } }
0
mirrored_repositories/E_Wallet/lib/features/wallet
mirrored_repositories/E_Wallet/lib/features/wallet/Model/card_model.dart
// ignore_for_file: public_member_api_docs, sort_constructors_first class CardModel { String number; String validupto; String name; CardModel({ required this.number, required this.validupto, required this.name, }); }
0
mirrored_repositories/E_Wallet/lib/features/wallet
mirrored_repositories/E_Wallet/lib/features/wallet/screen/account.dart
import 'package:e_wallet/common/common_color.dart'; import 'package:e_wallet/features/home/widget/card.dart'; import 'package:e_wallet/features/wallet/screen/CustomAccountCard.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class AccountTab extends StatefulWidget { const AccountTab({super.key}); @override State<AccountTab> createState() => _AccountTabState(); } class _AccountTabState extends State<AccountTab> { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: CommonColor().backgorund1, body: Center( child: Column( children: [ SizedBox( height: 10, ), CustomAccountCard( image: "assets/images/girl_profile.jpeg", name: "Aditi Sharma", value: true), CustomAccountCard( image: "assets/images/Ellipse 249.png", name: "Sandy Chungus", value: false), CustomAccountCard( image: "assets/images/actress1.jpeg", name: "Gautam Yadav", value: false), CustomAccountCard( image: "assets/images/WhatsApp Image 2023-10-16 at 9.47.48 PM.jpeg", name: "Aditya Chauhan", value: false), ], ), ), ); } }
0
mirrored_repositories/E_Wallet/lib/features/wallet
mirrored_repositories/E_Wallet/lib/features/wallet/screen/CustomAccountCard.dart
// ignore_for_file: public_member_api_docs, sort_constructors_first import 'package:e_wallet/common/common_color.dart'; import 'package:e_wallet/common/common_textstyle.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class CustomAccountCard extends StatefulWidget { const CustomAccountCard({ Key? key, required this.image, required this.name, required this.value, }) : super(key: key); final String image; final String name; final bool value; @override State<CustomAccountCard> createState() => _CustomAccountCardState(); } class _CustomAccountCardState extends State<CustomAccountCard> { @override Widget build(BuildContext context) { return Container( height: 80, width: 400, decoration: BoxDecoration( color: CommonColor().backgorund1, border: Border.all(color: Color(0xFF19173D)), borderRadius: BorderRadius.circular(60)), child: Row( children: [ SizedBox( width: 20, ), // Image.asset(widget.image), CircleAvatar( backgroundImage: AssetImage(widget.image), ), SizedBox( width: 20, ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Spacer(), Text( widget.name, style: CommonTextStyle().style1, ), SizedBox( height: 2, ), Spacer() ], ), Spacer(), Container( height: 44, width: 90, decoration: BoxDecoration( // boxShadow: [ // BoxShadow( // color: Colors.grey.shade50, // spreadRadius: 0.1, // blurRadius: 0.4) // ], borderRadius: BorderRadius.circular(60), color: CommonColor().backgorund1), child: Center( child: CupertinoSwitch( activeColor: CommonColor().shine, trackColor: CommonColor().background2, value: widget.value, onChanged: (value) { setState(() { value = false; }); }, ), ), ), SizedBox( width: 15, ) ], ), ); } }
0
mirrored_repositories/E_Wallet/lib/features/wallet
mirrored_repositories/E_Wallet/lib/features/wallet/screen/card_tab.dart
// ignore_for_file: public_member_api_docs, sort_constructors_first import 'package:card_swiper/card_swiper.dart'; import 'package:e_wallet/common/common_textstyle.dart'; import 'package:flutter/material.dart'; import 'package:e_wallet/common/common_color.dart'; import 'package:e_wallet/features/wallet/Model/card_model.dart'; class CardTab extends StatefulWidget { const CardTab({super.key}); @override State<CardTab> createState() => _CardTabState(); } class _CardTabState extends State<CardTab> { List<CardModel> cardlist = [ CardModel( number: "5000 0000 0000 1000", validupto: "12/26", name: "Aditya"), CardModel(number: "5000 2002 0000 0000", validupto: "02/25", name: "Aditi"), CardModel( number: "5000 4004 0000 9000", validupto: "06/28", name: "Gautam"), ]; @override Widget build(BuildContext context) { return Scaffold( backgroundColor: CommonColor().backgorund1, body: Padding( padding: const EdgeInsets.all(10.0), child: Column( children: [ SizedBox( height: 300, width: 400, child: SizedBox( child: LayoutBuilder( builder: (context, constraints) { return Swiper( axisDirection: AxisDirection.left, physics: const ClampingScrollPhysics(), autoplayDisableOnInteraction: true, layout: SwiperLayout.STACK, duration: Duration.microsecondsPerMillisecond, // autoplayDelay: Duration.secondsPerDay, autoplay: true, allowImplicitScrolling: true, itemWidth: 350, itemHeight: 220, itemCount: cardlist.length, scrollDirection: Axis.horizontal, itemBuilder: (context, index) { var data = cardlist[index]; return CreditCard( name: data.name, number: data.number, validupto: data.validupto, ); }, // pagination: const DotSwiperPaginationBuilder(space: 10), ); }, ), ), ), Padding( padding: const EdgeInsets.only(left: 10, right: 10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Image.asset( "assets/images/glass icon 1.png", scale: 1, ), Image.asset("assets/images/glass icon 2.png"), Image.asset("assets/images/3.png"), Image.asset("assets/images/4.png"), ], ), ), const SizedBox( height: 20, ), Flexible( child: Container( height: 330, width: 420, decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ CommonColor().backgorund1, CommonColor().shine.withOpacity(0.3) ]), borderRadius: BorderRadius.circular(20), border: Border.all( color: CommonColor().shine.withOpacity(0.3))), child: SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ Row( children: [ Image.asset( "assets/images/icons/Huge-icon-1.png", scale: 0.7, ), const Text( "Add Card", style: TextStyle( fontSize: 18, fontFamily: 'Poppins', fontWeight: FontWeight.w600, color: Colors.white), ) ], ), const Padding( padding: EdgeInsets.only(right: 120), child: Text( "Add your debit/credit card", style: TextStyle( fontSize: 15, fontFamily: 'Poppins', fontStyle: FontStyle.normal, color: Color(0xFF7B78AA)), ), ), Padding( padding: const EdgeInsets.only( right: 15, left: 15, top: 10), child: Column( children: [ TextFormField( decoration: InputDecoration( border: OutlineInputBorder( borderRadius: BorderRadius.circular(50), borderSide: BorderSide( color: CommonColor().shine)), contentPadding: const EdgeInsets.only( left: 20, right: 10, top: 3, bottom: 3), hintFadeDuration: const Duration(milliseconds: 1000), hintText: "Card Number", hintStyle: CommonTextStyle().style2, hoverColor: CommonColor().shine.withOpacity(0.3)), ), const SizedBox( height: 10, ), TextFormField( decoration: InputDecoration( border: OutlineInputBorder( borderRadius: BorderRadius.circular(50), borderSide: BorderSide( color: CommonColor().shine)), contentPadding: const EdgeInsets.only( left: 20, right: 10, top: 3, bottom: 3), hintFadeDuration: const Duration(milliseconds: 1000), hintText: "Card holder name", hintStyle: CommonTextStyle().style2, hoverColor: CommonColor().shine.withOpacity(0.3)), ), const SizedBox( height: 10, ), Row( children: [ SizedBox( width: 180, child: TextFormField( decoration: InputDecoration( border: OutlineInputBorder( borderRadius: BorderRadius.circular(50), borderSide: BorderSide( color: CommonColor().shine)), contentPadding: const EdgeInsets.only( left: 20, right: 10, top: 3, bottom: 3), hintFadeDuration: const Duration( milliseconds: 1000), hintText: "Expiration Date", hintStyle: CommonTextStyle().style2, hoverColor: CommonColor() .shine .withOpacity(0.3)), ), ), const SizedBox( width: 10, ), SizedBox( width: 170, child: TextFormField( decoration: InputDecoration( border: OutlineInputBorder( borderRadius: BorderRadius.circular(50), borderSide: BorderSide( color: CommonColor().shine)), contentPadding: const EdgeInsets.only( left: 20, right: 10, top: 3, bottom: 3), hintFadeDuration: const Duration( milliseconds: 1000), hintText: "Security Code", hintStyle: CommonTextStyle().style2, hoverColor: CommonColor() .shine .withOpacity(0.3)), ), ), ], ), const SizedBox( height: 20, ), Container( height: 44, width: 138, decoration: BoxDecoration( borderRadius: BorderRadius.circular(30), gradient: const LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ Color(0xFF0DA6C2), Color(0xFF0E39C6) ])), child: const Center( child: Text( "Next", style: TextStyle( fontSize: 15, fontFamily: 'Poppins', fontWeight: FontWeight.w600, color: Colors.white), ), ), ) ], ), ), ], ), ), ), ), ) ], ), ), ); } } class CreditCard extends StatelessWidget { String number; String validupto; String name; CreditCard({ Key? key, required this.number, required this.validupto, required this.name, }) : super(key: key); @override Widget build(BuildContext context) { List<Color> colorlist1 = [const Color(0xFF320DAF)]; List<Color> colorlist2 = [const Color(0xFF9327F0)]; return Container( decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ colorlist2[0], colorlist1[0], ]), borderRadius: BorderRadius.circular(20)), child: Column(children: [ Padding( padding: const EdgeInsets.only(top: 60, left: 50), child: Row( children: [ Image.asset( "assets/images/EMV Chip.png", scale: 0.8, ), const SizedBox( width: 5, ), Image.asset("assets/images/Contactless Indicator.png") ], ), ), Padding( padding: const EdgeInsets.only(top: 5, right: 40), child: Text( number, style: const TextStyle( fontSize: 20, fontFamily: 'Poppins', fontWeight: FontWeight.w600, color: Colors.white), ), ), Padding( padding: const EdgeInsets.only(left: 100), child: Row( children: [ const Text( "Valid\nThiru", style: TextStyle( fontSize: 8, fontFamily: 'Poppins', fontWeight: FontWeight.w600, color: Colors.white), ), const SizedBox( width: 5, ), Text( validupto, style: const TextStyle( fontSize: 18, fontFamily: 'Poppins', fontWeight: FontWeight.w600, color: Colors.white), ) ], ), ), Padding( padding: const EdgeInsets.only(top: 10, right: 15, left: 15, bottom: 10), child: Row( children: [ Text( name, style: const TextStyle( fontSize: 15, fontFamily: 'Poppins', fontWeight: FontWeight.w600, color: Colors.white), ), const Spacer(), Image.asset( "assets/images/Payment System Logo.png", scale: 1.5, ) ], ), ) ]), ); } }
0
mirrored_repositories/E_Wallet/lib
mirrored_repositories/E_Wallet/lib/router/router_config.dart
import 'package:flutter/cupertino.dart'; import 'package:go_router/go_router.dart'; import 'package:e_wallet/features/account/screen/account_screen.dart'; import 'package:e_wallet/features/home/screen/home_screen.dart'; import 'package:e_wallet/features/statistics/statistics_screen.dart'; import 'package:e_wallet/features/wallet/wallet_page.dart'; import 'package:e_wallet/router/router.dart'; import 'package:e_wallet/screen/navigation.dart'; final _rootNavigatorKey = GlobalKey<NavigatorState>(); final _shellNavigatorKey = GlobalKey<NavigatorState>(); final router = GoRouter( navigatorKey: _rootNavigatorKey, initialLocation: Routes.homescreen.path, routes: [ ShellRoute( parentNavigatorKey: _rootNavigatorKey, navigatorKey: _shellNavigatorKey, pageBuilder: (context, state, child) { int index = 0; if (state.fullPath == Routes.homescreen.path) { index = 0; } else if (state.fullPath == Routes.wallet.path) { index = 1; } else if (state.fullPath == Routes.account.path) { index = 2; } else if (state.fullPath == Routes.statisticsscreen.path) { index = 3; } return CupertinoPage( child: NavigationScreen( selectedIndex: index, child: child, ), ); }, routes: [ GoRoute( parentNavigatorKey: _shellNavigatorKey, path: Routes.homescreen.path, name: Routes.homescreen.name, pageBuilder: (context, state) { return const CupertinoPage(child: HomeScreen()); }, ), GoRoute( parentNavigatorKey: _shellNavigatorKey, path: Routes.wallet.path, name: Routes.wallet.name, pageBuilder: (context, state) { return const CupertinoPage(child: WalletScreen()); }, ), GoRoute( parentNavigatorKey: _shellNavigatorKey, path: Routes.account.path, name: Routes.account.name, pageBuilder: (context, state) { return const CupertinoPage(child: AccountScreen()); }, ), GoRoute( parentNavigatorKey: _shellNavigatorKey, path: Routes.statisticsscreen.path, name: Routes.statisticsscreen.name, pageBuilder: (context, state) { return const CupertinoPage(child: StatisticsScreen()); }, ), ], ), ]); // final router = GoRouter( routes: [ // GoRoute( // path: Routes.navigation.path, // name: Routes.navigation.name, // pageBuilder: (context, state) { // return const CupertinoPage(child: Navigation()); // }, // ), // GoRoute( // path: Routes.homescreen.path, // name: Routes.homescreen.name, // pageBuilder: (context, state) { // return const CupertinoPage(child: HomeScreen()); // }, // ), // GoRoute( // path: Routes.wallet.path, // name: Routes.wallet.name, // pageBuilder: (context, state) { // return const CupertinoPage(child: WalletScreen()); // }, // ), // GoRoute( // path: Routes.account.path, // name: Routes.account.name, // pageBuilder: (context, state) { // return const CupertinoPage(child: AccountScreen()); // }, // ), // GoRoute( // path: Routes.statisticsscreen.path, // name: Routes.statisticsscreen.name, // pageBuilder: (context, state) { // return const CupertinoPage(child: StatisticsScreen()); // }, // ), // ]);
0
mirrored_repositories/E_Wallet/lib
mirrored_repositories/E_Wallet/lib/router/router.dart
class AppRouter { String name; String path; AppRouter({ required this.name, required this.path, }); } class Routes { static AppRouter navigation = AppRouter(name: "root", path: "/"); static AppRouter homescreen = AppRouter(name: "home", path: "/home"); static AppRouter statisticsscreen = AppRouter(name: "statistics", path: "/statistics"); static AppRouter wallet = AppRouter(name: "wallet", path: "/wallet"); static AppRouter account = AppRouter(name: "account", path: "/account"); }
0
mirrored_repositories/E_Wallet/lib
mirrored_repositories/E_Wallet/lib/screen/navigation.dart
import 'package:e_wallet/common/common_color.dart'; import 'package:e_wallet/features/account/screen/account_screen.dart'; import 'package:e_wallet/features/home/screen/home_screen.dart'; import 'package:e_wallet/features/statistics/statistics_screen.dart'; import 'package:e_wallet/features/wallet/wallet_page.dart'; import 'package:e_wallet/router/router.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:iconsax/iconsax.dart'; class NavigationScreen extends StatelessWidget { const NavigationScreen({ Key? key, required this.child, required this.selectedIndex, }) : super(key: key); final Widget child; final int selectedIndex; @override Widget build(BuildContext context) { return PopScope( canPop: selectedIndex == 0, onPopInvoked: (didPop) { if (selectedIndex != 0) { context.go(Routes.homescreen.path); } }, child: Stack( children: [ child, Align( alignment: Alignment.bottomCenter, child: Container( padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 20), decoration: BoxDecoration( color: Colors.transparent.withOpacity(0.6), border: Border.all(color: CommonColor().bluebg), // boxShadow: [ // BoxShadow( // blurRadius: 30, // color: Colors.pink.shade200, // blurStyle: BlurStyle.normal, // spreadRadius: 2, // offset: const Offset( // 0, // 7, // ), // ), // ], ), child: SizedBox( height: 50, child: CustomNavBar( colors: Colors.pink, selectedColor: CommonColor().backgorund1, icons: const [ "assets/images/icons/House.png", "assets/images/icons/credit card.png", "assets/images/icons/account.png", "assets/images/icons/bar graph.png", // selectedIndex == 0 ? Iconsax.home5 : Iconsax.home_1, // selectedIndex == 1 ? Iconsax.heart5 : Iconsax.heart, // selectedIndex == 2 ? Iconsax.add : Iconsax.add, // selectedIndex == 3 ? Iconsax.message5 : Iconsax.message, ], currentIndex: selectedIndex, onItemTap: (index) => context.go(_indexToTab(index)), ), ), ), ), ], ), ); } String _indexToTab(int index) { switch (index) { case 0: return Routes.homescreen.path; case 1: return Routes.wallet.path; case 2: return Routes.account.path; case 3: return Routes.statisticsscreen.path; default: return Routes.homescreen.path; } } } class CustomNavBar extends StatefulWidget { const CustomNavBar({ super.key, required this.icons, required this.currentIndex, required this.onItemTap, required this.selectedColor, required this.colors, }); final List<String> icons; final int currentIndex; final void Function(int index) onItemTap; final Color selectedColor; final Color colors; @override State<CustomNavBar> createState() => _CustomNavBarState(); } class _CustomNavBarState extends State<CustomNavBar> { @override Widget build(BuildContext context) { return LayoutBuilder(builder: (_, constraints) { double lineSize = constraints.maxWidth / widget.icons.length; return Stack( children: [ Align( alignment: Alignment.topLeft, child: AnimatedContainer( curve: Curves.easeOut, duration: const Duration(milliseconds: 350), margin: EdgeInsets.only(left: widget.currentIndex * lineSize), height: 80, width: lineSize, decoration: BoxDecoration( color: CommonColor().bluebg, shape: BoxShape.circle, // border: Border.all( // color: Colors.white, // ), boxShadow: [ BoxShadow( color: CommonColor().bluebg, blurRadius: 10, ) ], ), ), ), Align( alignment: Alignment.center, child: Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.spaceAround, children: widget.icons.map( (e) { int index = widget.icons.indexOf(e); return Padding( padding: EdgeInsets.symmetric(horizontal: (lineSize - 48) / 2), child: SizedBox( width: 48, child: MaterialButton( elevation: 0, minWidth: 10, height: 45, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(100)), splashColor: const Color(0xFFBE8E9B), highlightColor: Colors.transparent, padding: const EdgeInsets.symmetric( vertical: 8, horizontal: 8), onPressed: widget.currentIndex == index ? null : () { widget.onItemTap(index); }, child: Image.asset( e, // color: widget.currentIndex == index // ? widget.selectedColor // : widget.colors, // size: 30, ), ), ), ); }, ).toList(), ), ), ], ); }); } } // class Navigation extends StatefulWidget { // const Navigation({super.key}); // @override // State<Navigation> createState() => _NavigationState(); // } // class _NavigationState extends State<Navigation> { // int selectedIndex = 0; // List<String> icondata = [ // "assets/images/icons/House.png", // "assets/images/icons/credit card.png", // "assets/images/icons/account.png", // "assets/images/icons/bar graph.png", // ]; // List<Widget> pages = [ // const HomeScreen(), // const WalletScreen(), // const AccountScreen(), // const StatisticsScreen(), // ]; // @override // Widget build(BuildContext context) { // return Scaffold( // bottomNavigationBar: Material( // child: Container( // padding: EdgeInsets.only(top: 0), // height: 100, // decoration: BoxDecoration(color: Colors.transparent.withOpacity(0.5)), // child: ListView.builder( // scrollDirection: Axis.horizontal, // itemCount: icondata.length, // padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10), // itemBuilder: (context, index) { // return Padding( // padding: // const EdgeInsets.symmetric(horizontal: 33, vertical: 10), // child: GestureDetector( // onTap: () { // setState(() { // selectedIndex = index; // }); // }, // child: AnimatedContainer( // duration: const Duration(milliseconds: 300), // width: index == 0 // ? 40 // : index == 3 // ? 35 // : 30, // height: 30, // child: Image.asset( // icondata[index], // color: index == selectedIndex // ? CommonColor().bluebg // : Colors.grey, // ), // ), // ), // ); // }, // ), // ), // ), // body: pages[selectedIndex], // ); // } // }
0
mirrored_repositories/E_Wallet/lib
mirrored_repositories/E_Wallet/lib/widget/custom_widget.dart
import 'dart:ui'; import 'package:e_wallet/common/common_color.dart'; import 'package:flutter/material.dart'; class BackgroundPainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { canvas.drawColor(Colors.white, BlendMode.src); Path path = Path() ..addOval( Rect.fromCircle( center: Offset(size.width, -60), radius: 100, ), ) ..addOval( Rect.fromCircle( center: Offset(0, size.height - 50), radius: 100, ), ) ..addOval( Rect.fromCircle( center: Offset(size.width, size.height - 100), radius: 100, ), ) ..addRRect( RRect.fromRectAndRadius( Rect.fromPoints( Offset(-50, size.height / 2), Offset(20, size.height / 2 + 90), ), const Radius.circular(50), ), ); canvas.drawShadow( path, CommonColor().bluebg, 100, true, ); } @override bool shouldRepaint(covariant CustomPainter oldDelegate) => true; }
0
mirrored_repositories/E_Wallet/lib
mirrored_repositories/E_Wallet/lib/common/common_color.dart
import 'package:flutter/material.dart'; class CommonColor { Color greytext = const Color(0xFF7B78AA); Color blacktext = const Color(0xFFFFFFFF); Color backgorund1 = const Color(0xFF19173D); Color background2 = const Color(0xFF7B78AA); Color shine = const Color(0xFF00D7FF); Color blackbg = const Color(0xFF19173D); Color bluebg = const Color(0xFF262450); }
0
mirrored_repositories/E_Wallet/lib
mirrored_repositories/E_Wallet/lib/common/common_textstyle.dart
import 'package:flutter/material.dart'; class CommonTextStyle { TextStyle style1 = const TextStyle( fontSize: 15, fontFamily: 'Poppins', fontWeight: FontWeight.w600, color: Colors.white); TextStyle style2 = const TextStyle( fontSize: 13, fontFamily: 'Poppins', fontStyle: FontStyle.normal, color: Color(0xFF7B78AA)); }
0
mirrored_repositories/E_Wallet
mirrored_repositories/E_Wallet/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:e_wallet/main.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(const MainApp()); // 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-Clean-Architecture-MVVM
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/main.dart
import 'package:camera/camera.dart'; import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'presentation/home/PokemonHome.dart'; import 'utils/AppLocalizations.dart'; List<CameraDescription> cameras; Future<Null> main() async { WidgetsFlutterBinding.ensureInitialized(); cameras = await availableCameras(); runApp(new MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( localizationsDelegates: [ AppLocalizations.delegate, GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, ], supportedLocales: [ const Locale('en', "US"), // English const Locale('vi', "VN"), // Vn // ... other locales the app supports ], localeResolutionCallback: (locale, supportedLocales) { for (var supportedLocale in supportedLocales) { if (supportedLocale.languageCode == locale.languageCode && supportedLocale.countryCode == locale.countryCode) { return supportedLocale; } } return supportedLocales.first; }, title: 'Flutter Example', theme: ThemeData( primarySwatch: Colors.blue, ), home: PokemonHome(cameras)); } }
0
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/data
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/data/remote/PokemonApiImpl.dart
import 'dart:convert'; import 'package:flutter_cleanarchitecture_mvvm/data/model/Pokemon.dart'; import 'package:flutter_cleanarchitecture_mvvm/data/remote/PokemonApi.dart'; import 'package:http/http.dart'; class PokemonApiImpl implements PokemonApi { @override Future<List<Pokemon>> getPokemonList() async { try{ final response = await get('https://raw.githubusercontent.com/Biuni/PokemonGO-Pokedex/master/pokedex.json'); if (response.statusCode == 200) { Map<String, dynamic> mapResponse = json.decode(response.body); var list = mapResponse['pokemon'] as List; List<Pokemon> listPokemon = List(); for (var idx=0;idx<list.length;idx++) { Pokemon pokemon = Pokemon(); pokemon.name = list.asMap()[idx]['name']; pokemon.url = list.asMap()[idx]['img']; pokemon.weight = list.asMap()[idx]['weight']; pokemon.height = list.asMap()[idx]['height']; listPokemon.add(pokemon); } return listPokemon; }else{ throw Exception("Error Code: ${response.statusCode}"); } }catch(e){ throw Exception("There was a problem with the connection"); } } }
0
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/data
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/data/remote/PokemonApi.dart
import 'package:flutter_cleanarchitecture_mvvm/data/model/Pokemon.dart'; abstract class PokemonApi{ Future<List<Pokemon>> getPokemonList(); }
0
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/data
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/data/repository/PokemonRepositoryImpl.dart
import 'package:flutter_cleanarchitecture_mvvm/data/model/Pokemon.dart'; import 'package:flutter_cleanarchitecture_mvvm/data/remote/PokemonApi.dart'; import 'package:flutter_cleanarchitecture_mvvm/data/repository/PokemonRepository.dart'; class PokemonRepositoryImpl implements PokemonRepository{ PokemonApi pokemonApi; PokemonRepositoryImpl(PokemonApi pokemonApi){ this.pokemonApi = pokemonApi; } @override Future<List<Pokemon>> getPokemonList() { return pokemonApi.getPokemonList(); } }
0
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/data
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/data/repository/PokemonRepository.dart
import 'package:flutter_cleanarchitecture_mvvm/data/model/Pokemon.dart'; abstract class PokemonRepository{ Future<List<Pokemon>> getPokemonList(); }
0
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/data
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/data/model/Pokemon.dart
class Pokemon{ String name; String url; String weight; String height; }
0
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/data
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/data/widget/mp_circle_avatar.dart
import 'package:flutter/material.dart'; Widget avatar(String url, MaterialColor color) { return new Material( borderRadius: new BorderRadius.circular(20.0), elevation: 3.0, child: url != null && url.isNotEmpty ? new CircleAvatar(child: new Image.network(url)) : new CircleAvatar( child: new Icon( Icons.play_arrow, color: Colors.white, ), backgroundColor: color, ), ); }
0
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/presentation
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/presentation/pokemon_detail/ViewPokemonDetail.dart
import 'package:flutter/material.dart'; class ViewPokemonDetail extends StatelessWidget { @override Widget build(BuildContext context) { return new MaterialApp( title: 'Welcome to Demo', home: new Scaffold( appBar: new AppBar( leading: new IconButton( icon: new Icon(Icons.arrow_back, color: Colors.white), onPressed: () => Navigator.of(context).pop(), ), title: new Text('Welcome To Pokemon Detail'), ), body: new Center( child: Text("Pokemon Detail"), ), ), ); } }
0
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/presentation
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/presentation/camera/CameraScreen.dart
import 'dart:async'; import 'dart:io'; import 'package:camera/camera.dart'; import 'package:flutter/material.dart'; import 'package:path/path.dart'; import 'package:path_provider/path_provider.dart'; class CameraScreen extends StatefulWidget { List<CameraDescription> cameras; CameraScreen(this.cameras); @override CameraScreenState createState() { return new CameraScreenState(); } } class CameraScreenState extends State<CameraScreen> { CameraController controller; @override void initState() { super.initState(); controller = new CameraController(widget.cameras[0], ResolutionPreset.medium); controller.initialize().then((_) { if (mounted) { setState(() {}); } }); } @override void dispose() { controller?.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('Take a picture')), // You must wait until the controller is initialized before displaying the // camera preview. Use a FutureBuilder to display a loading spinner until // the controller has finished initializing body: FutureBuilder<void>( future: controller.initialize(), builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.done) { // If the Future is complete, display the preview return CameraPreview(controller); } else { // Otherwise, display a loading indicator return Center(child: CircularProgressIndicator()); } }, ), floatingActionButton: FloatingActionButton( child: Icon(Icons.camera_alt), // Provide an onPressed callback onPressed: () async { // Take the Picture in a try / catch block. If anything goes wrong, // catch the error. try { // Ensure the camera is initialized await controller.initialize(); // Construct the path where the image should be saved using the path // package. final path = join( // In this example, store the picture in the temp directory. Find // the temp directory using the `path_provider` plugin. (await getTemporaryDirectory()).path, '${DateTime.now()}.png', ); // Attempt to take a picture and log where it's been saved await controller.takePicture(path); // If the picture was taken, display it on a new screen Navigator.push( context, MaterialPageRoute( builder: (context) => DisplayPictureScreen(imagePath: path), ), ); } catch (e) { // If an error occurs, log the error to the console. print(e); } }, ), ); } } // A Widget that displays the picture taken by the user class DisplayPictureScreen extends StatelessWidget { final String imagePath; const DisplayPictureScreen({Key key, this.imagePath}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('Display the Picture')), // The image is stored as a file on the device. Use the `Image.file` // constructor with the given path to display the image body: Image.file(File(imagePath)), ); } }
0
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/presentation
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/presentation/home/PokemonHome.dart
import 'package:flutter/material.dart'; import 'package:flutter_cleanarchitecture_mvvm/main.dart'; import 'package:flutter_cleanarchitecture_mvvm/presentation/camera/CameraScreen.dart'; import 'package:flutter_cleanarchitecture_mvvm/presentation/photo/ViewPhotoStaggered.dart'; import 'package:flutter_cleanarchitecture_mvvm/presentation/pokemon_list/ViewPokemonGrid.dart'; import 'package:flutter_cleanarchitecture_mvvm/presentation/pokemon_list/ViewPokemonList.dart'; import 'package:flutter_cleanarchitecture_mvvm/utils/AppLocalizations.dart'; class PokemonHome extends StatefulWidget { var cameras; PokemonHome(this.cameras); @override _PokemonHomeState createState() => new _PokemonHomeState(); } class _PokemonHomeState extends State<PokemonHome> with SingleTickerProviderStateMixin { TabController _tabController; @override void initState() { super.initState(); _tabController = new TabController(vsync: this, initialIndex: 0, length: 3); } @override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar( title: new Text(AppLocalizations.of(context).translate('name_app')), elevation: 0.7, bottom: new TabBar( controller: _tabController, indicatorColor: Colors.white, tabs: <Widget>[ new Tab(text: "LIST"), new Tab( text: "GRID", ), new Tab( text: "STAGGER", ), ], ), actions: <Widget>[ new IconButton( icon: new Icon( Icons.camera_alt, color: Colors.white, ), onPressed: () => _onClickCamera(context)), new Icon(Icons.more_vert) ], ), body: new TabBarView( controller: _tabController, children: <Widget>[ new ViewPokemonList(), new ViewPokemonGrid(), new ViewPhotoStaggered(), ], ), floatingActionButton: new FloatingActionButton( backgroundColor: Theme.of(context).accentColor, child: new Icon( Icons.message, color: Colors.white, ), onPressed: () => _showToast(context)), ); } _showToast(BuildContext context) { final scaffold = Scaffold.of(context); scaffold.showSnackBar( SnackBar( content: const Text('Hello!'), action: SnackBarAction( label: 'UNDO', onPressed: scaffold.hideCurrentSnackBar), ), ); } } _onClickCamera(BuildContext context) { print("OnClick Camera!!"); Navigator.push(context, new MaterialPageRoute(builder: (context) => new CameraScreen(cameras))); }
0
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/presentation
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/presentation/pokemon_list/ViewPokemonGrid.dart
import 'package:connectivity/connectivity.dart'; import 'package:flutter/material.dart'; import 'package:flutter_cleanarchitecture_mvvm/data/model/Pokemon.dart'; import 'package:flutter_cleanarchitecture_mvvm/data/widget/mp_circle_avatar.dart'; import 'package:flutter_cleanarchitecture_mvvm/presentation/pokemon_list/ViewModelPokemonList.dart'; class ViewPokemonGrid extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold(body: buildPokemonContent()); } Widget buildPokemonContent() { return Container( child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ PokemonListView(), ], ), ); } } class PokemonListView extends StatefulWidget { @override State<StatefulWidget> createState() { return PokemonListViewState(); } } class PokemonListViewState extends State<PokemonListView> with WidgetsBindingObserver { final ViewModelPokemonList viewModelPokemonList = ViewModelPokemonList(); @override void didChangeAppLifecycleState(AppLifecycleState state) { if (state == AppLifecycleState.resumed) { refresh(); } } @override void initState() { super.initState(); refresh(); Connectivity().onConnectivityChanged.listen((ConnectivityResult result) { if (result != ConnectivityResult.none) { refresh(); } }); WidgetsBinding.instance.addObserver(this); } @override void dispose() { WidgetsBinding.instance.removeObserver(this); viewModelPokemonList.closeObservable(); super.dispose(); } @override Widget build(BuildContext context) { return StreamBuilder<List<Pokemon>>( stream: viewModelPokemonList.pokemonList, builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return buildCircularProgressIndicatorWidget(); } if (snapshot.hasError) { showSnackBar(context, snapshot.error.toString()); return buildListViewNoDataWidget(); } if (snapshot.connectionState == ConnectionState.active) { var pokemonList = snapshot.data; if (null != pokemonList) return buildGridViewWidget(pokemonList); else return buildListViewNoDataWidget(); } }, ); } Widget buildGridViewWidget(List<Pokemon> pokemonList) { return Flexible( child: GridView.builder( padding: EdgeInsets.fromLTRB(5, 0, 0, 0), itemCount: 20, scrollDirection: Axis.horizontal, gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 3), itemBuilder: (BuildContext context, int index) { var item = pokemonList[index]; var _colors = Colors.primaries; final MaterialColor color = _colors[index % _colors.length]; return new GestureDetector( child: new Card( elevation: 5.0, child: new Container( alignment: Alignment.center, child: new Hero( tag: item.name, child: Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: <Widget>[ Container( child: avatar(item.url, color), ), new Text( "Weight: ${item.weight}", style: Theme.of(context).textTheme.caption, ), new Text( "Height: ${item.height} ", style: Theme.of(context).textTheme.caption, ), ], ), ), ), ), ); })); } Widget buildListViewNoDataWidget() { return Expanded( child: Center( child: Text("No Data Available"), ), ); } Widget buildCircularProgressIndicatorWidget() { return Expanded( child: Center( child: CircularProgressIndicator(), ), ); } void showSnackBar(BuildContext context, String errorMessage) async { await Future.delayed(Duration.zero); Scaffold.of(context).showSnackBar(SnackBar(content: Text(errorMessage))); } void refresh() { viewModelPokemonList.getPokemonList(); setState(() {}); } }
0
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/presentation
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/presentation/pokemon_list/ViewModelPokemonList.dart
import 'package:flutter_cleanarchitecture_mvvm/data/model/Pokemon.dart'; import 'package:flutter_cleanarchitecture_mvvm/data/remote/PokemonApiImpl.dart'; import 'package:flutter_cleanarchitecture_mvvm/domain/GetPokemonListUseCase.dart'; import 'package:flutter_cleanarchitecture_mvvm/data/repository/PokemonRepositoryImpl.dart'; import 'package:rxdart/rxdart.dart'; class ViewModelPokemonList { var pokemonListSubject = PublishSubject<List<Pokemon>>(); Observable<List<Pokemon>> get pokemonList => pokemonListSubject.stream; GetPokemonListUseCase getPokemonListUseCase = GetPokemonListUseCase(PokemonRepositoryImpl(PokemonApiImpl())); void getPokemonList() async { try { pokemonListSubject = PublishSubject<List<Pokemon>>(); pokemonListSubject.sink.add(await getPokemonListUseCase.perform()); } catch (e) { await Future.delayed(Duration(milliseconds: 500)); pokemonListSubject.sink.addError(e); } } void closeObservable() { pokemonListSubject.close(); } }
0
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/presentation
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/presentation/pokemon_list/ViewPokemonList.dart
import 'package:connectivity/connectivity.dart'; import 'package:flutter/material.dart'; import 'package:flutter_cleanarchitecture_mvvm/data/model/Pokemon.dart'; import 'package:flutter_cleanarchitecture_mvvm/data/widget/mp_circle_avatar.dart'; import 'package:flutter_cleanarchitecture_mvvm/presentation/pokemon_detail/ViewPokemonDetail.dart'; import 'package:flutter_cleanarchitecture_mvvm/presentation/pokemon_list/ViewModelPokemonList.dart'; class ViewPokemonList extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( body: buildPokemonContent()); } Widget buildPokemonContent() { return Container( child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ PokemonListView(), ], ), ); } } class PokemonListView extends StatefulWidget { @override State<StatefulWidget> createState() { return PokemonListViewState(); } } class PokemonListViewState extends State<PokemonListView> with WidgetsBindingObserver { final ViewModelPokemonList viewModelPokemonList = ViewModelPokemonList(); @override void didChangeAppLifecycleState(AppLifecycleState state) { if (state == AppLifecycleState.resumed) { refresh(); } } @override void initState() { super.initState(); refresh(); Connectivity().onConnectivityChanged.listen((ConnectivityResult result) { if (result != ConnectivityResult.none) { refresh(); } }); WidgetsBinding.instance.addObserver(this); } @override void dispose() { WidgetsBinding.instance.removeObserver(this); viewModelPokemonList.closeObservable(); super.dispose(); } @override Widget build(BuildContext context) { return StreamBuilder<List<Pokemon>>( stream: viewModelPokemonList.pokemonList, builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return buildCircularProgressIndicatorWidget(); } if (snapshot.hasError) { showSnackBar(context, snapshot.error.toString()); return buildListViewNoDataWidget(); } if (snapshot.connectionState == ConnectionState.active) { var pokemonList = snapshot.data; if (null != pokemonList) return buildListViewWidget(pokemonList); else return buildListViewNoDataWidget(); } }, ); } Widget buildListViewWidget(List<Pokemon> pokemonList) { return Flexible(child: new ListView.builder( padding: EdgeInsets.all(10), itemCount: pokemonList.length, itemBuilder: (BuildContext context, int index) { var item = pokemonList[index]; var _colors = Colors.primaries; final MaterialColor color = _colors[index % _colors.length]; return new ListTile( dense: false, leading: new Hero( child: avatar(item.url, color), tag: item.name, ), title: new Text(item.name), subtitle: new Text( "Weight: ${item.weight} Height: ${item.height} ", style: Theme .of(context) .textTheme .caption, ), onTap: () { Navigator.push( context, new MaterialPageRoute( builder: (context) => new ViewPokemonDetail())); }, ); }, )); } Widget buildListViewNoDataWidget() { return Expanded( child: Center( child: Text("No Data Available"), ), ); } Widget buildCircularProgressIndicatorWidget() { return Expanded( child: Center( child: CircularProgressIndicator(), ), ); } void showSnackBar(BuildContext context, String errorMessage) async { await Future.delayed(Duration.zero); Scaffold.of(context).showSnackBar(SnackBar(content: Text(errorMessage))); } void refresh() { viewModelPokemonList.getPokemonList(); setState(() {}); } }
0
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/presentation
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/presentation/photo/ViewPhotoStaggered.dart
import 'package:flutter/material.dart'; class ViewPhotoStaggered extends StatelessWidget { @override Widget build(BuildContext context) { return new Scaffold( body: new Center( child: Text("Photo Image"), ), ); } }
0
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/domain/GetPokemonListUseCase.dart
import 'package:flutter_cleanarchitecture_mvvm/data/model/Pokemon.dart'; import 'package:flutter_cleanarchitecture_mvvm/domain/BaseUseCase.dart'; import 'package:flutter_cleanarchitecture_mvvm/data/repository/PokemonRepository.dart'; class GetPokemonListUseCase extends BaseUseCase<List<Pokemon>> { PokemonRepository pokemonRepository; GetPokemonListUseCase(PokemonRepository pokemonRepository) { this.pokemonRepository = pokemonRepository; } @override Future<List<Pokemon>> perform() { return pokemonRepository.getPokemonList(); } }
0
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/domain/BaseUseCase.dart
abstract class BaseUseCase<T>{ Future<T> perform(); }
0
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib
mirrored_repositories/Flutter-Clean-Architecture-MVVM/lib/utils/AppLocalizations.dart
import 'dart:async'; import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; class AppLocalizations { final Locale locale; AppLocalizations(this.locale); static AppLocalizations of(BuildContext context) { return Localizations.of<AppLocalizations>(context, AppLocalizations); } static const LocalizationsDelegate<AppLocalizations> delegate = _AppLocalizationsDelegate(); Map<String, String> _localizedStrings; // Load file json vào bộ nhớ Future<bool> load() async { // Đọc file json dưới dạng chuỗi String jsonString = await rootBundle.loadString('assets/languages/${locale.languageCode}.json'); // Giải mã file json sang Map Map<String, dynamic> jsonMap = json.decode(jsonString); // Sau đó dùng hàm map() để đưa Map<String, dynamic> về Map<String, String> // và gán cho biến _localizedStrings _localizedStrings = jsonMap.map((key, value) { return MapEntry(key, value.toString()); }); // Đoạn này cũng không cần thiết phải trả về giá trị nào // Bạn có thể để Future không cũng được và không cần return return true; } // Đoạn này đơn giản chỉ là lấy giá trị đang // được lưu tại cái key được truyền vào String translate(String key) { return _localizedStrings[key]; } } class _AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> { const _AppLocalizationsDelegate(); @override bool isSupported(Locale locale) { // Bạn thêm tất cả các ngôn ngữ ứng dụng của bạn hỗ trợ tại đây return ['en', 'vi'].contains(locale.languageCode); } @override Future<AppLocalizations> load(Locale locale) async { // Gọi hàm load json được định nghĩa trong class bên trên AppLocalizations localizations = new AppLocalizations(locale); // Đợi load xong mới return về giá trị await localizations.load(); return localizations; } @override bool shouldReload(_AppLocalizationsDelegate old) => false; }
0
mirrored_repositories/Flutter-Clean-Architecture-MVVM
mirrored_repositories/Flutter-Clean-Architecture-MVVM/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:flutter_cleanarchitecture_mvvm/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/layout_basics_column_example
mirrored_repositories/layout_basics_column_example/lib/main.dart
import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:layout_basics_column_example/page/column_page.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); await SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, DeviceOrientation.portraitDown, ]); runApp(MyApp()); } class MyApp extends StatelessWidget { static final String title = 'Column'; @override Widget build(BuildContext context) => MaterialApp( debugShowCheckedModeBanner: false, title: title, theme: ThemeData(primarySwatch: Colors.red), home: RowColumnPage(), ); }
0
mirrored_repositories/layout_basics_column_example/lib
mirrored_repositories/layout_basics_column_example/lib/page/column_page.dart
import 'package:flutter/material.dart'; import 'package:layout_basics_column_example/main.dart'; import 'package:layout_basics_column_example/widget/appbar_widget.dart'; import 'package:layout_basics_column_example/widget/examples_widget.dart'; import 'package:layout_basics_column_example/widget/items/layout_type.dart'; import 'package:layout_basics_column_example/widget/items/column_items.dart'; class RowColumnPage extends StatefulWidget { @override _RowColumnPageState createState() => new _RowColumnPageState(); } class _RowColumnPageState extends State<RowColumnPage> { bool isRow = false; MainAxisAlignment mainAxisAlignment = MainAxisAlignment.start; CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.start; MainAxisSize mainAxisSize = MainAxisSize.min; int index = 0; void setLayout(int index) => setState(() => isRow = index == 0); MainAxisAlignment getMainAxisAlignment(int index) { switch (index) { case 0: return MainAxisAlignment.start; case 1: return MainAxisAlignment.end; case 2: return MainAxisAlignment.center; case 3: return MainAxisAlignment.spaceBetween; case 4: return MainAxisAlignment.spaceAround; case 5: return MainAxisAlignment.spaceEvenly; } return MainAxisAlignment.start; } void setMainAxisAlignment(int index) => setState(() => mainAxisAlignment = getMainAxisAlignment(index)); CrossAxisAlignment getCrossAxisAlignment(int index) { switch (index) { case 0: return CrossAxisAlignment.start; case 1: return CrossAxisAlignment.end; case 2: return CrossAxisAlignment.center; case 3: return CrossAxisAlignment.stretch; case 4: return CrossAxisAlignment.baseline; } return CrossAxisAlignment.start; } void setCrossAxisAlignment(int index) => setState(() => crossAxisAlignment = getCrossAxisAlignment(index)); void setMainAxisSize(int index) => setState( () => mainAxisSize = index == 0 ? MainAxisSize.min : MainAxisSize.max); Widget buildContent() { final children = [ FlutterLogo(size: 50), FlutterLogo(size: 100), FlutterLogo(size: 50), ]; if (isRow) { return Row( mainAxisAlignment: mainAxisAlignment, crossAxisAlignment: crossAxisAlignment, mainAxisSize: mainAxisSize, children: children, ); } else { return Column( mainAxisAlignment: mainAxisAlignment, crossAxisAlignment: crossAxisAlignment, mainAxisSize: mainAxisSize, children: children, ); } } @override Widget build(BuildContext context) { switch (index) { case 0: return Scaffold( appBar: AppBarWidget( layoutType: LayoutType.column, bottom: PreferredSize( preferredSize: Size.fromHeight(160), child: buildBottom(), ), ), body: Container(color: Colors.yellow, child: buildContent()), bottomNavigationBar: buildBottomBar(), ); case 1: default: return Scaffold( appBar: AppBar( title: Text(MyApp.title), centerTitle: true, ), body: ExamplesWidget(), bottomNavigationBar: buildBottomBar(), ); } } Widget buildBottom() => RowColumnItems( onChangedLayout: setLayout, onChangedMainAxisAlignment: setMainAxisAlignment, onChangedCrossAxisAlignment: setCrossAxisAlignment, onChangedMainAxisSize: setMainAxisSize, ); Widget buildBottomBar() => BottomNavigationBar( backgroundColor: Theme.of(context).primaryColor, selectedItemColor: Colors.white, unselectedItemColor: Colors.white70, currentIndex: index, items: [ BottomNavigationBarItem( icon: Icon(Icons.directions_walk), label: 'Walkthrough', ), BottomNavigationBarItem( icon: Icon(Icons.sort_by_alpha), label: 'Examples', ), ], onTap: (index) => setState(() => this.index = index), ); }
0
mirrored_repositories/layout_basics_column_example/lib
mirrored_repositories/layout_basics_column_example/lib/widget/appbar_widget.dart
import 'package:flutter/material.dart'; import 'items/layout_type.dart'; class AppBarWidget extends AppBar { AppBarWidget({ required LayoutType layoutType, required PreferredSize bottom, }) : super( title: Text(layoutNames[layoutType]!), centerTitle: true, bottom: bottom, ); }
0
mirrored_repositories/layout_basics_column_example/lib
mirrored_repositories/layout_basics_column_example/lib/widget/layout_selector_widget.dart
import 'package:flutter/material.dart'; class LayoutSelectorWidget extends StatefulWidget { final String title; final List<String> values; final bool disabled; final ValueChanged<int> onChanged; const LayoutSelectorWidget({ required this.title, required this.values, this.disabled = false, required this.onChanged, }); @override State<StatefulWidget> createState() => LayoutSelectorWidgetState(); } class LayoutSelectorWidgetState extends State<LayoutSelectorWidget> { int index = 0; void next() { final hasNext = index + 1 < widget.values.length; index = hasNext ? index + 1 : 0; update(); } void previous() { final hasPrevious = index > 0; index = hasPrevious ? index - 1 : widget.values.length - 1; update(); } void update() => setState(() => widget.onChanged(index)); @override Widget build(BuildContext context) { final color = widget.disabled ? Colors.white54 : Colors.white; return Column( children: [ Divider(color: Colors.white), Text( widget.title, style: TextStyle(color: color), ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Opacity( opacity: widget.title.isNotEmpty ? 1 : 0, child: IconButton( icon: Icon(Icons.arrow_back, color: color), onPressed: widget.disabled ? null : previous, ), ), Text( widget.values[index], maxLines: 2, textAlign: TextAlign.center, style: TextStyle(fontWeight: FontWeight.bold, color: color), ), if (widget.title.isNotEmpty) Opacity( opacity: widget.title.isNotEmpty ? 1 : 0, child: IconButton( icon: Icon(Icons.arrow_forward, color: color), onPressed: widget.disabled ? null : next, ), ), ], ), ], ); } }
0
mirrored_repositories/layout_basics_column_example/lib
mirrored_repositories/layout_basics_column_example/lib/widget/examples_widget.dart
import 'package:flutter/material.dart'; class ExamplesWidget extends StatelessWidget { @override Widget build(BuildContext context) => ListView( padding: EdgeInsets.all(32), children: [ buildBackgroundCard(), Center(child: buildIconCard()), Center(child: buildBurger()), ], ); Widget buildBurger() { final urlBurger = 'https://images.unsplash.com/photo-1586190848861-99aa4a171e90?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=80'; return ClipRRect( borderRadius: BorderRadius.circular(20), child: Container( padding: EdgeInsets.all(12), color: Color(0xFF010101), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ Image.network(urlBurger, width: 200, height: 200, fit: BoxFit.cover), Text( 'Beef Burger', style: TextStyle( fontWeight: FontWeight.bold, color: Colors.white, fontSize: 20, ), ), const SizedBox(height: 8), Text( 'Onion with cheese', style: TextStyle(color: Colors.white, fontSize: 16), ), const SizedBox(height: 8), Text( '\$24.00', style: TextStyle( fontWeight: FontWeight.bold, color: Colors.white, fontSize: 16, ), ), ], ), ), ); } Widget buildIconCard() => Card( color: Color(0xFF40358a), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(28)), child: Container( width: 160, height: 160, child: Column( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Icon(Icons.access_time, color: Color(0xFF00dcff), size: 48), const SizedBox(height: 16), Text( 'Active', style: TextStyle( fontWeight: FontWeight.bold, color: Colors.white, fontSize: 24, ), ), const SizedBox(height: 8), Text( '2 Times a day', style: TextStyle(color: Colors.white), ), ], ), ), ); Widget buildBackgroundCard() { final urlBackgroundImage = 'https://images.unsplash.com/photo-1570544820979-6eb25385944d?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=750&q=80'; return Container( padding: EdgeInsets.all(24), width: double.infinity, height: 200, decoration: BoxDecoration( borderRadius: BorderRadius.circular(16), image: DecorationImage( image: NetworkImage(urlBackgroundImage), fit: BoxFit.cover, colorFilter: ColorFilter.mode( Colors.black.withOpacity(0.25), BlendMode.darken, ), ), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Cottage', style: TextStyle( fontSize: 24, fontWeight: FontWeight.bold, color: Colors.white, ), ), const SizedBox(height: 8), Text( '70-150\$', style: TextStyle(fontSize: 24, color: Colors.white), ), ], ), ); } }
0
mirrored_repositories/layout_basics_column_example/lib/widget
mirrored_repositories/layout_basics_column_example/lib/widget/items/layout_type.dart
enum LayoutType { column, } Map<LayoutType, String> layoutNames = { LayoutType.column: 'Column', };
0
mirrored_repositories/layout_basics_column_example/lib/widget
mirrored_repositories/layout_basics_column_example/lib/widget/items/column_items.dart
import 'package:flutter/material.dart'; import 'package:layout_basics_column_example/widget/layout_selector_widget.dart'; class RowColumnItems extends StatefulWidget { final ValueChanged<int> onChangedLayout; final ValueChanged<int> onChangedMainAxisAlignment; final ValueChanged<int> onChangedCrossAxisAlignment; final ValueChanged<int> onChangedMainAxisSize; const RowColumnItems({ required this.onChangedLayout, required this.onChangedMainAxisAlignment, required this.onChangedCrossAxisAlignment, required this.onChangedMainAxisSize, }); @override _RowColumnItemsState createState() => _RowColumnItemsState(); } class _RowColumnItemsState extends State<RowColumnItems> { bool showMainAxisAlign = false; @override Widget build(BuildContext context) => Row( children: [ Expanded( child: Column( children: <Widget>[ LayoutSelectorWidget( title: '', values: [''], onChanged: widget.onChangedLayout, disabled: true, ), LayoutSelectorWidget( title: 'Main Axis Size', values: ['min', 'max'], onChanged: setMainAxisSize, ), ], ), ), Expanded( child: Column( children: [ LayoutSelectorWidget( title: 'Main Axis Alignment', values: [ 'start', 'end', 'center', 'space\nbetween', 'space\naround', 'space\nevenly' ], disabled: !showMainAxisAlign, onChanged: widget.onChangedMainAxisAlignment, ), LayoutSelectorWidget( title: 'Cross Axis Alignment', values: [ 'start', 'end', 'center', 'stretch', ], onChanged: widget.onChangedCrossAxisAlignment, ), ], ), ), ], ); void setMainAxisSize(int index) { widget.onChangedMainAxisSize(index); setState(() => showMainAxisAlign = index == 1); } }
0
mirrored_repositories/flutter_business_card
mirrored_repositories/flutter_business_card/lib/main.dart
import 'package:flutter/material.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart' as DotEnv; Future main() async{ await DotEnv.load(fileName: ".env"); runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( backgroundColor: Colors.cyan[900], body: SafeArea( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ CircleAvatar( radius: 50, backgroundImage: AssetImage('images/avatar.jpg'), ), Text(DotEnv.env['USERNAME'], style: TextStyle( color: Colors.white, fontSize: 30, fontWeight: FontWeight.bold, fontFamily: 'Pacifico')), Text(DotEnv.env['ROLE'], style: TextStyle( color: Colors.white, fontSize: 18, fontFamily: 'OpenSansCondensed-Light', letterSpacing: 1)), SizedBox( height: 20, width: 200, child: Divider(color: Colors.white)), Card( margin: EdgeInsets.symmetric(vertical: 10, horizontal: 30), child: ListTile( leading: Icon(Icons.phone, color: Colors.cyan[600]), title: Text( DotEnv.env['PHONE'], style: TextStyle( fontFamily: 'OpenSansCondensed-Light', fontSize: 16, color: Colors.cyan[900]), ), )), Card( margin: EdgeInsets.symmetric(vertical: 10, horizontal: 30), child: ListTile( leading: Icon(Icons.email, color: Colors.cyan[600]), title: Text( DotEnv.env['EMAIL'], style: TextStyle( fontFamily: 'OpenSansCondensed-Light', fontSize: 16, color: Colors.cyan[900]), ), )), ], ), )), ); } }
0
mirrored_repositories/pomodoro-timer
mirrored_repositories/pomodoro-timer/lib/main.dart
import 'package:flutter/material.dart'; //Screens import 'screens/pomodoroScreen.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Pomodoro App', debugShowCheckedModeBanner: false, darkTheme: ThemeData( brightness: Brightness.dark, canvasColor: Colors.transparent, primaryColor: Colors.green, fontFamily: 'Ubuntu', ), theme: ThemeData( fontFamily: 'Ubuntu', brightness: Brightness.light, canvasColor: Colors.transparent, primarySwatch: Colors.red, ), home: PomodoroScreen(), ); } }
0
mirrored_repositories/pomodoro-timer/lib
mirrored_repositories/pomodoro-timer/lib/models/Todo.dart
class Todo { int taskId; String task; bool isDone; Todo(String task, {bool isDone = false, int taskId}) { this.task = task; this.isDone = isDone; this.taskId = taskId; } }
0
mirrored_repositories/pomodoro-timer/lib
mirrored_repositories/pomodoro-timer/lib/models/CustomTimerPainter.dart
import 'package:flutter/material.dart'; import 'dart:math'; class CustomTimerPainter extends CustomPainter { final Animation<double> animation; final Color backgroundColor, color; CustomTimerPainter({ this.animation, this.backgroundColor, this.color, }) : super(repaint: animation); @override void paint(Canvas canvas, Size size) { Paint paint = Paint() ..color = backgroundColor ..strokeWidth = 8.0 ..strokeCap = StrokeCap.butt ..style = PaintingStyle.stroke; canvas.drawCircle(size.center(Offset.zero), size.width / 2.0, paint); paint.color = color; double progress = (1.0 - animation.value) * 2 * pi; canvas.drawArc(Offset.zero & size, pi * 1.5, progress, false, paint); } @override bool shouldRepaint(CustomTimerPainter oldDelegate) { return animation.value != oldDelegate.animation.value || color != oldDelegate.color || backgroundColor != oldDelegate.backgroundColor; } }
0
mirrored_repositories/pomodoro-timer/lib
mirrored_repositories/pomodoro-timer/lib/screens/pomodoroScreen.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:numberpicker/numberpicker.dart'; import 'package:pomodoro_timer/models/CustomTimerPainter.dart'; class PomodoroScreen extends StatefulWidget { @override _PomodoroScreenState createState() => _PomodoroScreenState(); } class _PomodoroScreenState extends State<PomodoroScreen> with TickerProviderStateMixin { // Switch states bool soundSwitch = true; bool vibrationSwitch = true; int _workSessionValue = 1; int _shortBreakValue = 1; int _longBreakValue = 1; NumberPicker integerNumberPicker; // Work Session _handleWorkValueChange(num value) { if (value != null) { setState(() { _workSessionValue = value; }); } } _handleWorkValueChangedExternally(num value) { if (value != null) { setState(() { _workSessionValue = value; }); integerNumberPicker.animateInt(value); } } // Short break _handleShortBreakValueChange(num value) { if (value != null) { setState(() { _shortBreakValue = value; }); } } _handleShortBreakValueChangedExternally(num value) { if (value != null) { setState(() { _shortBreakValue = value; }); integerNumberPicker.animateInt(value); } } // Long Break _handleLongBreakValueChange(num value) { if (value != null) { setState(() { _longBreakValue = value; }); } } _handleLongBreakChangedExternally(num value) { if (value != null) { setState(() { _longBreakValue = value; }); integerNumberPicker.animateInt(value); } } // Animation AnimationController animationController; String get timerString { Duration duration = animationController.duration * animationController.value; return '${duration.inMinutes.toString().padLeft(2, '0')}\n${(duration.inSeconds % 60).toString().padLeft(2, '0')}'; } _onSoundSwitchChanged(bool value) { (soundSwitch == false) ? setState(() { soundSwitch = true; }) : setState(() { soundSwitch = false; }); } _onVibrationSwitchChanged(bool value) { (vibrationSwitch == false) ? setState(() { vibrationSwitch = true; }) : setState(() { vibrationSwitch = false; }); } @override void initState() { super.initState(); animationController = AnimationController(vsync: this, duration: Duration(seconds: 1500)); } @override Widget build(BuildContext context) { final Brightness brightnessValue = MediaQuery.of(context).platformBrightness; bool isDark = brightnessValue == Brightness.dark; integerNumberPicker = new NumberPicker.integer( initialValue: _workSessionValue, minValue: 1, maxValue: 50, onChanged: _handleWorkValueChange, ); integerNumberPicker = new NumberPicker.integer( initialValue: _shortBreakValue, minValue: 1, maxValue: 50, onChanged: _handleShortBreakValueChange, ); integerNumberPicker = new NumberPicker.integer( initialValue: _longBreakValue, minValue: 1, maxValue: 50, onChanged: _handleLongBreakValueChange, ); return Scaffold( backgroundColor: (isDark) ? Color.fromRGBO(38, 38, 52, 1) : Color.fromRGBO(242, 62, 60, 1), body: AnimatedBuilder( animation: animationController, builder: (context, child) { return Container( child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Expanded( child: Align( alignment: FractionalOffset.topCenter, child: Padding( padding: EdgeInsets.only( left: 52, right: 52, bottom: 0, top: 70), child: AspectRatio( aspectRatio: 1, child: Stack( children: <Widget>[ Positioned.fill( child: AnimatedBuilder( animation: animationController, builder: (BuildContext context, Widget child) { return CustomPaint( painter: CustomTimerPainter( animation: animationController, backgroundColor: Colors.white, color: (isDark) ? Color.fromRGBO(92, 211, 62, 1) : Color.fromRGBO(175, 8, 8, 1)), ); }), ), Align( alignment: FractionalOffset.center, child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ AnimatedBuilder( animation: animationController, builder: (BuildContext context, Widget child) { return Text( timerString, style: TextStyle( fontSize: 85.0, fontWeight: FontWeight.w300, color: Colors.white), ); }, ) ], ), ), ], ), ), ), ), ), Padding( padding: const EdgeInsets.all(40), child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Padding( padding: const EdgeInsets.only(bottom: 60), child: Text( "Task Name", textAlign: TextAlign.center, style: TextStyle( color: Colors.white, fontWeight: FontWeight.w400, shadows: [ Shadow( blurRadius: 5, color: Color.fromRGBO(0, 0, 0, 0.5), offset: Offset(0, 3)) ], fontSize: 40), ), ), Padding( padding: const EdgeInsets.only(bottom: 55), child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Text( "0/4", style: TextStyle( color: Colors.white70, fontSize: 32, fontWeight: FontWeight.w600, letterSpacing: 4, shadows: [ Shadow( blurRadius: 5, color: Color.fromRGBO(0, 0, 0, 0.2), offset: Offset(0, 3)) ], ), ), Text( "Count", style: TextStyle( letterSpacing: 1.1, color: Colors.white, fontSize: 22, shadows: [ Shadow( blurRadius: 5, color: Color.fromRGBO(0, 0, 0, 0.3), offset: Offset(0, 3)) ], fontWeight: FontWeight.w400), ), ], ), ), new AnimatedBuilder( animation: animationController, builder: (context, child) { return Container( width: 75.0, height: 75.0, child: new RawMaterialButton( fillColor: Colors.white, shape: new CircleBorder(), elevation: 1.0, child: new Icon( (animationController.isAnimating) ? CupertinoIcons.pause_solid : CupertinoIcons.play_arrow_solid, size: 48, color: (isDark) ? Color.fromRGBO(92, 211, 62, 1) : Color.fromRGBO(242, 60, 62, 1), ), onPressed: () { if (animationController.isAnimating) { animationController.stop(); } else { animationController.reverse( from: animationController.value == 0.0 ? 1.0 : animationController.value); } }, ), ); }, ), ], ), ), ], )); }), floatingActionButton: Container( padding: EdgeInsets.only(top: 40), child: Align( alignment: Alignment.topLeft, child: FloatingActionButton( shape: RoundedRectangleBorder( borderRadius: BorderRadius.only( topLeft: Radius.circular(0), topRight: Radius.circular(0), bottomLeft: Radius.circular(0), bottomRight: Radius.circular(45))), child: Icon( CupertinoIcons.settings_solid, color: (isDark) ? Color.fromRGBO(92, 211, 62, 1) : Color.fromRGBO(242, 62, 60, 1), size: 32, ), elevation: 0.0, backgroundColor: Colors.white, onPressed: () { _openSettingsModal(isDark); }, ), ), ), floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat); } void _openSettingsModal(bool isDark) { showModalBottomSheet( context: context, builder: (context) => Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only( topLeft: Radius.circular(20), topRight: Radius.circular(20), ), ), child: Padding( padding: const EdgeInsets.all(20.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text( "Settings", textAlign: TextAlign.left, style: TextStyle( color: Colors.black, fontSize: 32, fontWeight: FontWeight.w700), ), Divider( thickness: 2, color: Colors.black26, ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Text( "Sound", textAlign: TextAlign.left, style: TextStyle( color: Colors.black, fontSize: 22, fontWeight: FontWeight.w400), ), Row( children: <Widget>[ Transform.scale( scale: 1.3, child: Switch( activeColor: (isDark) ? Color.fromRGBO(92, 211, 62, 1) : Color.fromRGBO(242, 62, 60, 1), inactiveTrackColor: Color.fromRGBO(157, 171, 192, 1), onChanged: _onSoundSwitchChanged, value: soundSwitch, ), ) ], ) ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Text( "Vibration", textAlign: TextAlign.left, style: TextStyle( color: Colors.black, fontSize: 22, fontWeight: FontWeight.w400), ), Row( children: <Widget>[ Transform.scale( scale: 1.3, child: Switch( activeColor: (isDark) ? Color.fromRGBO(92, 211, 62, 1) : Color.fromRGBO(242, 62, 60, 1), inactiveTrackColor: Color.fromRGBO(157, 171, 192, 1), onChanged: _onVibrationSwitchChanged, value: vibrationSwitch, ), ) ], ) ], ), ], ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text("Timer", textAlign: TextAlign.left, style: TextStyle( color: Colors.black, fontSize: 32, fontWeight: FontWeight.w700)), Divider( thickness: 2, color: Colors.black26, ), Padding( padding: const EdgeInsets.all(8.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Text( "Work session", style: TextStyle( color: Colors.black, fontSize: 22, fontWeight: FontWeight.w400), ), Row( children: <Widget>[ Container( width: 30, height: 30, child: RawMaterialButton( shape: new CircleBorder(), onPressed: _showWorkSessionDialog, fillColor: (isDark) ? Color.fromRGBO(92, 211, 62, 1) : Color.fromRGBO(242, 62, 60, 1), elevation: 0, child: Text( "$_workSessionValue", style: TextStyle( color: Colors.white, fontSize: 18, fontWeight: FontWeight.w500), ), ), ), Padding( padding: const EdgeInsets.all(5), child: Text( "min", style: TextStyle( color: Colors.black, fontSize: 18, fontWeight: FontWeight.w500), ), ) ], ) ], ), ), Padding( padding: const EdgeInsets.all(8.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Text( "Short Break", style: TextStyle( color: Colors.black, fontSize: 22, fontWeight: FontWeight.w400), ), Row( children: <Widget>[ Container( width: 30, height: 30, child: RawMaterialButton( shape: new CircleBorder(), onPressed: _showShortBreakDialog, fillColor: (isDark) ? Color.fromRGBO(92, 211, 62, 1) : Color.fromRGBO(242, 62, 60, 1), elevation: 0, child: Text( "$_shortBreakValue", style: TextStyle( color: Colors.white, fontSize: 18, fontWeight: FontWeight.w500), ), ), ), Padding( padding: const EdgeInsets.all(5), child: Text( "min", style: TextStyle( color: Colors.black, fontSize: 18, fontWeight: FontWeight.w500), ), ) ], ) ], ), ), Padding( padding: const EdgeInsets.all(8.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Text( "Long Break", style: TextStyle( color: Colors.black, fontSize: 22, fontWeight: FontWeight.w400), ), Row( children: <Widget>[ Container( width: 30, height: 30, child: RawMaterialButton( shape: new CircleBorder(), onPressed: _showLongBreakDialog, fillColor: (isDark) ? Color.fromRGBO(92, 211, 62, 1) : Color.fromRGBO(242, 62, 60, 1), elevation: 0, child: Text( "$_longBreakValue", style: TextStyle( color: Colors.white, fontSize: 18, fontWeight: FontWeight.w500), ), ), ), Padding( padding: const EdgeInsets.all(5), child: Text( "min", style: TextStyle( color: Colors.black, fontSize: 18, fontWeight: FontWeight.w500), ), ) ], ) ], ), ) ], ) ], ), ), ), ); } _showWorkSessionDialog() { showDialog<int>( context: context, builder: (BuildContext context) { return new NumberPickerDialog.integer( minValue: 0, maxValue: 50, initialIntegerValue: _workSessionValue, title: Text("Select a minute"), ); }, ).then(_handleWorkValueChangedExternally); } _showShortBreakDialog() { showDialog<int>( context: context, builder: (BuildContext context) { return new NumberPickerDialog.integer( minValue: 0, maxValue: 50, initialIntegerValue: _shortBreakValue, title: Text("Select a minute"), ); }, ).then(_handleShortBreakValueChangedExternally); } _showLongBreakDialog() { showDialog<int>( context: context, builder: (BuildContext context) { return new NumberPickerDialog.integer( minValue: 0, maxValue: 50, initialIntegerValue: _longBreakValue, title: Text("Select a minute"), ); }, ).then(_handleLongBreakChangedExternally); } }
0
mirrored_repositories/pomodoro-timer
mirrored_repositories/pomodoro-timer/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:pomodoro_timer/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/noteapp
mirrored_repositories/noteapp/lib/main.dart
import 'package:flutter/material.dart'; import 'package:hive_flutter/adapters.dart'; import 'package:noteapp/screens/dashboard.dart'; import 'package:path_provider/path_provider.dart'; void main() async{ WidgetsFlutterBinding.ensureInitialized(); final dir = await getApplicationDocumentsDirectory(); await Hive.initFlutter(dir.path); runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'NoteApp', theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), useMaterial3: true, ), home: const Dashboard(), ); } }
0
mirrored_repositories/noteapp/lib
mirrored_repositories/noteapp/lib/methods/hive_method.dart
import 'package:hive/hive.dart'; import 'package:noteapp/model/note.dart'; import 'package:uuid/uuid.dart'; class HiveMethod { final String boxName = "notes"; Future<bool> addNote( String title, String note, ) async { try { String id = const Uuid().v1(); var box = await Hive.openBox(boxName); Note noteModel = Note( title: title, note: note, date: DateTime.now(), id: id, ); await box.put(id, noteModel.toJson()); return true; } catch (err) { return false; } } Future<bool> deleteNote(String id) async { try { var box = await Hive.openBox(boxName); await box.delete(id); return true; } catch (err) { return false; } } Future<bool> updateNote(Note noteModel, String id) async { try { var box = await Hive.openBox(boxName); await box.put(id, noteModel.toJson()); return true; } catch (err) { return false; } } }
0
mirrored_repositories/noteapp/lib
mirrored_repositories/noteapp/lib/widgets/custom_appbar.dart
import 'package:flutter/material.dart'; import 'package:noteapp/screens/settings_screen.dart'; import 'package:noteapp/utils/colors.dart'; class CustomAppBar extends StatelessWidget { const CustomAppBar({super.key, required this.values}); final List values; @override Widget build(BuildContext context) { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Image.asset( "assets/fonts/icons/note.png", width: 50, ), Column( children: [ const Text( "Not Defteri", style: style1, ), Text( "${values.length} Adet Not", style: style2, ), ], ), IconButton( onPressed: () { Navigator.of(context).push( MaterialPageRoute( builder: (context) => const SettingPage(), ), ); }, icon: const Icon( Icons.settings, color: Colors.white, ), ), ], ); } }
0
mirrored_repositories/noteapp/lib
mirrored_repositories/noteapp/lib/widgets/note_card.dart
// ignore_for_file: prefer_typing_uninitialized_variables import 'package:flutter/material.dart'; import 'package:noteapp/screens/add_note_screen.dart'; import 'package:noteapp/utils/colors.dart'; class NoteCard extends StatefulWidget { const NoteCard({ super.key, required this.values, }); final values; @override State<NoteCard> createState() => _NoteCardState(); } class _NoteCardState extends State<NoteCard> { @override Widget build(BuildContext context) { return GestureDetector( onTap: () { Navigator.of(context).push( MaterialPageRoute( builder: (context) => AddNoteScreen( editMode: true, note: widget.values, ), ), ); }, child: Container( decoration: BoxDecoration( color: noteCardColor, borderRadius: BorderRadius.circular(15), ), child: Stack( children: [ Padding( padding: const EdgeInsets.symmetric(horizontal: 8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( widget.values["title"], overflow: TextOverflow.ellipsis, style: style1, ), Expanded( child: Text( widget.values["note"], style: style2, ), ), ], ), ), ], ), ), ); } }
0
mirrored_repositories/noteapp/lib
mirrored_repositories/noteapp/lib/widgets/dialog.dart
import 'package:flutter/material.dart'; class NoteChangeDialog extends StatefulWidget { const NoteChangeDialog({ super.key, required this.press, required this.cancel, }); final VoidCallback press; final VoidCallback cancel; @override State<NoteChangeDialog> createState() => _NoteChangeDialogState(); } class _NoteChangeDialogState extends State<NoteChangeDialog> { @override Widget build(BuildContext context) { return AlertDialog( title: const Text("Kaydedilmemiş Değişiklikler Var!"), content: const Text("Değişiklikler kaydedilsin mi?"), actions: [ TextButton( onPressed: widget.cancel, child: const Text("Hayır"), ), TextButton( onPressed: widget.press, child: const Text("Kaydet"), ), ], ); } }
0
mirrored_repositories/noteapp/lib
mirrored_repositories/noteapp/lib/model/note.dart
class Note { Note({ required this.title, required this.note, required this.date, required this.id, }); final String title; final String note; final String id; final DateTime date; factory Note.fromJson(Map<String, dynamic> json) => Note( title: json['title'] as String, note: json["note"] as String, date: json["date"] as DateTime, id: json["id"] as String, ); Map<String, dynamic> toJson() => { 'title': title, 'note': note, "id": id, "date": date, }; }
0
mirrored_repositories/noteapp/lib
mirrored_repositories/noteapp/lib/utils/colors.dart
import 'package:flutter/material.dart'; const Color backColor = Color.fromARGB(255, 53, 52, 121); const Color noteCardColor = Color.fromARGB(255, 53, 35, 94); const Color textColor = Colors.white; const Color subTextColor = Colors.grey; const TextStyle style1 = TextStyle( color: textColor, fontFamily: "Poppins", ); const TextStyle style2 = TextStyle( color: textColor, fontFamily: "Intel", ); const TextStyle subStyle = TextStyle( color: subTextColor, fontFamily: "Intel", );
0
mirrored_repositories/noteapp/lib
mirrored_repositories/noteapp/lib/utils/custom_snack.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; showSnackBar(String content, BuildContext context,Color color) { ScaffoldMessenger.of(context).showSnackBar( SnackBar( shape: const RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(25))), backgroundColor: color, behavior: SnackBarBehavior.floating, margin: const EdgeInsets.only(bottom: 70, left: 4.0, right: 4.0), dismissDirection: DismissDirection.vertical, content: ListTile( dense: false, title: Text(content,style: const TextStyle(color: Colors.white,fontWeight: FontWeight.bold,fontSize: 17 ,fontFamily: 'Poppins'),), leading: const Icon(CupertinoIcons.check_mark_circled,size: 40,color: Colors.white,), ), ), ); }
0
mirrored_repositories/noteapp/lib
mirrored_repositories/noteapp/lib/screens/add_note_screen.dart
// ignore_for_file: use_build_context_synchronously import 'package:flutter/material.dart'; import 'package:noteapp/methods/hive_method.dart'; import 'package:noteapp/model/note.dart'; import 'package:noteapp/utils/custom_snack.dart'; import 'package:noteapp/widgets/dialog.dart'; class AddNoteScreen extends StatefulWidget { const AddNoteScreen({ super.key, required this.editMode, required this.note, }); final bool editMode; final Map note; @override State<AddNoteScreen> createState() => _AddNoteScreenState(); } class _AddNoteScreenState extends State<AddNoteScreen> { final TextEditingController _titleContoller = TextEditingController(); final TextEditingController _noteContoller = TextEditingController(); bool ediMode = true; bool isThereChange = false; void addNote() async { if (_titleContoller.text.isNotEmpty && _noteContoller.text.isNotEmpty) { HiveMethod hive = HiveMethod(); bool response = await hive.addNote(_titleContoller.text, _noteContoller.text); if (response) { //başarılı setState(() { isThereChange = false; }); showSnackBar("Not Eklendi", context, Colors.green); } else { showSnackBar("Not Eklenemedi!", context, Colors.red); //başarısız } } } void updateNote() async { if (_titleContoller.text.isNotEmpty && _noteContoller.text.isNotEmpty) { HiveMethod hive = HiveMethod(); Note note = Note( title: _titleContoller.text, note: _noteContoller.text, date: widget.note["date"], id: widget.note["id"], ); bool response = await hive.updateNote(note, widget.note["id"]); if (response) { setState(() { isThereChange = false; }); //başarılı showSnackBar("Not Güncellendi", context, Colors.green); } else { showSnackBar("Not Güncellenemedi!", context, Colors.red); //başarısız } } } void showDeleteWarning() { showDialog( context: context, builder: (context) { return ShowDeleteWarning( deletePress: deleteNote, ); }); } void deleteNote() async { HiveMethod hive = HiveMethod(); bool response = await hive.deleteNote(widget.note["id"]); if (response) { //başarılı showSnackBar("Not Silindi", context, Colors.green); Navigator.pop(context); } else { showSnackBar("Not Silinemedi!", context, Colors.red); //başarısız } } bool chehckChange() { if (!isThereChange) { Navigator.pop(context); return true; } else { showDialog( context: context, builder: (context) { return NoteChangeDialog( cancel: () { Navigator.pop(context); Navigator.pop(context); }, press: () { //kaydet veye güncelle if (widget.editMode) { updateNote(); } else { addNote(); } }, ); }); return false; } } @override void initState() { if (widget.editMode) { _titleContoller.text = widget.note["title"]; _noteContoller.text = widget.note["note"]; ediMode = false; } super.initState(); } @override void dispose() { _titleContoller.dispose(); _noteContoller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return WillPopScope( onWillPop: () async { bool response = chehckChange(); return await Future.value(response); }, child: Scaffold( backgroundColor: const Color.fromARGB(255, 53, 52, 121), body: SingleChildScrollView( child: Column( children: [ const SizedBox( height: 38, ), Row( children: [ IconButton( splashRadius: 23, onPressed: () { chehckChange(); }, icon: const Icon( Icons.arrow_back_ios_new_rounded, color: Colors.white, ), ), const Spacer(), IconButton( splashRadius: 23, onPressed: () { setState(() { ediMode = !ediMode; }); }, icon: Icon( ediMode ? Icons.edit : Icons.remove_red_eye_rounded, color: Colors.white, ), ), widget.editMode ? IconButton( splashRadius: 23, onPressed: showDeleteWarning, icon: const Icon( Icons.delete, color: Colors.white, ), ) : const SizedBox(), IconButton( splashRadius: 23, onPressed: () { //kaydet veye güncelle if (widget.editMode) { updateNote(); } else { addNote(); } Navigator.pop(context); }, icon: const Icon( Icons.check, color: Colors.white, ), ), ], ), Container( width: double.infinity, padding: const EdgeInsets.symmetric(horizontal: 4.0), margin: const EdgeInsets.symmetric(horizontal: 8.0), decoration: BoxDecoration( color: Colors.black.withOpacity(0.4), borderRadius: BorderRadius.circular(30), ), child: TextFormField( readOnly: !ediMode, controller: _titleContoller, minLines: 1, maxLines: 1, keyboardType: TextInputType.text, style: const TextStyle( color: Colors.white, fontFamily: "Poppins"), onChanged: (s) { if (!isThereChange) { setState(() { isThereChange = true; }); } }, decoration: const InputDecoration( border: InputBorder.none, hintText: "Başlık Giriniz...", ), ), ), const SizedBox( height: 10, ), Padding( padding: const EdgeInsets.all(8.0), child: TextFormField( readOnly: !ediMode, controller: _noteContoller, minLines: 10, maxLines: null, keyboardType: TextInputType.text, style: const TextStyle(color: Colors.white, fontFamily: "Intel"), onChanged: (s) { if (!isThereChange) { setState(() { isThereChange = true; }); } }, decoration: const InputDecoration( border: InputBorder.none, hintText: "Notunuzu Giriniz...", ), ), ) ], ), ), ), ); } } class ShowDeleteWarning extends StatelessWidget { const ShowDeleteWarning({ super.key, required this.deletePress, }); final VoidCallback deletePress; @override Widget build(BuildContext context) { return AlertDialog( title: const Text("Bu Not Silinsin mi?"), content: const Text("Notunuz kalıcı olarak silinir."), actions: [ TextButton( onPressed: () => Navigator.pop(context), child: const Text( "İptal", ), ), TextButton( onPressed: deletePress, child: const Text( "Sil", ), ), ], ); } }
0
mirrored_repositories/noteapp/lib
mirrored_repositories/noteapp/lib/screens/settings_screen.dart
// ignore_for_file: use_build_context_synchronously import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; import 'package:noteapp/utils/colors.dart'; class SettingPage extends StatefulWidget { const SettingPage({super.key}); @override State<SettingPage> createState() => _SettingPageState(); } class _SettingPageState extends State<SettingPage> { void showWarning() { showDialog( context: context, builder: (context) { return AlertDialog( title: const Text("Tüm Notlar Silinsin mi?"), content: const Text("Bu işlem geri alınamaz!"), actions: [ TextButton( onPressed: () => Navigator.pop(context), child: const Text("İptal"), ), TextButton( onPressed: () async { var box = await Hive.openBox("notes"); box.clear(); Navigator.pop(context); }, child: const Text("Sil"), ), ], ); }); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: backColor, body: SafeArea( child: Padding( padding: const EdgeInsets.all(8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ IconButton( splashRadius: 23, onPressed: () => Navigator.pop(context), icon: const Icon( Icons.arrow_back_ios_new_rounded, color: Colors.white, ), ), const Text( "Ayarlar", style:style1, ), ], ), const SizedBox( height: 35, ), ListTile( textColor: textColor, iconColor: textColor, onTap: showWarning, title: const Text("Tüm Notları Silin"), subtitle: const Text("Tüm notlar kalıcı olarak silinir!"), trailing: const Icon(Icons.delete), ), const Spacer(), const Center(child: Text("NoteApp - Youtube/canncoder")), const SizedBox( height: 35, ), ], ), ), ), ); } }
0
mirrored_repositories/noteapp/lib
mirrored_repositories/noteapp/lib/screens/dashboard.dart
import 'package:flutter/material.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:hive/hive.dart'; import 'package:noteapp/screens/add_note_screen.dart'; import 'package:noteapp/utils/colors.dart'; import 'package:noteapp/widgets/custom_appbar.dart'; import 'package:noteapp/widgets/note_card.dart'; class Dashboard extends StatefulWidget { const Dashboard({super.key}); @override State<Dashboard> createState() => _DashboardState(); } class _DashboardState extends State<Dashboard> { Box? noteBox; void boxOpen() async { noteBox = await Hive.openBox("notes"); setState(() {}); } @override void initState() { boxOpen(); super.initState(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: backColor, body: noteBox != null ? StreamBuilder( stream: noteBox!.watch(), builder: (context, streamSnap) { return FutureBuilder( future: Hive.openBox("notes"), builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return const Center( child: CircularProgressIndicator(), ); } if (!snapshot.hasData) { return const Center( child: CircularProgressIndicator(), ); } if (snapshot.hasError) { return const Center( child: Icon(Icons.error), ); } final values = snapshot.data!.values.toList(); values.sort((b, a) => a["date"].compareTo(b["date"])); return SingleChildScrollView( child: Column( children: [ const SizedBox( height: 70, ), CustomAppBar(values: values), const SizedBox( height: 10, ), values.isNotEmpty ? Padding( padding: const EdgeInsets.symmetric( horizontal: 4.0), child: GridView.custom( physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, gridDelegate: SliverQuiltedGridDelegate( crossAxisCount: 3, mainAxisSpacing: 4, crossAxisSpacing: 4, repeatPattern: QuiltedGridRepeatPattern.inverted, pattern: [ const QuiltedGridTile(2, 2), const QuiltedGridTile(1, 1), const QuiltedGridTile(1, 1), ], ), childrenDelegate: SliverChildBuilderDelegate( childCount: values.length, (context, index) => NoteCard( values: values[index], ), ), ), ) : SizedBox( height: MediaQuery.of(context).size.height-200, child: const Center( child: Text( "Hiç Not Yok", style: style1, ), ), ), ], ), ); }); }) : const Center( child: CircularProgressIndicator(), ), floatingActionButton: FloatingActionButton( backgroundColor: const Color.fromARGB(255, 53, 52, 121), onPressed: () { Navigator.of(context).push( MaterialPageRoute( builder: (context) => const AddNoteScreen( editMode: false, note: {}, ), ), ); }, child: const Icon(Icons.add), ), ); } }
0
mirrored_repositories/noteapp
mirrored_repositories/noteapp/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:noteapp/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-signin
mirrored_repositories/flutter-signin/lib/app_main.dart
import 'package:flutter/material.dart'; import 'package:signup/signin.dart'; class AppMain extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Sign Up', debugShowCheckedModeBanner: false, theme: ThemeData( primarySwatch: Colors.purple ), home: SignIn(), ); } }
0
mirrored_repositories/flutter-signin
mirrored_repositories/flutter-signin/lib/signin.dart
import 'package:flutter/material.dart'; import 'package:signup/signup.dart'; class SignIn extends StatefulWidget { @override _SignInState createState() => _SignInState(); } class _SignInState extends State<SignIn> { @override Widget build(BuildContext context) { return Scaffold( body: Container( padding: EdgeInsets.all(24.0), child: ListView( children: <Widget>[ Text( 'S', style: TextStyle( fontSize: 140.0, color: Colors.purple, fontWeight: FontWeight.bold), textAlign: TextAlign.center, ), SizedBox( height: 40.0, ), TextField( maxLines: 1, decoration: InputDecoration( filled: true, labelText: 'Email', ), keyboardType: TextInputType.emailAddress, ), SizedBox(height: 10.0), TextField( maxLines: 1, obscureText: true, decoration: InputDecoration( filled: true, labelText: 'Password', ), ), SizedBox(height: 10.0), OutlineButton( child: Text('Sign In'), onPressed: () {}, padding: EdgeInsets.all(20.0), borderSide: BorderSide(color: Colors.purple), ), SizedBox(height: 4.0), Row(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text('Do not have account?'), FlatButton( child: Text('Sign Up'), onPressed: () { Navigator.push(context, MaterialPageRoute(builder: (context) => SignUp())); }, ) ]) ], ), ), ); } }
0
mirrored_repositories/flutter-signin
mirrored_repositories/flutter-signin/lib/signup.dart
import 'package:flutter/material.dart'; class SignUp extends StatefulWidget { @override _SignUpState createState() => _SignUpState(); } class _SignUpState extends State<SignUp> { @override Widget build(BuildContext context) { return Scaffold( body: Container( padding: EdgeInsets.all(24.0), child: ListView( children: <Widget>[ Text( 'S', style: TextStyle( fontSize: 140.0, color: Colors.purple, fontWeight: FontWeight.bold), textAlign: TextAlign.center, ), SizedBox( height: 40.0, ), TextField( maxLines: 1, decoration: InputDecoration( filled: true, labelText: 'Username', ), ), SizedBox( height: 10.0, ), TextField( maxLines: 1, decoration: InputDecoration( filled: true, labelText: 'Email', ), keyboardType: TextInputType.emailAddress, ), SizedBox(height: 10.0), TextField( maxLines: 1, obscureText: true, decoration: InputDecoration( filled: true, labelText: 'Password', ), ), SizedBox(height: 10.0), OutlineButton( child: Text('Sign Up'), onPressed: () {}, padding: EdgeInsets.all(20.0), borderSide: BorderSide(color: Colors.purple), ), SizedBox(height: 4.0), Row(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text('Already have an account?'), FlatButton( child: Text('Sign In'), onPressed: () { Navigator.pop(context); }, ) ]) ], ), ), ); } }
0
mirrored_repositories/flutter-signin
mirrored_repositories/flutter-signin/lib/main.dart
import 'package:flutter/material.dart'; import 'package:signup/app_main.dart'; void main() => runApp(AppMain());
0
mirrored_repositories/flutter-signin
mirrored_repositories/flutter-signin/test/widget_test.dart
import 'package:flutter_test/flutter_test.dart'; import 'package:signup/app_main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(new AppMain()); }); }
0
mirrored_repositories/Robeats-App
mirrored_repositories/Robeats-App/lib/main.dart
import 'package:Robeats/data/media_library.dart'; import 'package:Robeats/widgets/song_list_screen.dart'; import 'package:flutter/material.dart'; const String TITLE = "Robeats Player"; void main() async { await MediaLibrary().mediaLoader.load(); runApp(new RobeatsApp()); } class RobeatsApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: "Robeats Player", home: SongListScreen(), theme: RobeatsThemeData.getThemeData(), ); } } class RobeatsThemeData { static const Color PRIMARY = Color.fromRGBO(63, 81, 181, 1.0); static const Color LIGHT = Color.fromRGBO(92, 107, 192, 1.0); static const Color DARK = Color.fromRGBO(92, 107, 192, 1.0); static const Color ACCENT = Color.fromRGBO(255, 193, 7, 1.0); static const Color TEXT_COLOUR = Colors.black; static const Color TEXT_COLOUR_INVERSE = Colors.white; static ThemeData _instance; // Cannot be instantiated. RobeatsThemeData._private(); static ThemeData getThemeData() { if (_instance == null) { _instance = ThemeData( primarySwatch: Colors.purple, primaryColor: PRIMARY, primaryColorLight: LIGHT, primaryColorDark: DARK, accentColor: ACCENT, textTheme: TextTheme().apply(displayColor: TEXT_COLOUR), sliderTheme: SliderThemeData.fromPrimaryColors( primaryColor: PRIMARY, primaryColorDark: DARK, primaryColorLight: LIGHT, valueIndicatorTextStyle: TextStyle(color: Colors.white), ).copyWith(trackHeight: 2.0), ); } return _instance; } }
0
mirrored_repositories/Robeats-App/lib
mirrored_repositories/Robeats-App/lib/widgets/shared_widgets.dart
import 'package:Robeats/data/media_library.dart'; import 'package:Robeats/main.dart'; import 'package:Robeats/structures/media.dart'; import 'package:Robeats/widgets/currently_playing/slide_up_panel.dart'; import 'package:Robeats/widgets/local_network_screen.dart'; import 'package:Robeats/widgets/playlists/playlist_screen.dart'; import 'package:Robeats/widgets/song_list_screen.dart'; import 'package:flutter/material.dart'; class RobeatsAppBar extends AppBar { RobeatsAppBar() : super(title: Text(TITLE), iconTheme: IconThemeData(color: Colors.white)); } class RobeatsDrawer extends StatelessWidget { @override Widget build(BuildContext buildContext) { ListTile songListListTile = ListTile( leading: Icon( Icons.book, size: 40.0, ), title: Text("Song List"), onTap: () { Navigator.pushReplacement( buildContext, MaterialPageRoute(builder: (buildContext) => SongListScreen()), ); }, ); ListTile playlistsListTile = ListTile( leading: Icon( Icons.playlist_play, size: 40.0, ), title: Text("Playlists"), onTap: () { Navigator.pushReplacement( buildContext, MaterialPageRoute(builder: (buildContext) => PlaylistScreen()), ); }, ); ListTile networkDevicesListTile = ListTile( leading: Icon( Icons.devices, size: 40.0, ), title: Text("Network Devices"), onTap: () { Navigator.pushReplacement( buildContext, MaterialPageRoute(builder: (buildContext) => LocalNetworkScreen()), ); }, ); List<Widget> children = <Widget>[ DrawerHeader(child: Text("Navigate", style: TextStyle(fontSize: 25.0))), songListListTile, playlistsListTile, networkDevicesListTile, ]; return Drawer(child: ListView(children: children)); } } class DefaultScaffold extends StatelessWidget { final Widget body; final AppBar appBar; final Drawer drawer; final FloatingActionButton floatingActionButton; final FloatingActionButtonLocation floatingActionButtonLocation; DefaultScaffold(this.body, {this.appBar, this.drawer, this.floatingActionButton, this.floatingActionButtonLocation}); @override Widget build(BuildContext context) { return Scaffold( appBar: appBar ?? RobeatsAppBar(), drawer: drawer ?? RobeatsDrawer(), body: RobeatsSlideUpPanel(this.body), floatingActionButton: floatingActionButton, floatingActionButtonLocation: floatingActionButtonLocation, ); } } class SongListTile extends StatelessWidget { final MediaLibrary _mediaLibrary = MediaLibrary(); final Song _song; final Color _colour; final IconData _icon; final bool _selected; SongListTile(this._song, [this._colour, this._icon, this._selected = false]); static List<Widget> prepareTiles(Iterable<Song> iterable, [Song currentSong, Color colour, IconData icon]) { if (iterable != null) { return iterable.map((song) => SongListTile(song, colour, icon, song == currentSong)).toList(growable: false); } else { return []; } } Container createTrailingContainer(Song song) { return Container( child: Row( mainAxisSize: MainAxisSize.min, children: <Widget>[ IconButton( icon: Icon(Icons.queue), onPressed: () { _mediaLibrary.addToQueue(_song); }, ), IconButton( icon: Icon(Icons.play_circle_filled), onPressed: () { _mediaLibrary.playSong(_song); }, ) ], ), ); } @override Widget build(BuildContext context) { String title = _song?.title ?? "Unreadable"; String artist = _song?.artist ?? "Unreadble"; Decoration decoration = BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(5.0)), boxShadow: <BoxShadow>[ BoxShadow( color: _colour ?? Colors.white, spreadRadius: 1.5, ), ], ); return Container( margin: EdgeInsets.only(top: 5.0), decoration: decoration, child: ListTile( dense: true, selected: _selected, leading: Icon(_icon ?? Icons.music_note), title: Text("$title"), subtitle: Text("$artist"), trailing: createTrailingContainer(_song), ), ); } } class RaisedIconButton extends StatelessWidget { final Icon icon; final VoidCallback onPressed; final double elevation; final double highlightElevation; final double disabledElevation; final Color backgroundColour; RaisedIconButton({@required this.icon, @required this.onPressed, this.elevation = 6.0, this.highlightElevation = 12.0, this.disabledElevation = 0.0, this.backgroundColour = Colors.transparent}); @override Widget build(BuildContext context) { return FloatingActionButton( elevation: elevation, highlightElevation: highlightElevation, disabledElevation: disabledElevation, backgroundColor: backgroundColour, onPressed: onPressed, child: icon, ); } }
0
mirrored_repositories/Robeats-App/lib
mirrored_repositories/Robeats-App/lib/widgets/local_network_screen.dart
import 'package:Robeats/device/device.dart'; import 'package:Robeats/widgets/shared_widgets.dart'; import 'package:flutter/material.dart'; class LocalNetworkScreen extends StatelessWidget { @override Widget build(BuildContext context) { return DefaultScaffold( Padding( padding: EdgeInsets.only(top: 10.0), child: _createGridView(), ), ); } GridView _createGridView() { List<Widget> widgets = [_NetworkGridTile(Device.LOCAL_DEVICE)]; //todo: load this from bloc. return GridView.count( crossAxisCount: 3, crossAxisSpacing: 10.0, children: widgets, ); } } class _NetworkGridTile extends StatelessWidget { final Device _device; _NetworkGridTile(this._device); @override Widget build(BuildContext context) { List<Widget> children = <Widget>[ Expanded( flex: 6, child: LayoutBuilder(builder: (context, constraint) => Icon(Icons.devices)), ), Expanded( flex: 4, child: Text( _device.chosenIdentifier, textAlign: TextAlign.center, ), ), ]; Column column = Column( mainAxisAlignment: MainAxisAlignment.center, children: children, ); return GridTile(child: Card(child: column)); } }
0
mirrored_repositories/Robeats-App/lib
mirrored_repositories/Robeats-App/lib/widgets/song_list_screen.dart
import 'package:Robeats/data/media_library.dart'; import 'package:Robeats/structures/media.dart'; import 'package:Robeats/widgets/shared_widgets.dart'; import 'package:flutter/material.dart'; import 'package:rxdart/rxdart.dart'; class SongListScreen extends StatelessWidget { @override Widget build(BuildContext context) { final MediaLibrary mediaLibrary = MediaLibrary(); Observable<List> combined = Observable.combineLatest2( mediaLibrary.mediaLoader.songList.behaviorSubject, mediaLibrary.playerStateData.currentSongStream, (a, b) => [a, b] ); StreamBuilder<List> streamBuilder = StreamBuilder( stream: combined, builder: (_, AsyncSnapshot<List> snapshot) { List<Song> songList = snapshot.data != null ? snapshot.data[0] : []; Song currentSong = snapshot.data != null ? snapshot.data[1] : null; ListView listView = ListView( padding: EdgeInsets.fromLTRB(5, 5, 5, 0), children: SongListTile.prepareTiles(songList, currentSong), ); return Scrollbar(child: listView); }, ); return DefaultScaffold( streamBuilder, ); } }
0
mirrored_repositories/Robeats-App/lib/widgets
mirrored_repositories/Robeats-App/lib/widgets/playlists/playlist_creation_screen.dart
import 'package:Robeats/data/media_library.dart'; import 'package:Robeats/data/media_loader.dart'; import 'package:Robeats/main.dart'; import 'package:Robeats/structures/media.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; class PlaylistCreationDialog extends StatelessWidget { @override Widget build(BuildContext context) { return AlertDialog( title: Text('New playlist'), content: PlaylistCreation(), ); } } class PlaylistCreation extends StatelessWidget { static final formKey = GlobalKey<FormState>(); @override Widget build(BuildContext context) { var textEditingController = TextEditingController(); var formField = TextFormField( cursorColor: RobeatsThemeData.PRIMARY, controller: textEditingController, decoration: InputDecoration(hintText: 'Playlist name', icon: Icon(Icons.input)), validator: _invalidPlaylist, ); Function callback = () { if (formKey.currentState.validate()) { String value = textEditingController.value.text; Playlist.create(value); Navigator.of(context).pop(); } }; Form form = _createForm([formField], callback, context); var icon = ConstrainedBox( constraints: BoxConstraints.loose(Size.square(60)), child: Icon(Icons.library_music, size: 60.0), ); return Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ Expanded(child: icon, flex: 40), Expanded(child: form, flex: 60), ], ); } String _invalidPlaylist(String identifier) { MediaLoader mediaLoader = MediaLibrary().mediaLoader; if (identifier.length < 3 || identifier == null) return "Minimum 3 characters!"; if (mediaLoader .getMatchingPlaylists(identifier) .length > 0) return "Already exists!"; return null; } Form _createForm(List<Widget> fields, Function onPressed, BuildContext context) { List<Widget> children = List<Widget>.from(fields); RaisedButton createButton = RaisedButton( color: RobeatsThemeData.PRIMARY, onPressed: onPressed, textColor: Colors.white, child: Text("Create"), ); children.add(Padding( padding: EdgeInsets.only(top: 20.0), child: createButton, )); return Form( key: formKey, child: Column(children: children), ); } }
0
mirrored_repositories/Robeats-App/lib/widgets
mirrored_repositories/Robeats-App/lib/widgets/playlists/playlist_screen.dart
import 'package:Robeats/data/media_library.dart'; import 'package:Robeats/structures/media.dart'; import 'package:Robeats/widgets/playlists/playlist_creation_screen.dart'; import 'package:Robeats/widgets/shared_widgets.dart'; import 'package:flutter/material.dart'; class PlaylistScreen extends StatelessWidget { @override Widget build(BuildContext context) { final MediaLibrary mediaLibrary = MediaLibrary(); var button = FloatingActionButton( child: Icon(Icons.playlist_add), onPressed: () => showDialog( context: context, builder: (context) => PlaylistCreationDialog(), ), ); return DefaultScaffold( StreamBuilder( stream: mediaLibrary.mediaLoader.playlistSet.behaviorSubject, builder: (_, AsyncSnapshot<Set<Playlist>> snapshot) { return GridView.count(crossAxisCount: 2, crossAxisSpacing: 10.0, children: _prepareWidgets(snapshot)); }, ), floatingActionButton: button, floatingActionButtonLocation: FloatingActionButtonLocation.endTop, ); } List<Widget> _prepareWidgets(AsyncSnapshot<Set<Playlist>> snapshot) { Set<Playlist> playlists = snapshot.data; List<Widget> widgets; if (playlists != null) widgets = playlists.map((playlist) => _PlaylistGridTile(playlist)).toList(); else widgets = []; return widgets; } } class _PlaylistGridTile extends StatelessWidget { final Playlist _playlist; _PlaylistGridTile(this._playlist); @override Widget build(BuildContext context) { List<Widget> children = <Widget>[ Expanded( flex: 6, child: LayoutBuilder( builder: (context, constraint) => Icon(Icons.playlist_play, size: constraint.biggest.height), ), ), Expanded( flex: 4, child: Text( _playlist.identifier, textAlign: TextAlign.center, ), ), ]; Column column = Column( mainAxisAlignment: MainAxisAlignment.center, children: children, ); return GridTile( child: GestureDetector( child: Card(child: column), onTap: () { MediaLibrary().playPlaylist(_playlist); }, ), ); } }
0
mirrored_repositories/Robeats-App/lib/widgets
mirrored_repositories/Robeats-App/lib/widgets/currently_playing/slide_up_panel.dart
import 'dart:async'; import 'dart:collection'; import 'package:Robeats/data/media_library.dart'; import 'package:Robeats/structures/media.dart'; import 'package:Robeats/widgets/currently_playing/play_screen.dart'; import 'package:Robeats/widgets/currently_playing/playing_bottom_sheet.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:rxdart/rxdart.dart'; import 'package:sliding_up_panel/sliding_up_panel.dart'; class RobeatsSlideUpPanel extends StatefulWidget { final Widget _body; RobeatsSlideUpPanel(this._body); @override State<StatefulWidget> createState() { return _SlideUpPanelState(_body); } } class _SlideUpPanelState extends State<RobeatsSlideUpPanel> { final _panelController = PanelController(); final Widget _body; StreamSubscription _streamSubscription; _SlideUpPanelState(this._body); @override Widget build(BuildContext context) { _initiateSubscription(); return SlidingUpPanel( minHeight: 90, backdropEnabled: true, margin: EdgeInsets.only(bottom: 8.0), padding: EdgeInsets.all(0.0), renderPanelSheet: false, controller: _panelController, panel: PlayScreen(), collapsed: PlayingBottomSheet(), color: Colors.transparent, body: _body, ); } void _initiateSubscription() { MediaLibrary mediaLibrary = MediaLibrary(); Observable<List> observable = Observable.combineLatest2( mediaLibrary.playerStateData.currentSongStream, mediaLibrary.songQueue.behaviorSubject, (a, b) => [a, b], ); _streamSubscription?.cancel(); _streamSubscription = observable.listen( (streams) { Song currentSong = streams[0]; Queue<Song> queue = streams[1]; if (currentSong == null && queue.isEmpty) _panelController.hide(); else _panelController.show(); }, ); } @override void dispose() { _streamSubscription.cancel(); super.dispose(); } }
0
mirrored_repositories/Robeats-App/lib/widgets
mirrored_repositories/Robeats-App/lib/widgets/currently_playing/playing_bottom_sheet.dart
import 'package:Robeats/data/media_library.dart'; import 'package:Robeats/structures/media.dart'; import 'package:audioplayers/audioplayers.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; class PlayingBottomSheet extends StatelessWidget { @override Widget build(BuildContext context) { final mediaLibrary = MediaLibrary(); return StreamBuilder( stream: mediaLibrary.playerStateData.currentSongStream, builder: (_, AsyncSnapshot<Song> snapshot) { if (snapshot.data == null && mediaLibrary.songQueue.isEmpty) { return Container(height: 0); } return _PlayingContainer(snapshot.data == null ? mediaLibrary.songQueue.first : snapshot.data); }, ); } } class _PlayingContainer extends StatelessWidget { final Song _song; _PlayingContainer(this._song); @override Widget build(BuildContext context) { final MediaLibrary mediaLibrary = MediaLibrary(); String title = _song.title ?? "Unreadable"; String artist = _song.artist ?? "Unreadable"; StreamBuilder<AudioPlayerState> streamBuilder = StreamBuilder( stream: mediaLibrary.playerStateData.songStateStream, builder: (_, AsyncSnapshot<AudioPlayerState> snapshot) { return IconButton( iconSize: 30.0, icon: Icon(_chooseIcon(snapshot.data)), onPressed: () => mediaLibrary.toggleState(), ); }, ); ListTile listTile = ListTile( leading: Row( mainAxisSize: MainAxisSize.min, children: <Widget>[ Icon( Icons.music_note, size: 30.0, ), ], ), title: Text(title), subtitle: Text(artist), trailing: Row( mainAxisSize: MainAxisSize.min, children: <Widget>[ streamBuilder, ], ), ); return Padding( padding: EdgeInsets.only(left: 8.0, right: 8.0), child: Container( child: Column( children: <Widget>[ SizedBox( height: 10.0, ), Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Container( width: 30, height: 5, decoration: BoxDecoration( color: Colors.grey[300], borderRadius: BorderRadius.all(Radius.circular(12.0)), ), ), ], ), listTile, ], ), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(5.0)), ), ), ); } IconData _chooseIcon(AudioPlayerState state) { return state == AudioPlayerState.PLAYING ? Icons.pause_circle_filled : Icons.play_circle_filled; } }
0
mirrored_repositories/Robeats-App/lib/widgets
mirrored_repositories/Robeats-App/lib/widgets/currently_playing/play_screen.dart
import 'dart:collection'; import 'dart:core'; import 'package:Robeats/data/media_library.dart'; import 'package:Robeats/structures/media.dart'; import 'package:Robeats/widgets/shared_widgets.dart'; import 'package:audioplayers/audioplayers.dart'; import 'package:flutter/material.dart'; class PlayScreen extends StatelessWidget { @override Widget build(BuildContext context) { List<Widget> children = <Widget>[ Expanded(flex: 1, child: _MediaDisplay()), Expanded(flex: 1, child: _MediaControls()), Expanded(flex: 2, child: _QueueSongList()), ]; return Scaffold( appBar: _prepareAppBar(), body: Column(children: children), ); } AppBar _prepareAppBar() { Icon icon = Icon(Icons.keyboard_arrow_down, size: 30.0, color: Colors.grey[400]); return AppBar(leading: icon, elevation: 0, backgroundColor: Colors.transparent); } } class _MediaDisplay extends StatelessWidget { final MediaLibrary _mediaLibrary = MediaLibrary(); final TextStyle _songStyle = TextStyle(fontSize: 25.0); final TextStyle _artistStyle = TextStyle(fontSize: 15.0); @override Widget build(BuildContext context) { MediaQueryData data = MediaQuery.of(context); StreamBuilder<Song> streamBuilder = StreamBuilder( stream: _mediaLibrary.playerStateData.currentSongStream, builder: _prepareWidgetBuilder(), ); return Container( child: streamBuilder, ); } AsyncWidgetBuilder<Song> _prepareWidgetBuilder() { return (_, AsyncSnapshot<Song> snapshot) { String title = snapshot.data == null ? "Choose a song!" : snapshot.data.title ?? "Unreadable"; String artist = snapshot.data?.artist ?? ""; Row titleRow = Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[Text("$title", style: _songStyle)], ); Row artistRow = Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[Text("$artist", style: _artistStyle)], ); List<Widget> children = <Widget>[Padding(padding: EdgeInsets.only(top: 25.0), child: titleRow), artistRow]; return Column(children: children); }; } } class _MediaControls extends StatelessWidget { final MediaLibrary _mediaLibrary = MediaLibrary(); @override Widget build(BuildContext context) { List<Widget> children = <Widget>[_durationRow(), _controlsRow()]; return Column(children: children); } Row _durationRow() { StreamBuilder<double> streamBuilder = StreamBuilder( stream: _mediaLibrary.playerStateData.songDurationStream, builder: (_, AsyncSnapshot<double> snapshot) { double value = snapshot?.data; return Slider(value: value ?? 0, onChanged: (value) => _mediaLibrary.seekFraction(value)); }, ); List<Widget> children = [Flexible(flex: 1, child: streamBuilder)]; return Row(children: children); } Row _controlsRow() { StreamBuilder<AudioPlayerState> songStateStreamBuilder = StreamBuilder( stream: _mediaLibrary.playerStateData.songStateStream, builder: (_, AsyncSnapshot<AudioPlayerState> snapshot) { return IconButton( iconSize: 60, icon: Icon(_chooseIcon(snapshot.data)), onPressed: () => _mediaLibrary.toggleState(), ); }, ); List<Widget> children = <Widget>[ IconButton( iconSize: 40.0, icon: Icon(Icons.skip_previous), onPressed: () => _mediaLibrary.playPrevious(), ), songStateStreamBuilder, IconButton( iconSize: 40.0, icon: Icon(Icons.skip_next), onPressed: () => _mediaLibrary.playNext(), ), ]; return Row(mainAxisAlignment: MainAxisAlignment.center, children: children); } IconData _chooseIcon(AudioPlayerState state) { return state == AudioPlayerState.PLAYING ? Icons.pause_circle_filled : Icons.play_circle_filled; } } class _QueueSongList extends StatelessWidget { final MediaLibrary _mediaLibrary = MediaLibrary(); @override Widget build(BuildContext context) { return StreamBuilder( stream: _mediaLibrary.songQueue.behaviorSubject, builder: (_, AsyncSnapshot<Queue<Song>> snapshot) { ListView listView = ListView( padding: EdgeInsets.fromLTRB(5, 0, 5, 0), children: _QueueSongListTile.prepareTiles(snapshot?.data), ); return Scrollbar(child: listView); }, ); } } class _QueueSongListTile extends SongListTile { final MediaLibrary _mediaLibrary = MediaLibrary(); _QueueSongListTile(Song song, [bool selected = false]) : super(song, Colors.white10, Icons.queue_play_next, selected); static List<Widget> prepareTiles(Iterable<Song> iterable, [Song currentSong, Color colour, IconData icon]) { if (iterable != null) { return iterable.map((song) => _QueueSongListTile(song, currentSong == song)).toList(growable: false); } else { return []; } } @override Container createTrailingContainer(Song song) { return Container( child: Row( mainAxisSize: MainAxisSize.min, children: <Widget>[ IconButton( icon: Icon(Icons.play_circle_filled), onPressed: () { if (_mediaLibrary.songQueue.remove(song)) { _mediaLibrary.playSong(song); } }, ) ], ), ); } }
0
mirrored_repositories/Robeats-App/lib
mirrored_repositories/Robeats-App/lib/device/device.dart
/** * An interface representing a Device, this is any device running an instance of Robeats. This can be the desktop * software, or an app on Android or iOS. */ abstract class Device { static const LocalDevice LOCAL_DEVICE = const LocalDevice._private(); String get chosenIdentifier; } /** * A class, implementing [Device], representing a foreign (non-local) device running a Robeats instance. */ class ForeignDevice implements Device { final int id; String chosenIdentifier; ForeignDevice(this.id, this.chosenIdentifier); } /** * A class, implementing [Device], representing this local instance of Robeats. */ class LocalDevice implements Device { const LocalDevice._private(); @override String get chosenIdentifier => "Local Device"; }
0
mirrored_repositories/Robeats-App/lib
mirrored_repositories/Robeats-App/lib/data/media_loader.dart
import 'dart:io'; import 'dart:math'; import 'package:Robeats/persistence/json/json_manager.dart'; import 'package:Robeats/persistence/json/structures/json_file.dart'; import 'package:Robeats/structures/data_structures/stream_collection/stream_list.dart'; import 'package:Robeats/structures/data_structures/stream_collection/stream_set.dart'; import 'package:Robeats/structures/media.dart'; import 'package:crypto/crypto.dart'; import 'package:dart_tags/dart_tags.dart'; import 'package:path_provider/path_provider.dart'; /** * This class is reponsible for loading all media files, i.e. the songs and playlists themselves. */ class MediaLoader { JsonManager _jsonManager; StreamList<Song> _songList = StreamList(); StreamSet<Playlist> _playlistSet = StreamSet(); JsonManager get jsonManager => _jsonManager; StreamList<Song> get songList => _songList; StreamSet<Playlist> get playlistSet => _playlistSet; Song get randomSong { return _songList.elementAt(new Random().nextInt(_songList.length)); } /** * Get the [Directory] that music is all saved to. * If it does not exist, create it. * Async, as path_provider dictates. */ static Future<Directory> get directory async { Directory appDataDirectory = await getApplicationDocumentsDirectory(); appDataDirectory = new Directory(appDataDirectory.path + "/" + "music"); if (!appDataDirectory.existsSync()) { appDataDirectory.create(recursive: false); } return appDataDirectory; } /** * Utility function - returns the file name based on a [FileSystemEntity]'s path. * E.g. /a/b/c/song.mp3 would return song.mp3 */ static String _getFileName(FileSystemEntity entity) { return entity.path .split('/') .last; } /** * Utility function - returns the ID3 [Tag] based on a song. Depending on * the tag type used, either is returned. This could either be ID3v1 or * ID3v2. */ static Future<Tag> _metaTags(File file) async { TagProcessor tagProcessor = TagProcessor(); List<Tag> tags = await tagProcessor.getTagsFromByteArray( file.readAsBytes(), ); return tags.firstWhere((tag) => tag != null && tag.tags.isNotEmpty, orElse: () => null); } /** * Load all songs & playlists. */ Future<void> load() async { await _loadSongs().then((_) => _initialiseJsonManager()).then((_) => _loadPlaylists()); } Future<void> _initialiseJsonManager() async { List<String> files = <String>[ "_playlists.json", ]; _jsonManager = JsonManager(await directory, files); await _jsonManager.loadAll(); } /** * (Recursively) loop through all files of the [Directory]. Any files * with type .mp3 will be loaded, tags read, [Song] objects created * and added to the [_songList]. */ Future<void> _loadSongs() async { List<FileSystemEntity> entities = (await directory).listSync(recursive: true); for (FileSystemEntity entity in entities) { String fileName = _getFileName(entity); if (entity is File && fileName.endsWith(".mp3")) { Tag metaTags = await _metaTags(entity); String songTitle = metaTags?.tags['title']; String artist = metaTags?.tags['artist']; String hash = md5.convert(entity.readAsBytesSync()).toString(); Song song = Song(fileName, songTitle, hash, artist, null); _songList.add(song); } } } /** * Loop through all playlists in the _playlists.json file. Any songs * whose hash is in the list 'songs' will be added the the [Playlist]. * This [Playlist] will be added to [_playlistSet] */ Future<void> _loadPlaylists() async { JsonFile playlists = _jsonManager.jsonFiles['_playlists.json']; for (MapEntry<String, dynamic> entry in playlists.data.entries) { Playlist playlist = Playlist.deserialise(entry.key, entry.value); _playlistSet.add(playlist); } } Iterable<Playlist> getMatchingPlaylists(String identifier) { bool matching(String a, String b) => a?.toLowerCase() == b?.toLowerCase(); return _playlistSet.where((playlist) => matching(playlist.identifier, identifier)); } }
0
mirrored_repositories/Robeats-App/lib
mirrored_repositories/Robeats-App/lib/data/media_library.dart
import 'dart:collection'; import 'dart:io'; import 'package:Robeats/data/media_loader.dart'; import 'package:Robeats/data/streams/player_state_data.dart'; import 'package:Robeats/structures/data_structures/stack.dart'; import 'package:Robeats/structures/data_structures/stream_collection/stream_queue.dart'; import 'package:Robeats/structures/media.dart'; import 'package:audioplayers/audioplayers.dart'; /** * The MediaLibrary is responsible for playing songs, managing the currently playing song, and managing the queue * of songs. This is a singleton as only one MediaLibrary can exist for the app. Furthermore, this class contains * the MediaLoader instance that will be used; i.e. the MediaLoader belongs to the MediaLibrary. */ class MediaLibrary { static final MediaLibrary _instance = MediaLibrary._private(); final MediaLoader _mediaLoader = MediaLoader(); PlayerStateData _playerStateData = PlayerStateData(); AudioPlayer _audioPlayer = AudioPlayer(); Stack<Song> _songStack = Stack(); StreamQueue<Song> _songQueue = StreamQueue(); MediaLibrary._private() { _initialiseAudioEvents(); } factory MediaLibrary() { return _instance; } MediaLoader get mediaLoader => _mediaLoader; PlayerStateData get playerStateData => _playerStateData; StreamQueue<Song> get songQueue => _songQueue; Song get currentlyPlayingSong => _playerStateData.currentSongStream.value; /** * Listens to the stream for duration changes, and send it to the sink of * the [SongStateDataController] to update the UI. */ void _initialiseAudioEvents() { _audioPlayer.onAudioPositionChanged.listen((duration) { double durationFraction = 0; if (currentlyPlayingSong.duration != null) { durationFraction = (duration.inSeconds / currentlyPlayingSong.duration.inSeconds); } _playerStateData.songDurationStream.add(durationFraction); }); _audioPlayer.onPlayerCompletion.listen((event) { if (_songQueue.isNotEmpty) { playQueue(); } else { stop(); } }); _audioPlayer.onPlayerStateChanged.listen((state) { _playerStateData.songStateStream.add(state); }); } /** * This loads the URL of the [Song], by getting its [Directory]. * Once the song is played, the [_currentlyPlayingSong] is set to it, * and added to the [SongStateDataController]'s sink. * * The song is added to the stack, so when the previous button is pressed, * the top of the stack can simply be popped. The optional parameter stack * describes whether it should be pushed or not - the notable case where * it wouldn't, is where we are playing the previous song; to avoid a loop. * * Furthermore, the [Song]'s [Duration] has now been by audioplayers and can * be set. */ void playSong(Song song, [bool stack = true]) async { String url = await song.directory; if (stack && currentlyPlayingSong != null) { _songStack.push(currentlyPlayingSong); } _audioPlayer.play(url, volume: 0.35); _playerStateData.currentSongStream.add(song); song.duration ??= await _audioPlayer.onDurationChanged.first; } bool addToQueue(Song song) { if (!_songQueue.contains(song)) { _songQueue.add(song); return true; } return false; } /** * Play all songs in the [Queue]. The queue can be added to from the songs * list screen. */ void playQueue() { if (_songQueue.isNotEmpty) { Song song = _songQueue.removeFirst(); playSong(song); } } /** * Clear the [Queue] and add all songs from a [Playlist] to the * [_songQueue]. */ void playPlaylist(Playlist playlist) { _songQueue.clear(); _songQueue.addAll(playlist.songs); playQueue(); } /** * 'state' refers to the [AudioPlayer]'s current [AudioPlayerState]. * This could describe a song either: Stopped, Playing, Paused, or * Completed. * * If the state is PLAYING, then this pauses the song. If the song is * PAUSED, then it must be resumed. */ void toggleState() { AudioPlayerState state = _audioPlayer.state; switch (state) { case AudioPlayerState.PLAYING: _audioPlayer.pause(); break; case AudioPlayerState.PAUSED: _audioPlayer.resume(); break; default: if (_songQueue.isNotEmpty) playQueue(); break; } } /** * This stops the song. It calls [AudioPlayer]'s pause stop method, * and releases its resources, in case that no other songs will be played. * * Furthermore, the variable [_currentlyPlayingSong] and the sink in * [SongStateDataController] are returned to their original state: null. */ void stop() { _audioPlayer.stop(); _audioPlayer.release(); _playerStateData.currentSongStream.add(null); _playerStateData.songDurationStream.add(0); } /** * Pop the last element from the stack, and if it's not null, play it. */ void playPrevious() { Song song = _songStack.pop(); if (song != null) playSong(song, false); } /** * If the [Queue] is not empty, play the next song. If it is empty and * the user is currently playing another song, play the next one. If * they are not currently playing a song, play a random song. */ void playNext() { if (_songQueue.isNotEmpty) { playQueue(); return; } Song song; if (currentlyPlayingSong != null) { int index = _mediaLoader.songList.indexOf(currentlyPlayingSong) + 1; index %= _mediaLoader.songList.length; song = _mediaLoader.songList[index]; } else song = _mediaLoader.randomSong; playSong(song); } /** * Seeks the current position in the song (i.e. the cursor) to a fraction * of the total duration. * Null checks must be done on totalDuration, as if no song is playing, or * it's not loaded - due to it being async, it will return null. If it is * null no seeking will be done. */ void seekFraction(double fraction) async { Duration totalDuration = currentlyPlayingSong?.duration; if (totalDuration != null) { Duration duration = totalDuration * fraction; seekTime(duration, fraction: fraction); } } /** * Seeks the current position in the song (i.e. the cursor) to a specific * [Duration] and adds the fraction to the sink, if it's not -1. * * All checks for time extending the song's length are done * by audioplayers. */ void seekTime(Duration duration, {double fraction: -1}) { _audioPlayer.seek(duration); if (fraction != -1) { _playerStateData.songDurationStream.add(fraction); } } }
0
mirrored_repositories/Robeats-App/lib/data
mirrored_repositories/Robeats-App/lib/data/streams/player_state_data.dart
import 'package:Robeats/structures/media.dart'; import 'package:audioplayers/audioplayers.dart'; import 'package:rxdart/rxdart.dart'; class PlayerStateData { BehaviorSubject<Song> _currentSongStream = BehaviorSubject(); BehaviorSubject<double> _songDurationStream = BehaviorSubject(); BehaviorSubject<AudioPlayerState> _songStateStream = BehaviorSubject(); BehaviorSubject<Song> get currentSongStream => _currentSongStream; BehaviorSubject<double> get songDurationStream => _songDurationStream; BehaviorSubject<AudioPlayerState> get songStateStream => _songStateStream; PlayerStateData() { //Trigger initial update to all listeners _currentSongStream.add(null); } }
0
mirrored_repositories/Robeats-App/lib/persistence
mirrored_repositories/Robeats-App/lib/persistence/json/json_manager.dart
import 'dart:io'; import 'package:Robeats/persistence/json/structures/json_file.dart'; class JsonManager { final Map<String, JsonFile> _jsonFiles = {}; final List<File> _fileList = []; JsonManager(Directory directory, List<String> fileNames) { for (String path in fileNames) _fileList.add(File(directory.path + '/' + path)); } Map<String, JsonFile> get jsonFiles => _jsonFiles; /** * Load all [File]s, if they're a Json file, and add them to the [List]. */ Future<void> loadAll() async { for (File file in _fileList) { String fileName = file.path.split('/').last; if (_jsonFiles.containsKey(fileName)) await _jsonFiles[fileName].reloadFile(); else { JsonFile jsonFile = JsonFile(file); _jsonFiles[fileName] = jsonFile; await jsonFile.reloadFile(); } } } }
0
mirrored_repositories/Robeats-App/lib/persistence/json
mirrored_repositories/Robeats-App/lib/persistence/json/structures/json_file.dart
import 'dart:convert'; import 'dart:io'; import 'package:Robeats/persistence/json/structures/json_serialisable.dart'; const String EMPTY_OBJECT = "{}"; class JsonFile { Map<String, dynamic> data = {}; final File _file; /** * Constructor to instantiate a [JsonFile]. */ JsonFile(this._file); /** * Private utility method, if the [File] does not exist, create it. If the parameter write * is true, then write an empty object "{}" to the [File] as well. Otherwise, merely create * the [File]. Returns true if a new file was created and/or written to. */ Future<bool> _createIfNotExists([bool write = true]) async { if (_file != null && !_file.existsSync()) if (write) await _file.writeAsString(EMPTY_OBJECT); else await _file.create(); return false; } /** * Create the file if it does not exist, and if it did exist, read its data to the [Map]. */ Future<void> reloadFile() async { if (!(await _createIfNotExists())) { String fileContent = await _file.readAsString(); data = jsonDecode(fileContent); } } /** * Create the file if it does not exist, and serialise the [Map] and write it to the file. */ Future<void> saveFile() async { await _createIfNotExists(false); String dataContent = jsonEncode(data); await _file.writeAsString(dataContent); } /** * Convenience function to write a [JsonSerialisable] object to the [Map]. */ void put(String key, JsonSerialisable serialisable) { Map<String, dynamic> serialised = serialisable.serialise(); data[key] = serialised; } }
0
mirrored_repositories/Robeats-App/lib/persistence/json
mirrored_repositories/Robeats-App/lib/persistence/json/structures/json_serialisable.dart
import 'dart:convert' as convert; abstract class JsonSerialisable { /** * Turn this [JsonSerialisable] object into a [Map]. */ Map<String, dynamic> serialise(); /** * Turn this object into a [Map], and then encode it to JSON. */ String jsonEncode() { return convert.jsonEncode(this, toEncodable: (_) => serialise()); } }
0
mirrored_repositories/Robeats-App/lib
mirrored_repositories/Robeats-App/lib/structures/media.dart
import 'package:Robeats/data/media_library.dart'; import 'package:Robeats/data/media_loader.dart'; import 'package:Robeats/persistence/json/structures/json_file.dart'; import 'package:Robeats/persistence/json/structures/json_serialisable.dart'; class Song { String _fileName; String title; String hash; String artist; Duration duration; Song(String fileName, String title, String hash, String artist, Duration duration) { this._fileName = fileName; this.title = title; this.hash = hash; this.artist = artist; this.duration = duration; } /** * Retrieve the directory of the song. */ Future<String> get directory async { String path = (await MediaLoader.directory).path; return path + "/$_fileName"; } /** * Override of the equals operator. This works by checking that the hash * of the song's mp3 file is equal. */ @override bool operator ==(Object other) => identical(this, other) || other is Song && runtimeType == other.runtimeType && hash == other.hash; @override int get hashCode => hash.hashCode; } class Playlist extends JsonSerialisable { String identifier; List<Song> songs; Playlist(this.identifier, this.songs); /** * Deserialise a [Playlist] from its Json [Map]. */ factory Playlist.deserialise(String identifier, Map<String, dynamic> serialised) { MediaLoader mediaLoader = MediaLibrary().mediaLoader; List<String> hashes = List<String>.from(serialised['songs']); List<Song> songs = mediaLoader.songList.where((song) => hashes.contains(song.hash)).toList(); return Playlist(identifier, songs); } factory Playlist.create(String identifier) { return Playlist(identifier, []) ..save(); } /** * Serialise a [Playlist] into a Json string. */ Map<String, dynamic> serialise() { return <String, dynamic>{ "songs": songs.map((s) => s.hash).toList(growable: false), }; } void save() async { MediaLoader mediaLoader = MediaLibrary().mediaLoader; JsonFile file = mediaLoader.jsonManager.jsonFiles['_playlists.json']; mediaLoader.playlistSet.add(this); file.put(identifier, this); file.saveFile(); } /** * Override of the equals operator. This works by checking the identifier * (name) of the playlist, and the data structure holding all its [Song]s. */ @override bool operator ==(Object other) { return identical(this, other) || other is Playlist && runtimeType == other.runtimeType && identifier == other.identifier && songs == other.songs; } @override int get hashCode { return identifier.hashCode ^ songs.hashCode; } }
0
mirrored_repositories/Robeats-App/lib/structures
mirrored_repositories/Robeats-App/lib/structures/data_structures/stack.dart
import 'dart:collection'; /** * The purpose of this class is slightly trivial and unnecessary, however * using a list, and pretending it's a stack is confusing at times. Simply * having a class, albeit a wrapper class, for a stack is helpful. */ class Stack<T> { Queue<T> _queue = Queue(); Stack(); bool get isEmpty => _queue.isEmpty; bool get isNotEmpty => !isEmpty; void push(T t) { if (isEmpty) { _queue.addFirst(t); } } T pop() { return isNotEmpty ? _queue.removeFirst() : null; } T peek() { return isNotEmpty ? _queue.first : null; } }
0
mirrored_repositories/Robeats-App/lib/structures/data_structures
mirrored_repositories/Robeats-App/lib/structures/data_structures/stream_collection/stream_queue.dart
import 'dart:collection'; import 'package:rxdart/rxdart.dart'; /** * Wrapper class for a [Queue]. This enables most changes to be registered with * a [BehaviorSubject]. */ class StreamQueue<E> extends ListQueue<E> { BehaviorSubject<Queue<E>> _behaviorSubject; StreamQueue() { this._behaviorSubject = BehaviorSubject(); _behaviorSubject.add(this); } BehaviorSubject<Queue<E>> get behaviorSubject => _behaviorSubject; @override void clear() { super.clear(); _behaviorSubject.add(this); } @override bool remove(Object value) { bool val = super.remove(value); _behaviorSubject.add(this); return val; } @override void add(E value) { super.add(value); _behaviorSubject.add(this); } @override E removeLast() { E e = super.removeLast(); _behaviorSubject.add(this); return e; } @override E removeFirst() { E e = super.removeFirst(); _behaviorSubject.add(this); return e; } @override void addFirst(E value) { super.add(value); _behaviorSubject.add(this); } @override void addLast(E value) { super.add(value); _behaviorSubject.add(this); } @override void retainWhere(bool test(E element)) { super.retainWhere(test); _behaviorSubject.add(this); } @override void removeWhere(bool test(E element)) { super.removeWhere(test); _behaviorSubject.add(this); } @override void addAll(Iterable<E> elements) { super.addAll(elements); _behaviorSubject.add(this); } }
0
mirrored_repositories/Robeats-App/lib/structures/data_structures
mirrored_repositories/Robeats-App/lib/structures/data_structures/stream_collection/stream_list.dart
import 'package:collection/collection.dart'; import 'package:rxdart/rxdart.dart'; /** * Wrapper class for a [List]. This enables most changes to be registered with * a [BehaviorSubject]. */ class StreamList<E> extends DelegatingList<E> { BehaviorSubject<List<E>> _behaviorSubject; StreamList() : super(List()) { this._behaviorSubject = BehaviorSubject(); _behaviorSubject.add(this); } BehaviorSubject<List<E>> get behaviorSubject => _behaviorSubject; @override void clear() { super.clear(); _behaviorSubject.add(this); } @override bool remove(Object value) { super.remove(value); _behaviorSubject.add(this); } @override void add(E value) { super.add(value); _behaviorSubject.add(this); } @override E removeLast() { E e = super.removeLast(); _behaviorSubject.add(this); return e; } @override void retainWhere(bool test(E element)) { super.retainWhere(test); _behaviorSubject.add(this); } @override void removeWhere(bool test(E element)) { super.removeWhere(test); _behaviorSubject.add(this); } @override void addAll(Iterable<E> elements) { super.addAll(elements); _behaviorSubject.add(this); } }
0