repo_id
stringlengths
21
168
file_path
stringlengths
36
210
content
stringlengths
1
9.98M
__index_level_0__
int64
0
0
mirrored_repositories/juice-bar/lib/ui
mirrored_repositories/juice-bar/lib/ui/widgets/g_navbar_widget.dart
import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:google_nav_bar/google_nav_bar.dart'; class GNavBarWidget extends StatelessWidget { final void Function(int)? onTab; const GNavBarWidget({super.key, this.onTab}); @override Widget build(BuildContext context) { return Container( color: Colors.yellow.shade100, padding: const EdgeInsets.symmetric(vertical: 15), child: GNav( color: Colors.grey.shade400, activeColor: Colors.grey.shade700, mainAxisAlignment: MainAxisAlignment.center, tabActiveBorder: Border.all(color: Colors.white), tabBackgroundColor: Colors.white, backgroundColor: Colors.yellow.shade100, tabBorderRadius: 16, gap: 3, textStyle: GoogleFonts.varelaRound(fontSize: 15), // onTabChange: (value)=> onTab!(value), onTabChange: onTab!, // tabs: const [ GButton(icon: Icons.home, text: 'Home'), GButton(icon: Icons.shopping_bag, text: 'Cart'), ]), ); } }
0
mirrored_repositories/juice-bar/lib/ui
mirrored_repositories/juice-bar/lib/ui/screens/see_all_screen.dart
import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:get/get.dart'; import 'package:google_fonts/google_fonts.dart'; class SeeAllScreen extends StatefulWidget { const SeeAllScreen({super.key}); @override State<SeeAllScreen> createState() => _SeeAllScreenState(); } class _SeeAllScreenState extends State<SeeAllScreen> { // final JuiceJson _juiceJson = JuiceJson(); // @override // void initState() { // JuiceJson.readJson(); // _juiceJson.list; // super.initState(); // } List _list = []; Future<void> readJson() async { final String response = await rootBundle.loadString('assets/juiceshop.json'); final data = await json.decode(response); setState(() { _list = data['juices']; }); } @override void initState() { readJson(); super.initState(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.yellow.shade100, appBar: AppBar( backgroundColor: Colors.yellow.shade100, elevation: 0, leading: IconButton( onPressed: () { Get.back(); // Navigator.pop(context); }, icon: const Icon( Icons.arrow_back_ios_rounded, color: Colors.grey, )), ), body: Padding( padding: const EdgeInsets.all(15.0), child: Column( children: [ // checking data availability _list.isNotEmpty ? Expanded( child: ListView.builder( scrollDirection: Axis.vertical, itemCount: _list.length, itemBuilder: (BuildContext context, int index) { // card return Card( color: Colors.green.shade100, child: Padding( padding: const EdgeInsets.all(15.0), child: Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ SizedBox( height: 40, child: Image.asset( _list[index]['imagePath']), ), const SizedBox(width: 20), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ // name Text( _list[index]['juiceName'], style: GoogleFonts.ubuntu( fontSize: 20, fontWeight: FontWeight.bold), ), const SizedBox( height: 10, ), // price Row( children: [ Text( '\$${_list[index]['price'].toString()}', style: GoogleFonts.ubuntu( fontWeight: FontWeight.bold), ), // how much sales Text( '(542)', style: GoogleFonts.ubuntu(), ), ], ), ], ), ], ), Container( height: 40, width: 40, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Colors.lightGreen.shade600), child: IconButton( icon: const Icon( Icons.shopping_cart_checkout_rounded, color: Colors.white, ), onPressed: () => {}, ), ) ], ), // child: Text(_list[index]['juiceName']), ), ); }, ), ) : const Center( child: Text('Data not founded'), ), ], ), ), ); } }
0
mirrored_repositories/juice-bar/lib/ui
mirrored_repositories/juice-bar/lib/ui/screens/home_screen.dart
import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:get/get.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:juicebar/constants/text_styles.dart'; import 'package:juicebar/controllers/cart_controllers.dart'; import 'package:juicebar/ui/screens/see_all_screen.dart'; import '../widgets/popular_widgets.dart'; import '../widgets/recommended_widgets.dart'; class HomeScreen extends StatefulWidget { const HomeScreen({super.key}); @override State<HomeScreen> createState() => _HomeScreenState(); } class _HomeScreenState extends State<HomeScreen> { // getx cart controller initialize final CartController cartController = Get.put(CartController()); List _list = []; Future<void> readJson() async { final String response = await rootBundle.loadString('assets/juiceshop.json'); final data = await json.decode(response); setState(() { _list = data['juices']; }); } @override void initState() { readJson(); super.initState(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.yellow.shade100, body: Padding( padding: const EdgeInsets.symmetric(horizontal: 15), child: SingleChildScrollView( scrollDirection: Axis.vertical, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ // title Text( "Stay Fresh", style: homeScreenBannerText, ), // subtitle Text( "Any Time Any Where", style: homeScreenBannerText, ), // divider const Padding( padding: EdgeInsets.symmetric(vertical: 10), child: Divider( thickness: 1, ), ), // text Padding( padding: const EdgeInsets.only(bottom: 10), child: Text( 'Recommended', style: recommendedTitleText, ), ), // recommended widgets SizedBox( height: 280, child: ListView.builder( shrinkWrap: true, itemCount: _list.length, scrollDirection: Axis.horizontal, itemBuilder: (context, index) { return Row( children: [ RecommendedWidget( title: _list[index]['juiceName'], subtitle: _list[index]['juiceDescription'], price: _list[index]['price'].toString(), img: _list[index]['imagePath'], // onTap: cartController.addMoney(_list[index]['price']? '0'), onTap: () {}, ), const SizedBox(width: 10), ], ); }, ), ), const SizedBox(height: 20), // popular drinks Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( padding: const EdgeInsets.only(bottom: 10), child: Text( 'Popular Drinks 🔥', style: recommendedTitleText, ), ), Padding( padding: const EdgeInsets.symmetric(horizontal: 10), child: TextButton( onPressed: () { Get.to(const SeeAllScreen()); // Navigator.push( // context, // MaterialPageRoute( // builder: (builder) => const SeeAllScreen())); }, child: Text('See all', style: GoogleFonts.ubuntu( color: Colors.red.shade300))), ), ], ), const PopularWidgets() // SingleChildScrollView( // scrollDirection: Axis.vertical, // child: ListView.builder( // shrinkWrap: true, // scrollDirection: Axis.vertical, // itemCount: _list.length ~/ 2, // itemBuilder: (context, index) { // return Card( // color: Colors.green.shade100, // child: Padding( // padding: const EdgeInsets.all(15.0), // child: Row( // crossAxisAlignment: CrossAxisAlignment.start, // mainAxisAlignment: MainAxisAlignment.spaceBetween, // children: [ // Row( // children: [ // SizedBox( // height: 40, // child: // Image.asset(_list[index]['imagePath']), // ), // const SizedBox(width: 20), // Column( // crossAxisAlignment: // CrossAxisAlignment.start, // children: [ // // name // Text( // _list[index]['juiceName'], // style: GoogleFonts.ubuntu( // fontSize: 20, // fontWeight: FontWeight.bold), // ), // const SizedBox( // height: 10, // ), // // price // Row( // children: [ // Text( // '\$${_list[index]['price'].toString()}', // style: GoogleFonts.ubuntu( // fontWeight: FontWeight.bold), // ), // // how much sales // // Text( // // '(542)', // // style: GoogleFonts.ubuntu(), // // ), // ], // ), // ], // ), // ], // ), // Container( // height: 40, // width: 40, // decoration: BoxDecoration( // borderRadius: BorderRadius.circular(10), // color: Colors.lightGreen.shade600), // child: IconButton( // icon: const Icon( // Icons.add, // color: Colors.white, // ), // onPressed: () => {}, // ), // ) // ], // ), // // child: Text(_list[index]['juiceName']), // ), // ); // }), // ), ], ), ), ), ); } }
0
mirrored_repositories/juice-bar/lib/ui
mirrored_repositories/juice-bar/lib/ui/screens/main_nav_screen.dart
import 'package:flutter/material.dart'; import 'package:juicebar/ui/screens/home_screen.dart'; import '../widgets/g_navbar_widget.dart'; import 'cartscreens/cart_screen.dart'; import 'drawer.dart'; class MainNavScreen extends StatefulWidget { const MainNavScreen({super.key}); @override State<MainNavScreen> createState() => _MainNavScreenState(); } class _MainNavScreenState extends State<MainNavScreen> { int _selectPage = 0; final List<Widget> _index = [ const HomeScreen(), const CartScreen(), ]; void navigateBottomBar(int index) { setState(() { _selectPage = index; }); } @override Widget build(BuildContext context) { return Scaffold( drawer: const MyDrawer(), appBar: AppBar( actions: <Widget>[ Padding( padding: const EdgeInsets.all(10), child: IconButton( icon: const Icon( Icons.notifications_none_rounded, color: Colors.grey, ), onPressed: () {}), ), ], backgroundColor: Colors.yellow.shade100, elevation: 0, leading: Builder( builder: (context) => IconButton( onPressed: () { Scaffold.of(context).openDrawer(); }, icon: const Icon( Icons.menu_outlined, color: Colors.grey, ))), ), bottomNavigationBar: GNavBarWidget( onTab: (index) => navigateBottomBar(index), ), body: _index[_selectPage], ); } }
0
mirrored_repositories/juice-bar/lib/ui
mirrored_repositories/juice-bar/lib/ui/screens/drawer.dart
import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:juicebar/ui/screens/onboardings/display_screen.dart'; class MyDrawer extends StatelessWidget { const MyDrawer({super.key}); @override Widget build(BuildContext context) { return Drawer( width: 250, backgroundColor: Colors.grey.shade900, child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column( children: [ // drawer header logo DrawerHeader( child: Image.asset('assets/juice.png'), ), Padding( padding: const EdgeInsets.symmetric(horizontal: 20), child: Divider( thickness: 1, color: Colors.grey.shade600, ), ), // home button Padding( padding: const EdgeInsets.only(left: 15.0), child: GestureDetector( onTap: () {}, child: ListTile( leading: const Icon( Icons.home_rounded, color: Colors.white, ), title: Text( 'Home', style: GoogleFonts.ubuntu(color: Colors.white), ), ), ), ), // info button Padding( padding: const EdgeInsets.only(left: 15.0), child: GestureDetector( onTap: () {}, child: ListTile( leading: const Icon( Icons.info_outline_rounded, color: Colors.white, ), title: Text( 'Info', style: GoogleFonts.ubuntu(color: Colors.white), ), ), ), ), // Coupons button Padding( padding: const EdgeInsets.only(left: 15.0), child: GestureDetector( onTap: () {}, child: ListTile( leading: const Icon( Icons.discount_rounded, color: Colors.white, ), title: Text( 'Coupons', style: GoogleFonts.ubuntu(color: Colors.white), ), ), ), ), ], ), // logout button Padding( padding: const EdgeInsets.only(left: 15.0, bottom: 25), child: GestureDetector( onTap: () { Get.to(() => const DisplayScreen()); }, child: ListTile( leading: const Icon( Icons.logout_rounded, color: Colors.white, ), title: Text( 'Log Out', style: GoogleFonts.ubuntu(color: Colors.white), ), ), ), ), ], ), ); } }
0
mirrored_repositories/juice-bar/lib/ui/screens
mirrored_repositories/juice-bar/lib/ui/screens/cartscreens/cart_screen.dart
import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:juicebar/models/cart_model.dart'; import '../../../controllers/cart_controllers.dart'; import 'bottom_widget.dart'; import 'cart_widget.dart'; class CartScreen extends StatefulWidget { const CartScreen({super.key}); @override State<CartScreen> createState() => _CartScreenState(); } class _CartScreenState extends State<CartScreen> { // getx cart controller initialize final CartController cartController = Get.put(CartController()); final value = Get.put(CartModel()); @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.yellow.shade100, body: SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(25), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'My Cart', style: GoogleFonts.ubuntu(fontSize: 40, color: Colors.black54), ), const SizedBox(height: 40), const CartNewWidget( imgPath: 'assets/images/cranberry.png', juiceName: 'Cranberry Juice', juicePrice: '2.50'), const SizedBox(height: 10), const CartNewWidget( imgPath: 'assets/images/grapefruit.png', juiceName: 'Grapefruit Juice', juicePrice: '3.00'), const SizedBox(height: 10), const CartNewWidget( imgPath: 'assets/images/mango.png', juiceName: 'Mango Juice', juicePrice: '4.00'), const SizedBox(height: 10), ], ), ), ), bottomNavigationBar: BottomNewWidget(), ); } }
0
mirrored_repositories/juice-bar/lib/ui/screens
mirrored_repositories/juice-bar/lib/ui/screens/cartscreens/cart_widget.dart
import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; class CartNewWidget extends StatelessWidget { final String imgPath; final String juiceName; final String juicePrice; const CartNewWidget({ super.key, required this.imgPath, required this.juiceName, required this.juicePrice, }); @override Widget build(BuildContext context) { return Container( height: 100, decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), color: Colors.deepPurple.shade300), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Padding( padding: const EdgeInsets.symmetric(horizontal: 10), child: Image.asset( imgPath, height: 70, ), ), Padding( padding: const EdgeInsets.symmetric(vertical: 20), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( juiceName, style: GoogleFonts.ubuntu( fontSize: 16, fontWeight: FontWeight.bold), ), Text('\$$juicePrice', style: GoogleFonts.ubuntu( fontSize: 16, fontWeight: FontWeight.bold)), ], ), ), ], ), Padding( padding: const EdgeInsets.all(25), child: CircleAvatar( backgroundColor: Colors.red.shade400, minRadius: 20, child: IconButton( onPressed: () {}, icon: const Icon( Icons.delete_forever_rounded, color: Colors.black, size: 30, ), ), ), ) ], ), ); } }
0
mirrored_repositories/juice-bar/lib/ui/screens
mirrored_repositories/juice-bar/lib/ui/screens/cartscreens/bottom_widget.dart
import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:google_fonts/google_fonts.dart'; import '../../../controllers/cart_controllers.dart'; class BottomNewWidget extends StatelessWidget { BottomNewWidget({ super.key, }); // getx cart controller initialize final CartController cartController = Get.put(CartController()); @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 25), child: Container( height: 100, decoration: BoxDecoration( color: Colors.green.shade400, borderRadius: BorderRadius.circular(10)), child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( padding: const EdgeInsets.all(10), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( 'Total Price', style: GoogleFonts.comfortaa(fontSize: 20), ), Obx( () => Text( '\$${cartController.price}', style: GoogleFonts.comfortaa( fontSize: 30, fontWeight: FontWeight.bold), ), ) ], ), ), Padding( padding: const EdgeInsets.all(10), child: Container( decoration: BoxDecoration( border: Border.all(color: Colors.white60), borderRadius: BorderRadius.circular(10)), child: Padding( padding: const EdgeInsets.all(10.0), child: Row( children: [ Text('Pay Now', style: GoogleFonts.comfortaa(fontSize: 20)), const Icon(Icons.arrow_forward_ios_rounded) ], ), ), ), ) ]), ), ); } }
0
mirrored_repositories/juice-bar/lib/ui/screens
mirrored_repositories/juice-bar/lib/ui/screens/onboardings/display_screen.dart
import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; import 'package:juicebar/constants/colors.dart'; import 'package:juicebar/constants/text_styles.dart'; import '../main_nav_screen.dart'; class DisplayScreen extends StatefulWidget { const DisplayScreen({super.key}); @override State<DisplayScreen> createState() => _DisplayScreenState(); } class _DisplayScreenState extends State<DisplayScreen> { // @override // void initState() { // Future.delayed(const Duration(seconds: 3)) // .then((value) => Get.to(() => const MainNavScreen())); // super.initState(); // } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.green.shade100, body: SafeArea( child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ const Spacer(), // svg picture Padding( padding: const EdgeInsets.all(10), child: SvgPicture.asset( 'assets/svgs/refreshing.svg', height: 250, ), ), const Spacer(), // card Container( height: 250, width: 270, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(30)), child: Column( children: [ // title Padding( padding: const EdgeInsets.symmetric(vertical: 15), child: Text( 'Fruit Juice', style: onboardingText.copyWith( fontWeight: FontWeight.bold, fontSize: 30), ), ), // subtitle Padding( padding: const EdgeInsets.symmetric(horizontal: 50), child: Text( 'One sip; One sip closer to a healthy, happy you.', style: onboardingText.copyWith(color: grey, fontSize: 15), ), ), // button Padding( padding: const EdgeInsets.symmetric(vertical: 30), child: ElevatedButton( style: ElevatedButton.styleFrom( elevation: 3, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(15)), minimumSize: const Size(50, 60), backgroundColor: const Color(0xff362727), ), onPressed: () { Get.to(() => const MainNavScreen()); }, child: Text("Let's Drink 👉", style: onboardingText), ), ), ], ), ), const Spacer(), ], ), ), ), ); } }
0
mirrored_repositories/juice-bar
mirrored_repositories/juice-bar/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:juicebar/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/Oshops-app
mirrored_repositories/Oshops-app/lib/main.dart
// ignore_for_file: prefer_const_constructors_in_immutables, use_key_in_widget_constructors, prefer_const_constructors, non_constant_identifier_names, avoid_print import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:shop_app/business_logic/cubit/api_services/api_services_cubit.dart'; import 'package:shop_app/modules/cubit/cubit.dart'; import 'package:shop_app/modules/cubit/states.dart'; import 'package:shop_app/shared/bloc_observer.dart'; import 'package:shop_app/shared/network/local/cache_helper.dart'; import 'package:shop_app/shared/network/remote/dio_helper.dart'; import 'modules/on_boarding/on_boarding_screen.dart'; Future<void> main() async { WidgetsFlutterBinding.ensureInitialized(); Bloc.observer = MyBlocObserver(); DioHelper.init(); await CacheHelper.init(); var access_token = CacheHelper.getData(key: 'access_token'); print("the token is $access_token"); runApp(MyApp(access_token)); } class MyApp extends StatelessWidget { final String? token; MyApp(this.token); @override Widget build(BuildContext context) { return MultiBlocProvider( providers: [ // registeration cubit BlocProvider<ApiServicesCubit>( create: (context) { return ApiServicesCubit(); }, ), ], child: MaterialApp( debugShowCheckedModeBanner: false, title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: OnBoardingScreen(token), //home: CardScreen(), ), ); } } class MyHomePage extends StatefulWidget { MyHomePage({Key? key}) : super(key: key); @override State<MyHomePage> createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { @override Widget build(BuildContext context) { return BlocProvider( create: (BuildContext context) => ShopCubit(), child: BlocConsumer<ShopCubit, ShopStates>( listener: (context, state) {}, builder: (context, state) { return Scaffold( body: Center(), ); }, ), ); } }
0
mirrored_repositories/Oshops-app/lib
mirrored_repositories/Oshops-app/lib/shared/bloc_observer.dart
// ignore_for_file: avoid_print import 'package:bloc/bloc.dart'; class MyBlocObserver extends BlocObserver { @override void onCreate(BlocBase bloc) { super.onCreate(bloc); print('onCreate -- ${bloc.runtimeType}'); } @override void onChange(BlocBase bloc, Change change) { super.onChange(bloc, change); print('onChange -- ${bloc.runtimeType}, $change'); } @override void onError(BlocBase bloc, Object error, StackTrace stackTrace) { print('onError -- ${bloc.runtimeType}, $error'); super.onError(bloc, error, stackTrace); } @override void onClose(BlocBase bloc) { super.onClose(bloc); print('onClose -- ${bloc.runtimeType}'); } }
0
mirrored_repositories/Oshops-app/lib/shared
mirrored_repositories/Oshops-app/lib/shared/network/end_pointes.dart
// ignore_for_file: constant_identifier_names const LOGIN = 'userSignIn'; const categories = 'getStoreCategories/:id'; const query = 'page=1&size=1';
0
mirrored_repositories/Oshops-app/lib/shared/network
mirrored_repositories/Oshops-app/lib/shared/network/remote/dio_helper.dart
import 'package:dio/dio.dart'; class DioHelper { static late Dio dio; static init() { dio = Dio( BaseOptions( baseUrl: 'https://oshops-app.herokuapp.com', receiveDataWhenStatusError: true, headers: { 'Content-Type': 'application/json', }, ), ); } static Future<Response> getData({ required String url, String? token, Map<String, dynamic>? query, String? id, }) async { dio.options.headers["Authorization"] = "Bearer ${token}"; return await dio.get(url); } static Future<Response> postData({ required String url, required Map<String, dynamic> data, }) async { return await dio.post( url, data: data, ); } } // import 'package:dio/dio.dart'; // // class DioHelper{ // static late Dio dio; // // static void init(){ // dio = Dio( // BaseOptions( // baseUrl: "https://oshops-app.herokuapp.com", // receiveDataWhenStatusError: true, // headers: { // "Content-Type" :"application/json", // "lang" : "ar" // } // ) // ); // } // // static Future<Response> getData( // { // required String url, // } // )async{ // //dio.options.headers["Authorization"] = "Bearer 9941df1208c615c231c21671041566390be6a911743b7a9b7fd461d6a3546a0a"; // return await dio.get(url); // } // // // static Future<Response> postData({ // required String url, // required Map<String,dynamic> data, // }) async // { // //dio.options.headers["authorization"] = "token ${token}"; // //dio.options.headers["Authorization"] = "Bearer 9941df1208c615c231c21671041566390be6a911743b7a9b7fd461d6a3546a0a"; // return dio.post( // url, // data:data // ); // } // // static Future<Response> putData({ // required String url, // required Map<String,dynamic> data, // }) async // { // //dio.options.headers["Authorization"] = "Bearer 9941df1208c615c231c21671041566390be6a911743b7a9b7fd461d6a3546a0a"; // return dio.patch( // url, // data:data // ); // } // // static Future<Response> deleteData({ // required String url, // }) async // { // //dio.options.headers["Authorization"] = "Bearer 9941df1208c615c231c21671041566390be6a911743b7a9b7fd461d6a3546a0a"; // return dio.delete( // url, // ); // } // // // }
0
mirrored_repositories/Oshops-app/lib/shared/network
mirrored_repositories/Oshops-app/lib/shared/network/local/cache_helper.dart
// ignore_for_file: invalid_required_positional_param import 'package:flutter/cupertino.dart'; import 'package:shared_preferences/shared_preferences.dart'; class CacheHelper { static SharedPreferences? sharedPreferences; static init() async { sharedPreferences = await SharedPreferences.getInstance(); //print('ssss${sharedPreferences.toString()}'); } static Future<bool> putBoolean({ required String key, required bool value, }) async { return await sharedPreferences!.setBool(key, value); } static dynamic getData({ required String key, }) { return sharedPreferences!.get(key); } static bool? getBoolean({ required String key, }) { return sharedPreferences!.getBool(key); } static Future<bool> saveData({ required String key, required dynamic value, }) async { if (value is String) return await sharedPreferences!.setString(key, value); if (value is int) return await sharedPreferences!.setInt(key, value); if (value is bool) return await sharedPreferences!.setBool(key, value); return await sharedPreferences!.setDouble(key, value); } static Future<bool> deleteData({required String key}) { return sharedPreferences!.remove(key); } }
0
mirrored_repositories/Oshops-app/lib
mirrored_repositories/Oshops-app/lib/constants/toast_constant.dart
import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; class ToastConstant { static var fToast = FToast(); static showToast(BuildContext context, String? message) { fToast.init(context); fToast.showToast( child: Container( decoration: BoxDecoration( color: Colors.green, borderRadius: BorderRadius.circular(30)), child: Row( mainAxisSize: MainAxisSize.min, children: [ Padding( padding: const EdgeInsets.all(9.0), child: Text( message!, style: TextStyle(fontSize: 16, color: Colors.white), ), ), ], ), ), ); } }
0
mirrored_repositories/Oshops-app/lib
mirrored_repositories/Oshops-app/lib/constants/strings.dart
final String oShopsBaseUrl = 'https://oshops-app.herokuapp.com'; final String loginEndPoint = "/userSignIn"; final String registerEndPoint = "/signUp"; final String editUserProfileEndPoint = "editUserProfile"; final String resetPasswordEndPoint = 'resetPassword'; final String addAddressEndPoint = "addAddress"; final String removeAddressEndPoint = "/removeAddress"; final String getCurrentUserEndPoint = "getCurrentUser"; final String getAllStoresEndPoint = "/getAllStores"; final String getStoreCategoriesEndPoint = "/getStoreCategories"; final String getStoreByIdEndPoint = "/getStoreById"; final String getAllProductsEndPoint = "/getAllProducts"; final String topRatedProductsEndPoint = "/topRatedProducts"; final String storeTopRatedProductsEndPoint = "/storeTopRatedProducts"; final String storeProductsEndPoint = "/storeProducts"; final String productsByStoreAndCategoryEndPoint = "/productsByStoreAndCategory"; final String productSearchEndPoint = "/productSearch"; final String addProductToWishlistrEndPoint = "/addProductToWishlistr"; final String removeProductFromWishlistEndPoint = "/removeProductFromWishlist"; final String getUserWishlistEndPoint = "/getUserWishlist"; final String getAllActiveAdvertismentsEndPoint = "/getAllActiveAdvertisments";
0
mirrored_repositories/Oshops-app/lib
mirrored_repositories/Oshops-app/lib/models/categories_model.dart
// ignore_for_file: prefer_typing_uninitialized_variables class CategoriesModel { int? status ; String? message; int? totalRes; int? totalPages; var storeCategories; CategoriesModel.fromJson( Map<String,dynamic> json){ status = json['status']; message = json['message']; totalRes = json['totalRes']; totalPages = json['totalPages']; storeCategories = json['storeCategories']; } }
0
mirrored_repositories/Oshops-app/lib
mirrored_repositories/Oshops-app/lib/models/items_model.dart
import 'package:shop_app/models/data_model.dart'; class ItemsModel { int? status; String? message; List<Data>? data; ItemsModel({this.status, this.message, this.data}); ItemsModel.fromJson(Map<String, dynamic> json) { status = json['status']; message = json['message']; if (json['data'] != null) { data = []; json['data'].forEach((v) { data!.add(new Data.fromJson(v)); }); } } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['status'] = this.status; data['message'] = this.message; if (this.data != null) { data['data'] = this.data!.map((v) => v.toJson()).toList(); } return data; } }
0
mirrored_repositories/Oshops-app/lib
mirrored_repositories/Oshops-app/lib/models/product_model.dart
// ignore_for_file: file_names, prefer_typing_uninitialized_variables class ProductModel{ int? status ; String? message; int? totalRes; int? totalPages; var allProducts; ProductModel.fromJson( Map<String,dynamic> json){ status = json['status']; message = json['message']; totalRes = json['totalRes']; totalPages = json['totalPages']; allProducts = json['allProducts']; } }
0
mirrored_repositories/Oshops-app/lib
mirrored_repositories/Oshops-app/lib/models/login_model.dart
class ShopLoginModel{ int? status; String? message; String? token; UserData? data; ShopLoginModel.fromJson(Map<String, dynamic> josn){ status = josn['status']; message = josn['message']; token = josn['token']; // data = josn['data'] != null ? UserData.fromJson(josn['data']) : null; } } // class UserData{ late String token; UserData.fromJson(Map<String, dynamic> josn){ token = josn['token']; } }
0
mirrored_repositories/Oshops-app/lib
mirrored_repositories/Oshops-app/lib/models/constants.dart
// ignore_for_file: constant_identifier_names, avoid_print import 'package:flutter/material.dart'; const Color login_bg = Color(0xFFFAFAFA); const Color signup_bg = Color(0xFF0F68B3); const Color darkBlue = Color(0xFF00325A); const Color light = Color(0xFF9BD3FF); const Color g = Color(0xFFE3E3E3); const double defpaultPadding = 16.0; const Duration defaultDuration = Duration(milliseconds: 300); // base url : 'https://newsapi.org/' // method url : v2/top-headlines? //https://oshops-app.herokuapp.com/getStoreCategories/:id?page=1&size=1 void printFullText(String text){ final pattern = RegExp('.{1,800}'); pattern.allMatches(text).forEach((match) => print(match.group(0))); }
0
mirrored_repositories/Oshops-app/lib
mirrored_repositories/Oshops-app/lib/models/stores_model.dart
// ignore_for_file: file_names, prefer_typing_uninitialized_variables class StoresModel{ int? status ; int? totalRes; int? totalPages; var allStores; StoresModel.fromJson( Map<String,dynamic> json){ status = json['status']; totalRes = json['totalRes']; totalPages = json['totalPages']; allStores = json['allStores']; } }
0
mirrored_repositories/Oshops-app/lib
mirrored_repositories/Oshops-app/lib/models/data_model.dart
class Data { String? sId; String? productName; String? productImageURL; double? price; int? rate; bool? inStock; bool? topProduct; String? storeId; String? categoryId; int? iV; Data( {this.sId, this.productName, this.productImageURL, this.price, this.rate, this.inStock, this.topProduct, this.storeId, this.categoryId, this.iV}); Data.fromJson(Map<String, dynamic> json) { sId = json['_id']; productName = json['productName']; productImageURL = json['productImageURL']; price = json['price']; rate = json['rate']; inStock = json['inStock']; topProduct = json['topProduct']; storeId = json['storeId']; categoryId = json['categoryId']; iV = json['__v']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['_id'] = this.sId; data['productName'] = this.productName; data['productImageURL'] = this.productImageURL; data['price'] = this.price; data['rate'] = this.rate; data['inStock'] = this.inStock; data['topProduct'] = this.topProduct; data['storeId'] = this.storeId; data['categoryId'] = this.categoryId; data['__v'] = this.iV; return data; } }
0
mirrored_repositories/Oshops-app/lib
mirrored_repositories/Oshops-app/lib/models/user_model.dart
// ignore_for_file: file_names, prefer_typing_uninitialized_variables class UserModel{ String? message; var userData; UserModel.fromJson( Map<String,dynamic> json){ message = json['message']; userData = json['userData']; } }
0
mirrored_repositories/Oshops-app/lib/modules
mirrored_repositories/Oshops-app/lib/modules/signup/sign_up_form.dart
// ignore_for_file: prefer_const_constructors, avoid_print, must_be_immutable import 'package:buildcondition/buildcondition.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:shop_app/models/constants.dart'; import 'package:shop_app/modules/login/cubit/cubit.dart'; import 'package:shop_app/modules/login/cubit/states.dart'; import 'package:shop_app/modules/login/log_in_form.dart'; import 'package:shop_app/modules/signup/cubit/cubit.dart'; import 'package:shop_app/modules/signup/sign_up_form.dart'; import 'package:shop_app/screens/bottom_navigator_bar.dart'; import 'package:shop_app/screens/products/bottom_nav.dart'; import 'package:shop_app/screens/shopping.dart'; import 'package:shop_app/shared/network/local/cache_helper.dart'; import 'cubit/states.dart'; class SignUpScreen extends StatelessWidget { final String? token; SignUpScreen(this.token, {Key? key}) : super(key: key); var formSignupKey = GlobalKey<FormState>(); @override Widget build(BuildContext context) { var _firstNameController = TextEditingController(); var _lastNameController = TextEditingController(); var _emailController = TextEditingController(); var _passwordController = TextEditingController(); print("my token $token"); //Size size = MediaQuery.of(context).size; return BlocProvider( create: (BuildContext context) => ShopSignUpCubit(), child: BlocConsumer<ShopSignUpCubit, ShopSignUpStates>( listener: (context, state) { if (state is ShopSignUpSuccessState) { if (state.loginModel.message == "Success") { Navigator.push( context, MaterialPageRoute( builder: (context) => BottomNavigationScreen(), ), ); // CacheHelper.saveData( // key: 'access_token', // value: state.loginModel.token, // ).then((value) { // print("***************"); // print(value.toString()); // Navigator.push( // context, // MaterialPageRoute( // builder: (context) => BottomNav(token), // ), // ); // }); String? m = state.loginModel.message; var fToast = FToast(); fToast.init(context); fToast.showToast( child: Container( decoration: BoxDecoration( color: Colors.green, borderRadius: BorderRadius.circular(30)), child: Row( mainAxisSize: MainAxisSize.min, children: [ Padding( padding: const EdgeInsets.all(9.0), child: Text( m!, style: TextStyle(fontSize: 15, color: Colors.white), maxLines: 2, overflow: TextOverflow.ellipsis, ), ), ], ), ), ); print(state.loginModel.message); } else { String? m = state.loginModel.message; var fToast = FToast(); fToast.init(context); fToast.showToast( child: Container( decoration: BoxDecoration( color: Colors.red, borderRadius: BorderRadius.circular(30)), child: Row( mainAxisSize: MainAxisSize.min, children: [ Padding( padding: const EdgeInsets.all(9.0), child: Text( m!, maxLines: 3, overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: 5, color: Colors.white), ), ), ], ), ), ); print(state.loginModel.message); print(state.loginModel.status); print(state.loginModel.data); } } if (state is ShopSignUpErrorState) { print(state.error.toString()); var fToast = FToast(); fToast.init(context); fToast.showToast( child: Container( decoration: BoxDecoration( color: Colors.red, borderRadius: BorderRadius.circular(30)), child: Row( mainAxisSize: MainAxisSize.min, children: [ Padding( padding: const EdgeInsets.all(5.0), child: Text( state.error.toString(), style: TextStyle( fontSize: 5, fontWeight: FontWeight.bold, color: Colors.white), maxLines: 2, overflow: TextOverflow.ellipsis, ), ), ], ), ), ); } }, builder: (context, state) { return Scaffold( body: Center( child: SingleChildScrollView( physics: BouncingScrollPhysics(), child: Form( key: formSignupKey, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 30), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( 'assets/images/OShops.png', height: 150, width: 150, ), Align( alignment: Alignment.bottomLeft, child: IconButton( onPressed: () { Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => LoginScreen(token), ), ); }, icon: Icon(Icons.arrow_back_ios), ), ), Card( child: Padding( padding: const EdgeInsets.all(15), child: Column( children: [ Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Sign Up', style: TextStyle( fontSize: 30, fontWeight: FontWeight.bold), ), ], ), SizedBox( height: 10, ), TextFormField( controller: _firstNameController, validator: (value) { if (value!.isEmpty) { return 'Please enter your first name'; } else { return null; } }, keyboardType: TextInputType.text, decoration: InputDecoration( hintText: 'enter your first name', labelText: 'First Name', // style: TextStyle(color: signup_bg), ), ), SizedBox( height: 10, ), TextFormField( controller: _lastNameController, validator: (value) { if (value!.isEmpty) { return 'Please enter your last name'; } else { return null; } }, keyboardType: TextInputType.text, decoration: InputDecoration( hintText: 'enter your last name', labelText: 'Last Name', // style: TextStyle(color: signup_bg), ), ), SizedBox( height: 10, ), TextFormField( controller: _emailController, validator: (value) { if (value!.isEmpty) { return 'Please enter your email'; } else { return null; } }, keyboardType: TextInputType.emailAddress, decoration: InputDecoration( hintText: 'enter your email', labelText: 'Email', // style: TextStyle(color: signup_bg), ), ), Padding( padding: const EdgeInsets.symmetric( vertical: defpaultPadding), child: TextFormField( controller: _passwordController, validator: (value) { if (value!.isEmpty) { return 'Password is too short'; } else { return null; } }, keyboardType: TextInputType.visiblePassword, obscureText: ShopSignUpCubit.get(context).isPassword, onFieldSubmitted: (value) { if (formSignupKey.currentState! .validate()) { FocusScope.of(context).unfocus(); ShopSignUpCubit.get(context).userSignUp( firstName: _firstNameController.text, lastName: _lastNameController.text, email: _emailController.text, password: _passwordController.text, ); } }, decoration: InputDecoration( suffixIcon: GestureDetector( onTap: () { ShopSignUpCubit.get(context) .changePasswordVisibility(); }, child: Icon( ShopSignUpCubit.get(context) .suffix)), hintText: 'enter your password', labelText: 'Password', //style: TextStyle(color: signup_bg), errorBorder: UnderlineInputBorder( borderSide: BorderSide(color: Colors.red)), ), ), ), SizedBox( height: 30, ), BuildCondition( condition: state is! ShopSignUpLoadingState, builder: (context) => FlatButton( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20), ), minWidth: 500, color: signup_bg, onPressed: () { if (formSignupKey.currentState! .validate()) { FocusScope.of(context).unfocus(); ShopSignUpCubit.get(context).userSignUp( firstName: _firstNameController.text, lastName: _lastNameController.text, email: _emailController.text, password: _passwordController.text, ); } }, child: Text( 'sign up'.toUpperCase(), style: TextStyle(color: Colors.white), ), ), fallback: (context) => Center( child: CircularProgressIndicator( color: signup_bg, ), ), ), ], ), ), ) ], ), ), ), ), ), ); }, ), ); } } // TextFormField( // controller: _firstNameController, // validator: (value) { // if (value!.isEmpty) { // return 'Please enter your first name'; // } // }, // keyboardType: TextInputType.name, // decoration: InputDecoration( // label: Text( // 'First name', // style: TextStyle(color: login_bg), // ), // ), // ), // Padding( // padding: const EdgeInsets.symmetric( // vertical: defpaultPadding), // child: TextFormField( // controller: _lastNameController, // validator: (value) { // if (value!.isEmpty) { // return 'Please enter your last name'; // } // }, // keyboardType: TextInputType.name, // decoration: InputDecoration( // label: Text( // 'Last name', // style: TextStyle(color: login_bg), // ), // ), // ), // ), // TextFormField( // controller: _emailController, // validator: (value) { // if (value!.isEmpty) { // return 'Please enter your email'; // } // }, // keyboardType: TextInputType.emailAddress, // decoration: InputDecoration( // label: Text( // 'Email', // style: TextStyle(color: login_bg), // ), // ), // ), // Padding( // padding: const EdgeInsets.symmetric( // vertical: defpaultPadding), // child: TextFormField( // controller: _passwordController, // validator: (value) { // if (value!.isEmpty) { // return 'Password is too short'; // } // }, // keyboardType: // TextInputType.visiblePassword, // decoration: InputDecoration( // label: Text( // 'Password', // style: TextStyle(color: login_bg), // ), // errorBorder: UnderlineInputBorder( // borderSide: // BorderSide(color: Colors.red)), // ), // ), // ),
0
mirrored_repositories/Oshops-app/lib/modules/signup
mirrored_repositories/Oshops-app/lib/modules/signup/cubit/states.dart
import 'package:shop_app/models/login_model.dart'; abstract class ShopSignUpStates{} class ShopSignUpInitialState extends ShopSignUpStates{} class ShopSignUpLoadingState extends ShopSignUpStates{} class ShopSignUpSuccessState extends ShopSignUpStates{ final ShopLoginModel loginModel; ShopSignUpSuccessState(this.loginModel); } class ShopSignUpErrorState extends ShopSignUpStates{ final String error; ShopSignUpErrorState(this.error); } class ShopSignUpChangPasswordVisibilityState extends ShopSignUpStates{}
0
mirrored_repositories/Oshops-app/lib/modules/signup
mirrored_repositories/Oshops-app/lib/modules/signup/cubit/cubit.dart
// ignore_for_file: avoid_print import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:shop_app/models/login_model.dart'; import 'package:shop_app/modules/signup/cubit/states.dart'; import 'package:shop_app/shared/network/remote/dio_helper.dart'; class ShopSignUpCubit extends Cubit<ShopSignUpStates> { ShopSignUpCubit() : super(ShopSignUpInitialState()); static ShopSignUpCubit get(context) => BlocProvider.of(context); ShopLoginModel? loginModel; void userSignUp({ required String firstName, required String lastName, required String email, required String password, }) { emit(ShopSignUpLoadingState()); DioHelper.postData( url: "/signUp", data: { 'firstName': firstName, 'lastName': lastName, 'email': email, 'password': password, }, ).then((value) { print(value.data); loginModel = ShopLoginModel.fromJson(value.data); emit(ShopSignUpSuccessState(loginModel!)); }).catchError((error){ print(error.response.data.toString()); emit(ShopSignUpErrorState(error.response.data['message'].toString())); }); } void postOrder(){ emit(ShopSignUpLoadingState()); DioHelper.postData( url: '/signUp', data: { "email": "mohamed.ragab@gmail.com", "password": "Mohamed1!" }, ).then((value){ print(value.data); loginModel = ShopLoginModel.fromJson(value.data); emit(ShopSignUpSuccessState(loginModel!)); }).catchError((error){ print("------------------------------"); print(error.response.data); print(error.response.headers); print(error.message); emit(ShopSignUpErrorState(error.toString())); }); } IconData suffix = Icons.visibility_outlined; bool isPassword = true; void changePasswordVisibility(){ isPassword = !isPassword; suffix = isPassword ? Icons.visibility_outlined : Icons.visibility_off_outlined; emit(ShopSignUpChangPasswordVisibilityState()); } }
0
mirrored_repositories/Oshops-app/lib/modules
mirrored_repositories/Oshops-app/lib/modules/login/reset_password.dart
// ignore_for_file: avoid_returning_null_for_void import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:shop_app/business_logic/cubit/api_services/api_services_cubit.dart'; import 'package:shop_app/constants/toast_constant.dart'; import 'package:shop_app/models/constants.dart'; import 'package:shop_app/modules/login/log_in_form.dart'; import 'package:shop_app/screens/bottom_navigator_bar.dart'; class ResetPassword extends StatefulWidget { final String? token; ResetPassword(this.token); @override State<ResetPassword> createState() => _ResetPasswordState(token!); } class _ResetPasswordState extends State<ResetPassword> { final String token; _ResetPasswordState(this.token); var _passwordControllerOld = TextEditingController(); var _passwordControllerNew = TextEditingController(); var resetKey = GlobalKey<FormState>(); bool isPassword = true; bool isChecked = false; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( centerTitle: true, elevation: 0, backgroundColor: Colors.white10, leading: IconButton( onPressed: () { //Navigator.pop(context); Navigator.pushReplacement( context, MaterialPageRoute( builder: (BuildContext context) => LoginScreen(token), ), ); }, icon: const Icon( Icons.arrow_back_ios, color: Colors.black, ), ), ), body: SingleChildScrollView( physics: BouncingScrollPhysics(), child: Column( children: [ Image.asset( 'assets/images/OShops.png', height: 150, width: 150, ), Form( key: resetKey, child: Column( children: [ const SizedBox( height: 20, ), const Padding( padding: EdgeInsets.symmetric(horizontal: 20), child: Align( alignment: Alignment.topLeft, child: Text( 'Reset Your Password', style: TextStyle( fontSize: 27, fontWeight: FontWeight.bold), ), ), ), const SizedBox( height: 20, ), Padding( padding: const EdgeInsets.all(defpaultPadding), child: TextFormField( controller: _passwordControllerOld, validator: (value) { if (value!.isEmpty) { return 'Password Password is empty'; } else { return null; } }, keyboardType: TextInputType.visiblePassword, decoration: const InputDecoration( hintText: 'enter your old password', labelText: 'Old Password', errorBorder: UnderlineInputBorder( borderSide: BorderSide(color: Colors.red), ), ), ), ), Padding( padding: const EdgeInsets.all(defpaultPadding), child: TextFormField( controller: _passwordControllerNew, validator: (value) { if (value!.isEmpty) { return 'Password is empty'; } else { return null; } }, keyboardType: TextInputType.visiblePassword, decoration: const InputDecoration( hintText: 'enter your new password', labelText: 'New Password', errorBorder: UnderlineInputBorder( borderSide: BorderSide(color: Colors.red), ), ), ), ), const SizedBox( height: 40, ), Padding( padding: const EdgeInsets.symmetric(horizontal: 20), child: BlocListener<ApiServicesCubit, ApiServicesStates>( listener: (context, state) { if (state is SuccessResetPasswordState) { ToastConstant.showToast(context, state.message); Navigator.push( context, MaterialPageRoute( builder: (context) => BottomNavigationScreen(), ), ); } else if (state is FailedRestPasswordState) { setState(() { isChecked = false; }); ToastConstant.showToast(context, state.error); } }, child: BlocBuilder<ApiServicesCubit, ApiServicesStates>( builder: (context, state) { return FlatButton( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20), ), minWidth: 500, color: signup_bg, onPressed: () async { print( "${_passwordControllerOld.text} + ${_passwordControllerNew.text}+$token", ); setState(() { isChecked = true; }); if (resetKey.currentState!.validate()) { FocusScope.of(context).unfocus(); print("object"); await ApiServicesCubit.getInstance(context) .changePassword( oldPassword: _passwordControllerOld.text.toString(), newPassword: _passwordControllerNew.text.toString(), token: token, ); } else { setState(() { isChecked = false; }); } }, child: Text( 'Reset Password', style: TextStyle( color: Colors.white, fontSize: 20, ), ), ); }, ), ), ), const SizedBox( height: 10, ), Visibility( visible: isChecked, child: CircularProgressIndicator( color: Colors.blue, ), ), ], ), ), ], ), ), ); } }
0
mirrored_repositories/Oshops-app/lib/modules
mirrored_repositories/Oshops-app/lib/modules/login/log_in_form.dart
// ignore_for_file: prefer_const_constructors, avoid_print, must_be_immutable import 'package:buildcondition/buildcondition.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:shop_app/models/constants.dart'; import 'package:shop_app/modules/login/cubit/cubit.dart'; import 'package:shop_app/modules/login/cubit/states.dart'; import 'package:shop_app/modules/login/reset_password.dart'; import 'package:shop_app/modules/signup/sign_up_form.dart'; import 'package:shop_app/screens/bottom_navigator_bar.dart'; import 'package:shop_app/screens/products/bottom_nav.dart'; import 'package:shop_app/screens/shopping.dart'; import 'package:shop_app/shared/network/local/cache_helper.dart'; class LoginScreen extends StatelessWidget { final String? token; LoginScreen(this.token, {Key? key}) : super(key: key); var formKey = GlobalKey<FormState>(); @override Widget build(BuildContext context) { var _emailControllerLog = TextEditingController(); var _passwordControllerLog = TextEditingController(); //Size size = MediaQuery.of(context).size; return BlocProvider( create: (BuildContext context) => ShopLoginCubit(), child: BlocConsumer<ShopLoginCubit, ShopLoginStates>( listener: (context, state) { if (state is ShopLoginSuccessState) { if (state.loginModel.message == "Success") { CacheHelper.saveData( key: 'access_token', value: state.loginModel.token, ).then((value) { print("***************"); print(value.toString()); Navigator.push( context, MaterialPageRoute( builder: (context) => BottomNavigationScreen(), ), ); }); String? m = state.loginModel.message; var fToast = FToast(); fToast.init(context); fToast.showToast( child: Container( decoration: BoxDecoration( color: Colors.green, borderRadius: BorderRadius.circular(30)), child: Row( mainAxisSize: MainAxisSize.min, children: [ Padding( padding: const EdgeInsets.all(9.0), child: Text( m!, style: TextStyle(fontSize: 16, color: Colors.white), ), ), ], ), ), ); print(state.loginModel.message); } else { String? m = state.loginModel.message; var fToast = FToast(); fToast.init(context); fToast.showToast( child: Container( decoration: BoxDecoration( color: Colors.red, borderRadius: BorderRadius.circular(30)), child: Row( mainAxisSize: MainAxisSize.min, children: [ Padding( padding: const EdgeInsets.all(9.0), child: Text( m!, style: TextStyle(fontSize: 5, color: Colors.white), ), ), ], ), ), ); print(state.loginModel.message); print(state.loginModel.status); print(state.loginModel.data); } } if (state is ShopLoginErrorState) { print(state.error.toString()); var fToast = FToast(); fToast.init(context); fToast.showToast( child: Container( decoration: BoxDecoration( color: Colors.red, borderRadius: BorderRadius.circular(30)), child: Row( mainAxisSize: MainAxisSize.min, children: [ Padding( padding: const EdgeInsets.all(5.0), child: Text( state.error.toString(), style: TextStyle( fontSize: 5, fontWeight: FontWeight.bold, color: Colors.white), ), ), ], ), ), ); } }, builder: (context, state) { return Scaffold( body: Center( child: SingleChildScrollView( physics: BouncingScrollPhysics(), child: Form( key: formKey, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 30), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( 'assets/images/OShops.png', height: 150, width: 150, ), Card( child: Padding( padding: const EdgeInsets.all(15.0), child: Column( children: [ Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Welcome,', style: TextStyle( fontSize: 30, fontWeight: FontWeight.bold), ), Spacer(), TextButton( child: Text( 'SignUp', style: TextStyle( color: Colors.blue, fontSize: 17), ), onPressed: () { Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => SignUpScreen(token), ), ); }, ) ], ), Align( alignment: Alignment.bottomLeft, child: Text( 'Sign in to continue', style: TextStyle(color: Colors.grey), )), SizedBox( height: 10, ), TextFormField( controller: _emailControllerLog, validator: (value) { if (value!.isEmpty) { return 'Please enter your email'; } else { return null; } }, keyboardType: TextInputType.emailAddress, decoration: InputDecoration( hintText: 'enter your email', labelText: 'Email', // style: TextStyle(color: signup_bg), ), ), Padding( padding: const EdgeInsets.symmetric( vertical: defpaultPadding), child: TextFormField( controller: _passwordControllerLog, validator: (value) { if (value!.isEmpty) { return 'Password is too short'; } else { return null; } }, onFieldSubmitted: (value) { if (formKey.currentState!.validate()) { FocusScope.of(context).unfocus(); ShopLoginCubit.get(context).userLogin( email: _emailControllerLog.text, password: _passwordControllerLog.text, ); } }, keyboardType: TextInputType.visiblePassword, obscureText: ShopLoginCubit.get(context).isPassword, decoration: InputDecoration( suffixIcon: GestureDetector( onTap: () { ShopLoginCubit.get(context) .changePasswordVisibility(); }, child: Icon( ShopLoginCubit.get(context) .suffix)), hintText: 'enter your password', labelText: 'Password', //style: TextStyle(color: signup_bg), errorBorder: UnderlineInputBorder( borderSide: BorderSide(color: Colors.red)), ), ), ), Align( alignment: Alignment.bottomRight, child: TextButton( onPressed: () { Navigator.pushReplacement( context, MaterialPageRoute( builder: (BuildContext context) => ResetPassword(token), ), ); }, child: Text( "Reset Password?", style: TextStyle(color: Color(0xFF3F6B93)), ), ), ), SizedBox( height: 30, ), BuildCondition( condition: state is! ShopLoginLoadingState, builder: (context) => FlatButton( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20), ), minWidth: 500, color: signup_bg, onPressed: () { if (formKey.currentState!.validate()) { FocusScope.of(context).unfocus(); ShopLoginCubit.get(context).userLogin( email: _emailControllerLog.text, password: _passwordControllerLog.text, ); } }, child: Text('sign in'.toUpperCase(), style: TextStyle( color: Colors.white, fontSize: 20)), ), fallback: (context) => Center( child: CircularProgressIndicator( color: signup_bg, )), ), ], ), ), ) ], ), ), ), ), ), ); }, ), ); } }
0
mirrored_repositories/Oshops-app/lib/modules/login
mirrored_repositories/Oshops-app/lib/modules/login/cubit/states.dart
import 'package:shop_app/models/login_model.dart'; abstract class ShopLoginStates{} class ShopLoginInitialState extends ShopLoginStates{} class ShopLoginLoadingState extends ShopLoginStates{} class ShopLoginSuccessState extends ShopLoginStates{ final ShopLoginModel loginModel; ShopLoginSuccessState(this.loginModel); } class ShopLoginErrorState extends ShopLoginStates{ final String error; ShopLoginErrorState(this.error); } class ShopChangPasswordVisibilityState extends ShopLoginStates{}
0
mirrored_repositories/Oshops-app/lib/modules/login
mirrored_repositories/Oshops-app/lib/modules/login/cubit/cubit.dart
// ignore_for_file: avoid_print import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:shop_app/models/login_model.dart'; import 'package:shop_app/modules/login/cubit/states.dart'; import 'package:shop_app/shared/network/remote/dio_helper.dart'; class ShopLoginCubit extends Cubit<ShopLoginStates> { ShopLoginCubit() : super(ShopLoginInitialState()); static ShopLoginCubit get(context) => BlocProvider.of(context); ShopLoginModel? loginModel; void userLogin({ required String email, required String password, }) { emit(ShopLoginLoadingState()); DioHelper.postData( url: "/userSignIn", data: { 'email': email, 'password': password, }, ).then((value) { print(value.data); loginModel = ShopLoginModel.fromJson(value.data); emit(ShopLoginSuccessState(loginModel!)); }).catchError((error){ print(error.response.data.toString()); emit(ShopLoginErrorState(error.response.data['message'].toString())); }); } void postOrder(){ emit(ShopLoginLoadingState()); DioHelper.postData( url: '/userSignIn', data: { "email": "mohamed.ragab@gmail.com", "password": "Mohamed1!" }, ).then((value){ print(value.data); loginModel = ShopLoginModel.fromJson(value.data); emit(ShopLoginSuccessState(loginModel!)); }).catchError((error){ print("------------------------------"); print(error.response.data); print(error.response.headers); print(error.message); emit(ShopLoginErrorState(error.toString())); }); } IconData suffix = Icons.visibility_outlined; bool isPassword = true; void changePasswordVisibility(){ isPassword = !isPassword; suffix = isPassword ? Icons.visibility_outlined : Icons.visibility_off_outlined; emit(ShopChangPasswordVisibilityState()); } }
0
mirrored_repositories/Oshops-app/lib/modules
mirrored_repositories/Oshops-app/lib/modules/on_boarding/on_boarding_screen.dart
// ignore_for_file: use_key_in_widget_constructors, prefer_const_literals_to_create_immutables, prefer_const_constructors, unnecessary_string_interpolations, avoid_print import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:shop_app/modules/login/log_in_form.dart'; import 'package:shop_app/screens/bottom_navigator_bar.dart'; import 'package:shop_app/screens/products/bottom_nav.dart'; import 'package:shop_app/screens/shopping.dart'; import 'package:shop_app/shared/network/local/cache_helper.dart'; import 'package:smooth_page_indicator/smooth_page_indicator.dart'; class BoardingModel { final String image1; final String image2; BoardingModel({ required this.image1, required this.image2, }); } class OnBoardingScreen extends StatefulWidget { final String? token; const OnBoardingScreen(this.token); @override State<OnBoardingScreen> createState() => _OnBoardingScreenState(token); } class _OnBoardingScreenState extends State<OnBoardingScreen> { final String? token; _OnBoardingScreenState(this.token); var boardingController = PageController(); List<BoardingModel> boarding = [ BoardingModel( image1: 'assets/images/OShops.png', image2: 'assets/images/1.png', ), BoardingModel( image1: 'assets/images/OShops.png', image2: 'assets/images/2.png', ), BoardingModel( image1: 'assets/images/OShops.png', image2: 'assets/images/3.png', ), ]; void submit() { CacheHelper.saveData( key: 'onBoarding', value: true, ).then((value) { if(value){ Navigator.pushAndRemoveUntil( context, MaterialPageRoute( builder: (context) => token == null ? LoginScreen(token) : BottomNavigationScreen(), ), (route) => false, ); } }); } bool isLast = false; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( elevation: 0, backgroundColor: Colors.white10, actions: [ TextButton( onPressed: () { submit(); }, child: Padding( padding: const EdgeInsets.only(right: 10), child: Text('skip', style: TextStyle(fontSize: 25, fontFamily: 'SFProDisplay')), ), ) ], ), body: Padding( padding: const EdgeInsets.all(20.0), child: Column( children: [ Expanded( child: PageView.builder( physics: BouncingScrollPhysics(), controller: boardingController, onPageChanged: (int index) { if (index == boarding.length - 1) { print('last'); setState(() { isLast = true; }); } else { print('not last'); setState(() { isLast = false; }); } }, itemBuilder: (context, item) => buildBoardingItem(boarding[item]), itemCount: boarding.length, ), ), SizedBox( height: 20, ), Row( children: [ SmoothPageIndicator( controller: boardingController, effect: ExpandingDotsEffect( dotColor: Colors.grey, activeDotColor: Colors.blue, dotHeight: 10, dotWidth: 10, spacing: 5, expansionFactor: 4), count: boarding.length, ), Spacer(), FloatingActionButton( onPressed: () { isLast ? Navigator.pushAndRemoveUntil( context, MaterialPageRoute( builder: (context) => LoginScreen(token), ), (route) => false, ) : boardingController.nextPage( duration: Duration(milliseconds: 500), curve: Curves.ease, ); }, child: Icon(Icons.arrow_forward_ios), ) ], ), SizedBox( height: 20, ), ], ), ), ); } Column buildBoardingItem(BoardingModel model) { return Column( children: [ Expanded( child: Image( image: AssetImage('${model.image1}'), ), ), SizedBox( height: 60, ), Expanded( child: Image( image: AssetImage('${model.image2}'), ), ), ], ); } }
0
mirrored_repositories/Oshops-app/lib/modules
mirrored_repositories/Oshops-app/lib/modules/cubit/states.dart
abstract class ShopStates{} class ShopInitialState extends ShopStates{} class ShopChangeState extends ShopStates{}
0
mirrored_repositories/Oshops-app/lib/modules
mirrored_repositories/Oshops-app/lib/modules/cubit/cubit.dart
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:shop_app/modules/cubit/states.dart'; class ShopCubit extends Cubit<ShopStates> { ShopCubit() : super(ShopInitialState()); static ShopCubit get(context) => BlocProvider.of(context); int counter = 1; }
0
mirrored_repositories/Oshops-app/lib/business_logic/cubit
mirrored_repositories/Oshops-app/lib/business_logic/cubit/api_services/api_services_cubit.dart
import 'dart:convert'; import 'package:bloc/bloc.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:meta/meta.dart'; import 'package:shop_app/constants/strings.dart'; import 'package:http/http.dart' as http; import 'package:shop_app/models/data_model.dart'; import 'package:shop_app/models/items_model.dart'; part 'api_Services_states.dart'; class ApiServicesCubit extends Cubit<ApiServicesStates> { ApiServicesCubit() : super(ApiServicesInitialState()); static ApiServicesCubit getInstance(BuildContext context) { return BlocProvider.of<ApiServicesCubit>(context); } changePassword({ required String oldPassword, required String newPassword, required String token, }) async { var headers = { 'Authorization': 'Bearer $token', 'Content-Type': 'application/json' }; var request = http.Request('PUT', Uri.parse('https://oshops-app.herokuapp.com/$resetPasswordEndPoint')); request.body = json.encode({ "oldPassword": oldPassword, "newPassword": newPassword, }); request.headers.addAll(headers); http.StreamedResponse response = await request.send(); if (response.statusCode == 200) { emit(SuccessResetPasswordState(message: "Success")); print(await response.stream.bytesToString()); } else { emit(FailedRestPasswordState(error: "UnSuccess")); print(response.reasonPhrase); } } editProfile( {required String firstName, required String lastName, required String email, required String token}) async { var headers = { 'Authorization': 'Bearer $token', 'Content-Type': 'application/json' }; var request = http.Request('PUT', Uri.parse('https://oshops-app.herokuapp.com/$editUserProfileEndPoint')); request.body = json.encode( { "firstName": firstName, "lastName": lastName, "email": email, }, ); request.headers.addAll(headers); http.StreamedResponse response = await request.send(); if (response.statusCode == 200) { emit(EditProfileSuccessState(message: "Success")); print(await response.stream.bytesToString()); } else { emit(EditProfileUnSuccessState(error: "UnSuccess")); print(response.reasonPhrase); } } AddShoppingAddress({required String address, required String token}) async { var headers = { 'Authorization': 'Bearer $token', 'Content-Type': 'application/json' }; var request = http.Request('PUT', Uri.parse('https://oshops-app.herokuapp.com/$addAddressEndPoint')); request.body = json.encode( { "address": address, }, ); request.headers.addAll(headers); http.StreamedResponse response = await request.send(); if (response.statusCode == 200) { emit(SuccessAddAdressState(message: "Success")); print(await response.stream.bytesToString()); } else { emit(UnSucessAddedAdderessState(error: "UnSuccess")); print(response.reasonPhrase); } } getCurrentUser({required String token}) async { emit(UserInfoLoadingSate()); var headers = {'Authorization': 'Bearer $token'}; var request = http.Request('GET', Uri.parse('https://oshops-app.herokuapp.com/$getCurrentUserEndPoint')); request.headers.addAll(headers); http.StreamedResponse response = await request.send(); if (response.statusCode == 200) { var model = json.decode(await response.stream.bytesToString()); print(model["message"]); print(model["userData"]["firstName"]); //print(await response.stream.bytesToString()); emit(UserInfoLoadedState(data: model)); } else { emit(UserInfoUnLoadedState(error: "No data at this time")); print(response.reasonPhrase); } } searchItem({required String token, required String param}) async { var headers = {'Authorization': 'Bearer $token'}; var request = http.Request( 'GET', Uri.parse('https://oshops-app.herokuapp.com/productSearch?search=$param'), ); request.headers.addAll(headers); http.StreamedResponse response = await request.send(); if (response.statusCode == 200) { List<Map<String, dynamic>> products = []; var items = json.decode(await response.stream.bytesToString()); //print(items); //ItemsModel model = ItemsModel.fromJson(items); print(items["data"]); items["data"].forEach((element) { products.add(element); }); print(products.length); emit(SearchItemFoundState(items: products)); } else { emit(SearchItemNotFoundState(error: "Not found at this time")); print(response.reasonPhrase); } } }
0
mirrored_repositories/Oshops-app/lib/business_logic/cubit
mirrored_repositories/Oshops-app/lib/business_logic/cubit/api_services/api_Services_states.dart
part of 'api_services_cubit.dart'; @immutable abstract class ApiServicesStates {} class ApiServicesInitialState extends ApiServicesStates {} class SuccessResetPasswordState extends ApiServicesStates { final message; SuccessResetPasswordState({required this.message}); } class FailedRestPasswordState extends ApiServicesStates { final error; FailedRestPasswordState({required this.error}); } class EditProfileSuccessState extends ApiServicesStates { final String message; EditProfileSuccessState({required this.message}); } class EditProfileUnSuccessState extends ApiServicesStates { final String error; EditProfileUnSuccessState({required this.error}); } class SuccessAddAdressState extends ApiServicesStates { final String message; SuccessAddAdressState({required this.message}); } class UnSucessAddedAdderessState extends ApiServicesStates { final String error; UnSucessAddedAdderessState({required this.error}); } class UserInfoLoadingSate extends ApiServicesStates {} class UserInfoLoadedState extends ApiServicesStates { final data; UserInfoLoadedState({required this.data}); } class UserInfoUnLoadedState extends ApiServicesStates { final String error; UserInfoUnLoadedState({required this.error}); } class SearchItemFoundState extends ApiServicesStates { final List<Map<String, dynamic>> items; SearchItemFoundState({required this.items}); } class SearchItemNotFoundState extends ApiServicesStates { final String error; SearchItemNotFoundState({required this.error}); }
0
mirrored_repositories/Oshops-app/lib
mirrored_repositories/Oshops-app/lib/cubit/states.dart
import 'package:shop_app/models/categories_model.dart'; import 'package:shop_app/models/stores_model.dart'; import 'package:shop_app/models/user_model.dart'; abstract class ShopStates{} class ShopInitialState extends ShopStates{} class ShopChangeBottomNavState extends ShopStates{} class ShopLoadingStoresDataState extends ShopStates{} class StoreSuccessState extends ShopStates{ final StoresModel storesModel; StoreSuccessState(this.storesModel); } class ErrorState extends ShopStates{ final String error; ErrorState(this.error); } class ShopLoadingProductsDataState extends ShopStates{} class ProductsSuccessState extends ShopStates{} class ProductsErrorState extends ShopStates{ final String error; ProductsErrorState(this.error); } class ShopLoadingCategoriesDataState extends ShopStates{} class CategoriesSuccessState extends ShopStates{ final CategoriesModel categoriesModel; CategoriesSuccessState(this.categoriesModel); } class CategoriesErrorState extends ShopStates{ final String error; CategoriesErrorState(this.error); } class ShopLoadingUserDataState extends ShopStates{} class UserSuccessState extends ShopStates{ final UserModel userModel; UserSuccessState(this.userModel); } class UserErrorState extends ShopStates{ final String error; UserErrorState(this.error); }
0
mirrored_repositories/Oshops-app/lib
mirrored_repositories/Oshops-app/lib/cubit/cubit.dart
// ignore_for_file: prefer_const_constructors, avoid_print import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:shop_app/cubit/states.dart'; import 'package:shop_app/models/categories_model.dart'; import 'package:shop_app/models/product_model.dart'; import 'package:shop_app/models/stores_model.dart'; import 'package:shop_app/models/user_model.dart'; import 'package:shop_app/screens/profile.dart'; import 'package:shop_app/screens/shopping.dart'; import 'package:shop_app/shared/network/remote/dio_helper.dart'; class ShopCubit extends Cubit<ShopStates> { ShopCubit() : super(ShopInitialState()); static ShopCubit get(context) => BlocProvider.of(context); int currentIndex = 0; List<Widget> bottomsScreens = [ShoppingScreen(), ProfileScreen()]; void changeBottom(int index) { currentIndex = index; emit(ShopChangeBottomNavState()); } //String? orderId = 'FY0NY8piDFMtDGZH_SoQn'; StoresModel? storesModel; List<dynamic> allStores = []; void getStores({required String token}) { emit(ShopLoadingStoresDataState()); DioHelper.getData( url: '/getAllStores', token: token, ).then((value) { //print(value.data['allStores'][0]['storeName']); allStores = value.data['allStores']; print(allStores[0]['storeName']); storesModel = StoresModel.fromJson(value.data); emit(StoreSuccessState(storesModel!)); }).catchError((error) { print(error.toString()); emit(ErrorState(error.toString())); }); } UserModel? userModel; List<dynamic> userData = []; void getUser({required String token}) { emit(ShopLoadingUserDataState()); DioHelper.getData( url: '/getCurrentUser', token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MThkOWYyNzM0OWFhYTliYTExYjU4NjMiLCJyb2xlIjoidXNlciIsImlhdCI6MTYzNzcxODAwN30.d1ZPI_TQu2kn2d8vLlJ7u_rDhwm3wayA58oYmG5u4zo', ).then((value) { //print(value.data['userData'][0]['storeName']); userData = value.data['userData']; print('333333333333333333333333333333333333333333333333333333'); userModel = UserModel.fromJson(value.data); emit(UserSuccessState(userModel!)); }).catchError((error) { print(error.toString()); print('090909090909090900000909090009090900900090009090900909'); emit(UserErrorState(error.toString())); }); } ProductModel? productModel; List<dynamic> allProducts = []; void getProducts({required String token}) { emit(ShopLoadingProductsDataState()); DioHelper.getData( url: '/getAllProducts', query: {'page':'1', 'size':'4'}, token: token, ).then((value) { //print(value.data['allProducts'][0]['productName']); allProducts = value.data['allProducts']; print(allProducts[0]['productName']); storesModel = StoresModel.fromJson(value.data); emit(StoreSuccessState(storesModel!)); }).catchError((error) { print(error.toString()); emit(ErrorState(error.toString())); }); } CategoriesModel? categoriesModel; List<dynamic> storeCategories = []; void getCategories({required String token}) { emit(ShopLoadingCategoriesDataState()); DioHelper.getData( url: '/getStoreCategories', //id: id, query: {'page':'1', 'size':'1'}, token: token, ).then((value) { //print(value.data['storeCategories'][0]['productName']); storeCategories = value.data['storeCategories']; print(storeCategories[0]['categoryName']); categoriesModel = CategoriesModel.fromJson(value.data); emit(CategoriesSuccessState(categoriesModel!)); }).catchError((error) { print(error.toString()); emit(CategoriesErrorState(error.toString())); }); } }
0
mirrored_repositories/Oshops-app/lib
mirrored_repositories/Oshops-app/lib/screens/bottom_navigator_bar.dart
import 'package:curved_navigation_bar/curved_navigation_bar.dart'; import 'package:flutter/material.dart'; import 'package:shop_app/screens/profile.dart'; import 'package:shop_app/screens/shopping.dart'; class BottomNavigationScreen extends StatefulWidget { @override State<BottomNavigationScreen> createState() => _BottomNavigationScreenState(); } class _BottomNavigationScreenState extends State<BottomNavigationScreen> { int currentIndex = 0; List<Widget> bottomsScreens = <Widget>[ShoppingScreen(), ProfileScreen()]; void changeBottom(int index) { setState(() { currentIndex = index; }); } @override Widget build(BuildContext context) { return Scaffold( body: bottomsScreens.elementAt(currentIndex), bottomNavigationBar: CurvedNavigationBar( items: const [ Icon(Icons.shopping_cart_outlined, size: 30), Icon(Icons.person_outlined, size: 30), ], height: 60, onTap: (index){ changeBottom(index); }, index: currentIndex, ), ); } }
0
mirrored_repositories/Oshops-app/lib
mirrored_repositories/Oshops-app/lib/screens/shopping.dart
// ignore_for_file: non_constant_identifier_names, prefer_const_constructors import 'package:carousel_slider/carousel_options.dart'; import 'package:carousel_slider/carousel_slider.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:shop_app/models/constants.dart'; import 'package:shop_app/screens/brands.dart'; import 'package:shop_app/screens/categories.dart'; import 'package:shop_app/screens/product.dart'; import 'package:shop_app/screens/search_screen.dart'; class ShoppingScreen extends StatelessWidget { @override Widget build(BuildContext context) { // var p = ShopCubit.get(context).allStores; // var ph = ShopCubit.get(context).allStores['_id']; // var ind = ShopCubit.get(context).allStores.map((e) => e['_id']); // String base = 'https://oshops-app.herokuapp.com/'; // String ProductImage = '${ShopCubit.get(context).allProducts[0]['productImageURL']}'; // String ProductName = // '${ShopCubit.get(context).allProducts[0]['productName']}'; // String ProductPrice = '${ShopCubit.get(context).allProducts[0]['price']}'; // String ProductImage1 = // '${ShopCubit.get(context).allProducts[1]['productImageURL']}'; // String ProductName1 = // '${ShopCubit.get(context).allProducts[1]['productName']}'; // String ProductPrice1 = '${ShopCubit.get(context).allProducts[1]['price']}'; // String ProductImage2 = // '${ShopCubit.get(context).allProducts[2]['productImageURL']}'; // String ProductName2 = // '${ShopCubit.get(context).allProducts[2]['productName']}'; // String ProductPrice2 = '${ShopCubit.get(context).allProducts[2]['price']}'; // String ProductImage3 = // '${ShopCubit.get(context).allProducts[3]['productImageURL']}'; // String ProductName3 = // '${ShopCubit.get(context).allProducts[3]['productName']}'; // String ProductPrice3 = '${ShopCubit.get(context).allProducts[3]['price']}'; // // List images = [ // '$base${p[0]['storeLogoURL']}'.replaceAll("\\", "/"), // '$base${p[1]['storeLogoURL']}'.replaceAll("\\", "/"), // '$base${p[2]['storeLogoURL']}'.replaceAll("\\", "/"), // '$base${p[3]['storeLogoURL']}'.replaceAll("\\", "/"), // '$base${p[4]['storeLogoURL']}'.replaceAll("\\", "/"), // '$base${p[5]['storeLogoURL']}'.replaceAll("\\", "/"), // '$base${p[6]['storeLogoURL']}'.replaceAll("\\", "/"), // '$base${p[7]['storeLogoURL']}'.replaceAll("\\", "/"), // '$base${p[8]['storeLogoURL']}'.replaceAll("\\", "/"), // ]; // // List id = [ // '$base${p[0]['_id']}', // '$base${p[1]['_id']}', // '$base${p[2]['_id']}', // '$base${p[3]['_id']}', // '$base${p[4]['_id']}', // '$base${p[5]['_id']}', // '$base${p[6]['_id']}', // '$base${p[7]['_id']}', // '$base${p[8]['_id']}', // ]; // List<String> names = [ // '${p[0]['storeName']}' // '${p[1]['storeName']}' // '${p[2]['storeName']}' // '${p[3]['storeName']}' // '${p[4]['storeName']}' // '${p[5]['storeName']}' // '${p[6]['storeName']}' // '${p[7]['storeName']}' // '${p[8]['storeName']}' // ]; List imagessss = [ 'assets/images/Cars.jpeg', 'assets/images/Electronics.jpeg', 'assets/images/Groceries.jpeg', 'assets/images/Makeup.jpeg', ]; List CaImages = [ 'assets/images/11.png', 'assets/images/22.png', 'assets/images/33.png', 'assets/images/44.png', ]; Column buildColumn(BuildContext context, screen, url) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ GestureDetector( onTap: () { Navigator.pushReplacement( context, MaterialPageRoute(builder: (context) => screen)); }, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: g, ), height: 180, width: 180, child: Image.asset(url), ), ), const SizedBox( height: 10, ), const Text('watch', style: TextStyle(fontSize: 19), maxLines: 2, overflow: TextOverflow.ellipsis), const SizedBox( height: 10, ), const Text( '300\$', style: TextStyle(fontSize: 19, color: Colors.green), ), ], ); } return Scaffold( body: SingleChildScrollView( physics: BouncingScrollPhysics(), child: Column( children: [ const SizedBox( height: 25, ), Padding( padding: const EdgeInsets.symmetric(horizontal: 10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( "Oshops", style: TextStyle( fontSize: 25, fontWeight: FontWeight.bold, color: Colors.blue, ), ), Flexible( flex: 8, child: Container( height: 50, margin: const EdgeInsets.symmetric(vertical: 30), padding: const EdgeInsets.symmetric( horizontal: 30, vertical: 5), decoration: BoxDecoration( borderRadius: BorderRadius.circular(29.5), ), child: InkWell( onTap: () { Navigator.of(context).push( MaterialPageRoute( builder: (context) => SearchScreen(), ), ); }, child: Icon( Icons.search, size: 25, color: Colors.black, ), )), ), ], ), ), Padding( padding: const EdgeInsets.symmetric(horizontal: 10), child: Row( children: const [ Text( 'Stores', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 22, ), ) ], ), ), const SizedBox( height: 25, ), Padding( padding: const EdgeInsets.symmetric(horizontal: 10), child: SizedBox( height: 135, child: ListView.builder( shrinkWrap: true, physics: BouncingScrollPhysics(), scrollDirection: Axis.horizontal, itemCount: imagessss.length, itemBuilder: (context, index) => Container( margin: const EdgeInsets.only(right: 20), width: 80, child: Column( children: <Widget>[ FloatingActionButton( //backgroundColor: , onPressed: () { Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => CategoriesScreen(), )); }, child: Container( height: 80, decoration: BoxDecoration( shape: BoxShape.circle, image: DecorationImage( fit: BoxFit.fill, image: AssetImage( imagessss[index], ), ), ), ), ), const SizedBox( height: 20, ), index == 0 ? const Text('Cars') : index == 1 ? const Text('Electronics') : index == 2 ? const Text('Groceries') : index == 3 ? const Text('Makeup') : index == 4 ? const Text('') : const Text('') ], ), ), ), ), ), Padding( padding: const EdgeInsets.symmetric(horizontal: 10), child: Row( children: const [ Text( 'Brands', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 22, ), ) ], ), ), const SizedBox( height: 25, ), Padding( padding: const EdgeInsets.symmetric(horizontal: 20), child: SizedBox( height: 100, child: ListView.builder( shrinkWrap: true, physics: BouncingScrollPhysics(), scrollDirection: Axis.horizontal, itemCount: imagessss.length, itemBuilder: (context, index) => GestureDetector( onTap: () { Navigator.pushReplacement( context, MaterialPageRoute( builder: (BuildContext context) => BrandsScreen(), ), ); }, child: Container( color: Colors.white, margin: const EdgeInsets.only(right: 20), child: Center( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 15.0), child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ FloatingActionButton( onPressed: () { Navigator.pushReplacement( context, MaterialPageRoute( builder: (BuildContext context) => BrandsScreen(), ), ); }, child: Container( height: 80, decoration: BoxDecoration( shape: BoxShape.circle, image: DecorationImage( fit: BoxFit.fill, image: AssetImage( imagessss[index], ), ), ), ), ), const SizedBox( width: 15, ), Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: const [ Text( 'Brand Name', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 19, ), ), SizedBox( height: 5, ), Text( 'Details', style: TextStyle( fontSize: 15, ), ), ], ) ], ), ), ), ), ), ), ), ), const SizedBox( height: 25, ), const Padding( padding: EdgeInsets.symmetric(horizontal: 10), child: Align( alignment: Alignment.topLeft, child: Text( 'For you', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 22, ), ), ), ), const SizedBox( height: 25, ), CarouselSlider( options: CarouselOptions( height: 150, initialPage: 0, enlargeCenterPage: true, autoPlay: true, autoPlayInterval: const Duration(seconds: 3), ), items: CaImages.map((imageURL) { return Container( width: double.infinity, margin: EdgeInsets.symmetric(horizontal: 10), child: Image.asset( imageURL, fit: BoxFit.fill, ), ); }).toList(), ), const SizedBox( height: 25, ), Padding( padding: const EdgeInsets.symmetric(horizontal: 10), child: Row( children: [ const Text( 'Recommended', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 22, ), ), const Spacer(), TextButton( onPressed: () { Navigator.pushReplacement( context, MaterialPageRoute( builder: (BuildContext context) => CategoriesScreen(), ), ); }, child: const Text( 'see all', style: TextStyle( fontSize: 15, ), ), ), ], ), ), const SizedBox( height: 25, ), Padding( padding: const EdgeInsets.symmetric(horizontal: 10), child: Row( children: [ buildColumn(context, ProductScreen(), 'assets/images/w1.png'), const Spacer(), buildColumn(context, ProductScreen(), 'assets/images/w1.png'), ], ), ), const SizedBox( height: 25, ), ], ), ), ); // return BlocConsumer<ShopCubit, ShopStates>( // listener: (context, state) {}, // builder: (context, state) { // return SingleChildScrollView( // physics: BouncingScrollPhysics(), // child: Column( // children: [ // const SizedBox( // height: 25, // ), // Padding( // padding: const EdgeInsets.symmetric(horizontal: 10), // child: Row( // children: [ // Flexible( // flex: 8, // child: Container( // height: 50, // margin: const EdgeInsets.symmetric(vertical: 30), // padding: const EdgeInsets.symmetric( // horizontal: 30, vertical: 5), // decoration: BoxDecoration( // color: Colors.white, // borderRadius: BorderRadius.circular(29.5), // ), // child: const TextField( // decoration: InputDecoration( // icon: Icon(Icons.search), // hintText: 'search', // border: InputBorder.none), // ), // ), // ), // ], // ), // ), // Padding( // padding: const EdgeInsets.symmetric(horizontal: 10), // child: Row( // children: const [ // Text( // 'Stores', // style: TextStyle( // fontWeight: FontWeight.bold, // fontSize: 22, // ), // ) // ], // ), // ), // const SizedBox( // height: 25, // ), // Padding( // padding: const EdgeInsets.symmetric(horizontal: 10), // child: SizedBox( // height: 135, // child: ListView.builder( // shrinkWrap: true, // physics: BouncingScrollPhysics(), // scrollDirection: Axis.horizontal, // itemCount: imagessss.length, // itemBuilder: (context, index) => Container( // margin: const EdgeInsets.only(right: 20), // width: 80, // child: Column( // children: <Widget>[ // FloatingActionButton( // //backgroundColor: , // onPressed: () { // Navigator.pushReplacement( // context, // MaterialPageRoute( // builder: (context) => CategoriesScreen(), // )); // }, // child: Container( // height: 80, // decoration: BoxDecoration( // shape: BoxShape.circle, // image: DecorationImage( // fit: BoxFit.fill, // image: AssetImage( // imagessss[index], // ), // ), // ), // ), // ), // const SizedBox( // height: 20, // ), // index == 0 // ? const Text('Cars') // : index == 1 // ? const Text('Electronics') // : index == 2 // ? const Text('Groceries') // : index == 3 // ? const Text('Makeup') // : index == 4 // ? const Text('') // : const Text('') // ], // ), // ), // ), // ), // ), // Padding( // padding: const EdgeInsets.symmetric(horizontal: 10), // child: Row( // children: const [ // Text( // 'Brands', // style: TextStyle( // fontWeight: FontWeight.bold, // fontSize: 22, // ), // ) // ], // ), // ), // const SizedBox(height: 25,), // Padding( // padding: const EdgeInsets.symmetric(horizontal: 20), // child: SizedBox( // height: 100, // child: ListView.builder( // shrinkWrap: true, // physics: BouncingScrollPhysics(), // scrollDirection: Axis.horizontal, // itemCount: imagessss.length, // itemBuilder: (context, index) => GestureDetector( // onTap: (){ // Navigator.pushReplacement( // context, // MaterialPageRoute(builder: (BuildContext context)=>BrandsScreen(),), // ); // }, // child: Container( // color: Colors.white, // margin: const EdgeInsets.only(right: 20), // child: Center( // child: Padding( // padding: const EdgeInsets.symmetric(horizontal: 15.0), // child: Row( // crossAxisAlignment: CrossAxisAlignment.center, // children: [ // FloatingActionButton( // onPressed: () { // Navigator.pushReplacement( // context, // MaterialPageRoute(builder: (BuildContext context)=>BrandsScreen(),), // ); // }, // child: Container( // height: 80, // decoration: BoxDecoration( // shape: BoxShape.circle, // image: DecorationImage( // fit: BoxFit.fill, // image: AssetImage( // imagessss[index], // ), // ), // ), // ), // ), // const SizedBox(width: 15,), // Column( // crossAxisAlignment: CrossAxisAlignment.start, // mainAxisAlignment: MainAxisAlignment.center, // children: [ // Text('Brand Name', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 19,),), // const SizedBox(height: 5,), // Text('Details', style: TextStyle(fontSize: 15,),), // ], // ) // ], // ), // ), // ), // ), // ), // ), // ), // ), // const SizedBox(height: 25,), // const Padding( // padding: EdgeInsets.symmetric(horizontal: 10), // child: Align( // alignment: Alignment.topLeft, // child: Text( // 'For you', // style: TextStyle( // fontWeight: FontWeight.bold, // fontSize: 22, // ), // ), // ), // ), // const SizedBox( // height: 25, // ), // CarouselSlider( // options: CarouselOptions( // height: 150, // initialPage: 0, // enlargeCenterPage: true, // autoPlay: true, // autoPlayInterval: const Duration(seconds: 3), // ), // items: CaImages.map((imageURL) { // return Container( // width: double.infinity, // margin: EdgeInsets.symmetric(horizontal: 10), // child: Image.asset( // imageURL, // fit: BoxFit.fill, // ), // ); // }).toList(), // ), // const SizedBox( // height: 25, // ), // Padding( // padding: const EdgeInsets.symmetric(horizontal: 10), // child: Row( // children: [ // const Text( // 'Recommended', // style: TextStyle( // fontWeight: FontWeight.bold, // fontSize: 22, // ), // ), // const Spacer(), // TextButton( // onPressed: () { // Navigator.pushReplacement( // context, // MaterialPageRoute(builder: (BuildContext context)=>CategoriesScreen(),), // ); // }, // child: const Text( // 'see all', // style: TextStyle( // fontSize: 15, // ), // ), // ), // ], // ), // ), // const SizedBox( // height: 25, // ), // Padding( // padding: const EdgeInsets.symmetric(horizontal: 10), // child: Row( // children: [ // buildColumn(context, ProductScreen(), 'assets/images/w1.png'), // const Spacer(), // buildColumn(context, ProductScreen(), 'assets/images/w1.png'), // ], // ), // ), // const SizedBox(height: 25,), // ], // ), // ); // }, // ); } }
0
mirrored_repositories/Oshops-app/lib
mirrored_repositories/Oshops-app/lib/screens/profile.dart
// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables, use_key_in_widget_constructors, sized_box_for_whitespace, deprecated_member_use import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:shop_app/business_logic/cubit/api_services/api_services_cubit.dart'; import 'package:shop_app/constants/toast_constant.dart'; import 'package:shop_app/models/constants.dart'; import 'package:shop_app/screens/edit_profile.dart'; import 'package:shop_app/screens/shopping_address.dart'; import 'package:image_picker/image_picker.dart'; import 'package:image_cropper/image_cropper.dart'; import 'package:shop_app/shared/network/local/cache_helper.dart'; import 'package:shop_app/modules/login/log_in_form.dart'; class ProfileScreen extends StatefulWidget { @override _ProfileScreenState createState() => _ProfileScreenState(); } class _ProfileScreenState extends State<ProfileScreen> { var titleTextStyle = TextStyle( fontSize: 22, fontWeight: FontWeight.bold, fontStyle: FontStyle.normal, ); File? imageFile; void showCameraDialog() { showDialog( context: context, builder: (context) { return AlertDialog( title: Text( 'please choose an option', style: TextStyle( color: Colors.black, fontSize: 20, fontWeight: FontWeight.bold, ), ), content: Container( width: MediaQuery.of(context).size.width * 0.9, child: Column( mainAxisSize: MainAxisSize.min, children: [ InkWell( onTap: pickImageWithCamera, child: Padding( padding: const EdgeInsets.all(8.0), child: Row(children: [ Icon( Icons.camera_alt_outlined, color: Colors.blue, ), SizedBox( width: 10, ), Text( 'camera', style: TextStyle( color: Colors.blue, fontSize: 20, ), ) ]), ), ), InkWell( onTap: pickImageWithGallery, child: Padding( padding: const EdgeInsets.all(8.0), child: Row(children: [ Icon( Icons.image_outlined, color: Colors.blue, ), SizedBox( width: 10, ), Text( 'gallery', style: TextStyle( color: Colors.blue, fontSize: 20, ), ) ]), ), ), ], )), ); }, ); } void pickImageWithCamera() async { PickedFile? pickedFile = await ImagePicker() .getImage(source: ImageSource.camera, maxWidth: 1080, maxHeight: 1080); // setState(() { // imageFile = File(pickedFile!.path); // }); cropImage(pickedFile!.path); Navigator.pop(context); } void pickImageWithGallery() async { PickedFile? pickedFile = await ImagePicker() .getImage(source: ImageSource.gallery, maxWidth: 1080, maxHeight: 1080); // setState(() { // imageFile = File(pickedFile!.path); // }); cropImage(pickedFile!.path); Navigator.pop(context); } void cropImage(filePath) async { File? cropImage = await ImageCropper.cropImage( sourcePath: filePath, maxWidth: 1080, maxHeight: 1080); if (cropImage != null) { setState(() { filePath = cropImage; }); } } String? token; getAccessToken() async { await CacheHelper.init(); var access_token = CacheHelper.getData(key: 'access_token'); print("the token is $access_token"); await ApiServicesCubit.getInstance(context) .getCurrentUser(token: access_token); token = access_token; } @override void initState() { super.initState(); getAccessToken(); } @override Widget build(BuildContext context) { Size size = MediaQuery.of(context).size; return Scaffold( body: Column( children: [ Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ Padding( padding: const EdgeInsets.only(top: 40, left: 20, bottom: 20), child: GestureDetector( onTap: showCameraDialog, child: Container( width: size.width * 0.29, height: size.width * 0.29, decoration: BoxDecoration( border: Border.all( width: 9, color: Theme.of(context).scaffoldBackgroundColor), shape: BoxShape.circle, ), child: imageFile == null ? Image.network( 'https://cdn.icon-icons.com/icons2/2643/PNG/512/male_boy_person_people_avatar_icon_159358.png', ) : Image.file( imageFile!, fit: BoxFit.fill, ), ), ), ), SizedBox( width: 30, ), BlocBuilder<ApiServicesCubit, ApiServicesStates>( builder: (context, state) { var firstName, lastName, email, address; if (state is UserInfoLoadedState) { firstName = state.data["userData"]["firstName"]; lastName = state.data["userData"]["lastName"]; email = state.data["userData"]["email"]; address = state.data["userData"]["address"]; print(email); } else if (state is UserInfoUnLoadedState) { ToastConstant.showToast(context, state.error); } return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Icon( Icons.people, size: 15, color: Colors.blue, ), const SizedBox(width: 8), Text( firstName == null ? "Name" : "$firstName $lastName", style: TextStyle( fontSize: 25, fontWeight: FontWeight.bold, ), ), ], ), SizedBox( height: 10, ), Row( children: [ Icon( Icons.email, size: 15, color: Colors.blue, ), const SizedBox(width: 8), Text( email == null ? "email" : email, style: TextStyle(fontSize: 18), ), ], ), SizedBox( height: 10, ), Row( children: [ Icon( Icons.place, size: 15, color: Colors.blue, ), const SizedBox(width: 8), Text( address == null ? "address" : address, style: TextStyle(fontSize: 18), ), ], ), ], ); }, ), ], ), SizedBox( height: 20, ), buildGestureDetector(Icons.edit, 'Edit Profile', () { Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => EditProfile(), ), ); }), SizedBox( height: 20, ), buildGestureDetector(Icons.location_on_outlined, 'Shopping Address', () { Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => ShoppingAddress(), ), ); }), SizedBox( height: 20, ), buildGestureDetector(Icons.logout, 'Log Out', () { final alert = AlertDialog( title: Align( alignment: Alignment.center, child: Text( 'Are you sure to log out?', style: TextStyle(color: Colors.black, fontSize: 20), )), content: Row( children: [ Container( height: 40, child: TextButton( onPressed: () async { await CacheHelper.init(); CacheHelper.deleteData(key: "access_token") .then((value) { if (value) { Navigator.of(context).push( MaterialPageRoute( builder: (context) => LoginScreen(" "), ), ); } }); }, child: Text( 'Yes', style: TextStyle(color: Colors.blue, fontSize: 20), )), ), Spacer(), Container( height: 40, child: TextButton( onPressed: () { Navigator.pop(context); }, child: Text( 'No', style: TextStyle(color: Colors.blue, fontSize: 20), )), ), ], ), ); showDialog(builder: (context) => alert, context: context); }), ], ), ); } GestureDetector buildGestureDetector(icon, text, fun) { return GestureDetector( onTap: fun, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 40), child: Row( children: [ Container( child: Padding( padding: const EdgeInsets.all(8.0), child: Icon(icon), ), color: light, ), SizedBox( width: 10, ), Text( text, style: TextStyle(fontSize: 20), ), Spacer(), Icon(Icons.arrow_forward_ios_rounded), ], ), ), ); } }
0
mirrored_repositories/Oshops-app/lib
mirrored_repositories/Oshops-app/lib/screens/edit_profile.dart
// ignore_for_file: avoid_returning_null_for_void import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:shop_app/business_logic/cubit/api_services/api_services_cubit.dart'; import 'package:shop_app/constants/toast_constant.dart'; import 'package:shop_app/models/constants.dart'; import 'package:shop_app/screens/bottom_navigator_bar.dart'; import 'package:shop_app/screens/profile.dart'; import 'package:shop_app/shared/network/local/cache_helper.dart'; class EditProfile extends StatefulWidget { @override State<EditProfile> createState() => _EditProfileState(); } class _EditProfileState extends State<EditProfile> { var _firstNameController = TextEditingController(); var _lastNameController = TextEditingController(); var _emailController = TextEditingController(); var formSignupKey = GlobalKey<FormState>(); var resetKey = GlobalKey<FormState>(); bool isChecked = false; @override Widget build(BuildContext context) { return Scaffold( body: Center( child: SingleChildScrollView( physics: BouncingScrollPhysics(), child: Form( key: formSignupKey, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 30), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( 'assets/images/OShops.png', height: 150, width: 150, ), Align( alignment: Alignment.bottomLeft, child: IconButton( onPressed: () { Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => BottomNavigationScreen(), ), ); }, icon: Icon(Icons.arrow_back_ios), ), ), Card( child: Padding( padding: const EdgeInsets.all(15), child: Column( children: [ Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'edit profile', style: TextStyle( fontSize: 30, fontWeight: FontWeight.bold), ), ], ), SizedBox( height: 10, ), TextFormField( controller: _firstNameController, validator: (value) { if (value!.isEmpty) { return 'Please enter your first name'; } else { return null; } }, keyboardType: TextInputType.text, decoration: InputDecoration( hintText: 'enter your first name', labelText: 'First Name', // style: TextStyle(color: signup_bg), ), ), SizedBox( height: 10, ), TextFormField( controller: _lastNameController, validator: (value) { if (value!.isEmpty) { return 'Please enter your last name'; } else { return null; } }, keyboardType: TextInputType.text, decoration: InputDecoration( hintText: 'enter your last name', labelText: 'Last Name', // style: TextStyle(color: signup_bg), ), ), SizedBox( height: 10, ), TextFormField( controller: _emailController, validator: (value) { if (value!.isEmpty) { return 'Please enter your email'; } else { return null; } }, keyboardType: TextInputType.emailAddress, decoration: InputDecoration( hintText: 'enter your email', labelText: 'Email', // style: TextStyle(color: signup_bg), ), ), SizedBox( height: 30, ), BlocListener<ApiServicesCubit, ApiServicesStates>( listener: (context, state) { if (state is EditProfileSuccessState) { ToastConstant.showToast(context, state.message); setState(() { isChecked = false; }); Navigator.push( context, MaterialPageRoute( builder: (context) => BottomNavigationScreen(), ), ); } else if (state is EditProfileUnSuccessState) { setState(() { isChecked = false; }); ToastConstant.showToast(context, state.error); } }, child: BlocBuilder<ApiServicesCubit, ApiServicesStates>( builder: (context, state) { return FlatButton( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20), ), minWidth: 500, color: signup_bg, onPressed: () async { setState(() { isChecked = true; }); if (formSignupKey.currentState! .validate()) { FocusScope.of(context).unfocus(); await CacheHelper.init(); var access_token = CacheHelper.getData( key: 'access_token'); print("the token is $access_token"); await ApiServicesCubit.getInstance( context) .editProfile( firstName: _firstNameController.text, lastName: _lastNameController.text, email: _emailController.text, token: access_token, ); } else { setState(() { isChecked = false; }); } }, child: Text('Submit'.toUpperCase(), style: TextStyle( color: Colors.white, fontSize: 20)), ); }, ), ), const SizedBox( height: 10, ), Visibility( visible: isChecked, child: CircularProgressIndicator( color: Colors.blue, ), ), ], ), ), ) ], ), ), ), ), ), ); } }
0
mirrored_repositories/Oshops-app/lib
mirrored_repositories/Oshops-app/lib/screens/card.dart
import 'package:flutter/material.dart'; import 'package:shop_app/models/constants.dart'; import 'package:shop_app/screens/product.dart'; class CardScreen extends StatefulWidget { @override State<CardScreen> createState() => _CardScreenState(); } class _CardScreenState extends State<CardScreen> { int num = 0; int price = 0; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( elevation: 0, backgroundColor: Colors.white10, leading: IconButton( icon: Icon(Icons.arrow_back_ios,color: Colors.black,), onPressed: (){ Navigator.pushReplacement(context, MaterialPageRoute(builder: (context)=>ProductScreen()),); }, ), ), body: SingleChildScrollView( child: Column( children: [ const SizedBox(height: 20,), Padding( padding: const EdgeInsets.all(20.0), child: Column( children: [ buildRow(), const SizedBox(height: 300,), Padding( padding: const EdgeInsets.symmetric(horizontal: 30), child: Align( alignment: Alignment.bottomCenter, child: Container( child: Row( children: [ Column( children: [ const Text('TOTAL', style: TextStyle(fontSize: 20),), Text('${price} \$', style: TextStyle(color: Colors.green, fontSize: 30),), ], ), const Spacer(), FlatButton( color: Colors.green, onPressed: (){ final alert = AlertDialog( title: Text('Go to the website', style: TextStyle(color: Colors.black, fontSize: 30),), content: Container( height: 40, child: Text('https:website.com', style: TextStyle(color: Colors.blue, fontSize: 20),), ), ); showDialog(builder: (context) => alert, context: context); }, child: Text('Check Out', style: TextStyle(color: Colors.white, fontSize: 30),)) ], ), ), ), ) ], ), ), ], ), ), ); } Row buildRow() { return Row( children: [ Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: g, ), height: 180, width: 180, child: Image.asset('assets/images/w1.png'), ), const SizedBox( width: 20, ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text('watch', style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold),), const SizedBox( height: 10, ), const Text( '300\$', style: TextStyle(fontSize: 19, color: Colors.green), ), const SizedBox( height: 10, ), Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: g, ), child: Row( children: [ IconButton(onPressed: (){setState(() { num++; price = price+300; });}, icon: Icon(Icons.plus_one)), const SizedBox( width: 20, ), Text('${num}', style: TextStyle(fontSize: 27),), const SizedBox( width: 20, ), IconButton(onPressed: (){setState(() { if(num>0){ num--; price = price-300; } });}, icon: Icon(Icons.exposure_minus_1)), ], ), ) ], ) ], ); } }
0
mirrored_repositories/Oshops-app/lib
mirrored_repositories/Oshops-app/lib/screens/brands.dart
// ignore_for_file: use_key_in_widget_constructors import 'package:flutter/material.dart'; import 'package:shop_app/models/constants.dart'; import 'package:shop_app/screens/bottom_navigator_bar.dart'; import 'package:shop_app/screens/product.dart'; import 'package:shop_app/screens/shopping.dart'; class BrandsScreen extends StatelessWidget { List BrandsName = [ 'adidas', 'Samsung', 'Noon', 'Nike', 'apple', ]; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( centerTitle: true, elevation: 0, backgroundColor: Colors.white10, title: const Text( 'Brand Name', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 22, color: Colors.black), ), leading: IconButton( onPressed: () { Navigator.pushReplacement( context, MaterialPageRoute( builder: (BuildContext context) => BottomNavigationScreen(), ), ); }, icon: const Icon( Icons.arrow_back_ios, color: Colors.black, ), ), ), body: SingleChildScrollView( physics: const BouncingScrollPhysics(), child: Column( children: [ const SizedBox( height: 30, ), Padding( padding: const EdgeInsets.symmetric(horizontal: 10), child: Row( children: [ buildColumn(context), const Spacer(), buildColumn(context), ], ), ), const SizedBox( height: 20, ), Padding( padding: const EdgeInsets.symmetric(horizontal: 10), child: Row( children: [ buildColumn(context), const Spacer(), buildColumn(context), ], ), ), const SizedBox( height: 20, ), Padding( padding: const EdgeInsets.symmetric(horizontal: 10), child: Row( children: [ buildColumn(context), const Spacer(), buildColumn(context), ], ), ), ], ), ), ); } Column buildColumn(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ GestureDetector( onTap: () { Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => ProductScreen())); }, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: g, ), height: 180, width: 180, child: Image.asset('assets/images/w1.png'), ), ), const SizedBox( height: 10, ), const Text('watch', style: TextStyle(fontSize: 19), maxLines: 2, overflow: TextOverflow.ellipsis), const SizedBox( height: 10, ), const Text( '300\$', style: TextStyle(fontSize: 19, color: Colors.green), ), ], ); } }
0
mirrored_repositories/Oshops-app/lib
mirrored_repositories/Oshops-app/lib/screens/product.dart
import 'package:flutter/material.dart'; import 'package:shop_app/models/constants.dart'; import 'package:shop_app/screens/card.dart'; import 'categories.dart'; class ProductScreen extends StatelessWidget { const ProductScreen({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( body: Column( children: [ Container( decoration: const BoxDecoration( borderRadius: BorderRadius.only(bottomLeft: Radius.circular(70), bottomRight: Radius.circular(70)), color: g, ), height: 300, width: double.infinity, child: Stack( alignment: Alignment.center, children: [ Image.asset('assets/images/w1.png'), Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Padding( padding: const EdgeInsets.only(left: 20), child: Align(alignment: Alignment.topLeft,child: IconButton(onPressed: (){ Navigator.pushReplacement( context, MaterialPageRoute(builder: (BuildContext context)=>CategoriesScreen(),), ); },icon: const Icon(Icons.arrow_back_ios))), ), ], ), ], ), ), const SizedBox(height: 10,), const Text('Sliver Watch From \'BOSS\'', style: TextStyle(fontSize: 19, fontWeight: FontWeight.bold), ), const SizedBox(height: 20,), Padding( padding: const EdgeInsets.symmetric(horizontal: 50), child: Row( children: [ Row( children: const [ Text('Size:', style: TextStyle(fontSize: 20),), SizedBox(width: 30,), Text('for men', style: TextStyle(fontSize: 20),), ], ), const Spacer(), Row( children: [ const Text('Color:', style: TextStyle(fontSize: 20),), const SizedBox(width: 30,), Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: Colors.grey, ), height: 30, width: 30, ), ], ) ], ), ), const SizedBox(height: 30,), Padding( padding: const EdgeInsets.symmetric(horizontal: 20), child: Align( alignment: Alignment.topLeft, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: const [ Text('Details', style: TextStyle(fontSize: 20,fontWeight: FontWeight.bold),), SizedBox(height: 10,), Text('From Database', style: TextStyle(fontSize: 20),), ], ), ), ), const SizedBox(height: 90,), Align( alignment: Alignment.bottomCenter, child: FlatButton( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20), ), color: Colors.blue, onPressed: (){ Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => CardScreen())); }, child: Text('add to card', style: TextStyle(fontSize: 20, color: Colors.white),), ), ) ], ), ); } }
0
mirrored_repositories/Oshops-app/lib
mirrored_repositories/Oshops-app/lib/screens/search_screen.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:shop_app/business_logic/cubit/api_services/api_services_cubit.dart'; import 'package:shop_app/constants/toast_constant.dart'; import 'package:shop_app/shared/network/local/cache_helper.dart'; class SearchScreen extends StatefulWidget { const SearchScreen({Key? key}) : super(key: key); @override _SearchScreenState createState() => _SearchScreenState(); } class _SearchScreenState extends State<SearchScreen> { String? item; List<Map<String, dynamic>> products = []; @override Widget build(BuildContext context) { return Scaffold( body: Padding( padding: const EdgeInsets.all(10), child: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const SizedBox(height: 50), Row( children: [ InkWell( onTap: () { Navigator.of(context).pop(); }, child: Icon( Icons.arrow_back_ios, size: 25, color: Colors.black, ), ), SizedBox(width: 10), Text( "Find your items", style: TextStyle( fontSize: 23, fontWeight: FontWeight.w700, color: Colors.black, ), ) ], ), SizedBox(height: 20), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( width: 250, child: TextField( decoration: InputDecoration( hintText: 'search about your items', prefixIcon: Icon( Icons.search, color: Colors.black, size: 18, ), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(5.0), borderSide: BorderSide( color: Colors.grey, width: 0.4, ), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(5.0), borderSide: BorderSide( color: Colors.grey, width: 0.4, ), ), border: OutlineInputBorder( borderRadius: BorderRadius.circular(5.0), borderSide: BorderSide( color: Colors.grey, width: 0.4, ), ), ), onChanged: (value) { setState(() { item = value.toString(); }); }, ), ), InkWell( onTap: () async { await CacheHelper.init(); var access_token = CacheHelper.getData(key: 'access_token'); print("the token is $access_token"); ApiServicesCubit.getInstance(context).searchItem( token: access_token, param: item!, ); }, child: BlocBuilder<ApiServicesCubit, ApiServicesStates>( builder: (context, state) { if (state is SearchItemFoundState) { products = state.items; products.sort(); // sort items from shotest to longest } else if (state is SearchItemNotFoundState) { ToastConstant.showToast(context, state.error); } return Container( width: 60, height: 40, decoration: BoxDecoration( color: Colors.blue, borderRadius: BorderRadius.circular(10), ), child: Icon( Icons.search, color: Colors.white, size: 20, ), ); }, ), ), ], ), ///** /// هشام هنا هتعمل ليست فيو ويدجيت وتنادي فيها علي اللسته /// بعد معملتلها سورت هتلاقيها فوق سطر 109 /// وبعد كدا هترسم شكل للداتا بس دا كل الي هتعمله هنا /// */ ], ), ), ), ); } }
0
mirrored_repositories/Oshops-app/lib
mirrored_repositories/Oshops-app/lib/screens/categories.dart
// ignore_for_file: use_key_in_widget_constructors import 'package:flutter/material.dart'; import 'package:shop_app/models/constants.dart'; import 'package:shop_app/screens/bottom_navigator_bar.dart'; import 'package:shop_app/screens/product.dart'; class CategoriesScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( centerTitle: true, elevation: 0, backgroundColor: Colors.white10, title: const Text( 'Categories', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 22, color: Colors.black), ), leading: IconButton( onPressed: () { Navigator.pushReplacement( context, MaterialPageRoute( builder: (BuildContext context) => BottomNavigationScreen(), ), ); }, icon: const Icon( Icons.arrow_back_ios, color: Colors.black, ), ), ), body: SingleChildScrollView( physics: const BouncingScrollPhysics(), child: Column( children: [ const SizedBox( height: 30, ), Padding( padding: const EdgeInsets.symmetric(horizontal: 10), child: Row( children: [ buildColumn(context), const Spacer(), buildColumn(context), ], ), ), const SizedBox( height: 20, ), Padding( padding: const EdgeInsets.symmetric(horizontal: 10), child: Row( children: [ buildColumn(context), const Spacer(), buildColumn(context), ], ), ), const SizedBox( height: 20, ), Padding( padding: const EdgeInsets.symmetric(horizontal: 10), child: Row( children: [ buildColumn(context), const Spacer(), buildColumn(context), ], ), ), ], ), ), ); } Column buildColumn(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ GestureDetector( onTap: () { Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => ProductScreen())); }, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: g, ), height: 180, width: 180, child: Image.asset('assets/images/w1.png'), ), ), const SizedBox( height: 10, ), const Text('watch', style: TextStyle(fontSize: 19), maxLines: 2, overflow: TextOverflow.ellipsis), const SizedBox( height: 10, ), const Text( '300\$', style: TextStyle(fontSize: 19, color: Colors.green), ), ], ); } }
0
mirrored_repositories/Oshops-app/lib
mirrored_repositories/Oshops-app/lib/screens/shopping_address.dart
// ignore_for_file: avoid_returning_null_for_void, prefer_const_constructors, use_key_in_widget_constructors import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:shop_app/business_logic/cubit/api_services/api_services_cubit.dart'; import 'package:shop_app/constants/toast_constant.dart'; import 'package:shop_app/models/constants.dart'; import 'package:shop_app/screens/bottom_navigator_bar.dart'; import 'package:shop_app/shared/network/local/cache_helper.dart'; class ShoppingAddress extends StatefulWidget { @override State<ShoppingAddress> createState() => _ShoppingAddressState(); } class _ShoppingAddressState extends State<ShoppingAddress> { var _addressController = TextEditingController(); var formSignupKey = GlobalKey<FormState>(); var resetKey = GlobalKey<FormState>(); bool isChecked = false; @override Widget build(BuildContext context) { return Scaffold( body: Center( child: SingleChildScrollView( physics: BouncingScrollPhysics(), child: Form( key: formSignupKey, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 30), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( 'assets/images/OShops.png', height: 150, width: 150, ), Align( alignment: Alignment.bottomLeft, child: IconButton( onPressed: () { Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => BottomNavigationScreen(), ), ); }, icon: Icon(Icons.arrow_back_ios), ), ), Card( child: Padding( padding: const EdgeInsets.all(15), child: Column( children: [ Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Add your shopping address', style: TextStyle( fontSize: 25, fontWeight: FontWeight.bold), ), ], ), SizedBox( height: 10, ), TextFormField( controller: _addressController, validator: (value) { if (value!.isEmpty) { return 'Please enter your shopping address'; } else { return null; } }, keyboardType: TextInputType.text, decoration: InputDecoration( hintText: 'enter your shopping address', labelText: 'Shopping Address', ), ), SizedBox( height: 10, ), BlocListener<ApiServicesCubit, ApiServicesStates>( listener: (context, state) { if (state is SuccessAddAdressState) { ToastConstant.showToast(context, state.message); setState(() { isChecked = false; }); Navigator.push( context, MaterialPageRoute( builder: (context) => BottomNavigationScreen(), ), ); } else if (state is UnSucessAddedAdderessState) { setState(() { isChecked = false; }); ToastConstant.showToast(context, state.error); } }, child: BlocBuilder<ApiServicesCubit, ApiServicesStates>( builder: (context, state) { return FlatButton( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20), ), minWidth: 500, color: signup_bg, onPressed: () async { setState(() { isChecked = true; }); if (formSignupKey.currentState! .validate()) { FocusScope.of(context).unfocus(); await CacheHelper.init(); var access_token = CacheHelper.getData( key: 'access_token'); print("the token is $access_token"); await ApiServicesCubit.getInstance( context) .AddShoppingAddress( address: _addressController.text, token: access_token, ); } else { setState(() { isChecked = false; }); } }, child: Text( 'Submit'.toUpperCase(), style: TextStyle( color: Colors.white, fontSize: 20, ), ), ); }, ), ), const SizedBox( height: 10, ), Visibility( visible: isChecked, child: CircularProgressIndicator( color: Colors.blue, ), ), ], ), ), ) ], ), ), ), ), ), ); } }
0
mirrored_repositories/Oshops-app/lib/screens
mirrored_repositories/Oshops-app/lib/screens/products/all_products.dart
import 'package:flutter/material.dart'; class AllProducts extends StatelessWidget { const AllProducts({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( body: Column( ), ); } }
0
mirrored_repositories/Oshops-app/lib/screens
mirrored_repositories/Oshops-app/lib/screens/products/bottom_nav.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:shop_app/cubit/cubit.dart'; import 'package:shop_app/cubit/states.dart'; import 'package:curved_navigation_bar/curved_navigation_bar.dart'; class BottomNav extends StatefulWidget { final String? token; BottomNav(this.token); @override _BottomNavState createState() => _BottomNavState(token); } class _BottomNavState extends State<BottomNav> { final String? token; _BottomNavState(this.token); @override Widget build(BuildContext context) { //Size size = MediaQuery.of(context).size; return BlocProvider( create: (BuildContext context) => ShopCubit(), child: BlocConsumer<ShopCubit, ShopStates>( listener: (BuildContext context, state) {}, builder: (context, state){ final items = [ const Icon(Icons.shopping_cart_outlined, size: 30), const Icon(Icons.person_outlined, size: 30), ]; var cubit = ShopCubit.get(context); return Scaffold( body: cubit.bottomsScreens[cubit.currentIndex], bottomNavigationBar: CurvedNavigationBar( height: 60, onTap: (index){ cubit.changeBottom(index); }, index: cubit.currentIndex, items: items, ), ); }, ) ); } }
0
mirrored_repositories/Oshops-app
mirrored_repositories/Oshops-app/test/widget_test.dart
// // This is a basic Flutter widget test. // // // // To perform an interaction with a widget in your test, use the WidgetTester // // utility that Flutter provides. For example, you can send tap and scroll // // gestures. You can also use WidgetTester to find child widgets in the widget // // tree, read text, and verify that the values of widget properties are correct. // // import 'package:flutter/material.dart'; // import 'package:flutter_test/flutter_test.dart'; // // import 'package:shop_app/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/dino_run_flutter
mirrored_repositories/dino_run_flutter/lib/main.dart
// ignore: import_of_legacy_library_into_null_safe import 'dart:io'; import 'package:flame/flame.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart'; import 'package:hive/hive.dart'; import 'package:path_provider/path_provider.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'ads/ad_state.dart'; import 'game/audio_manager.dart'; import 'game/store_manager.dart'; import 'screens/main_menu.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); await Flame.device.fullScreen(); await Flame.device.setLandscape(); if (!kIsWeb) { if (Platform.isAndroid || Platform.isIOS) { final dir = await getApplicationDocumentsDirectory(); Hive.init(dir.path); await dotenv.load(fileName: ".env"); await AdState.instance.init(); } } await AudioManager.instance.init(); await StoreManager.instance.init(); runApp(AppWidget()); } class AppWidget extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'Dino Running', home: MainMenu(), theme: ThemeData( fontFamily: 'Audiowide-Regular', visualDensity: VisualDensity.adaptivePlatformDensity, ), ); } }
0
mirrored_repositories/dino_run_flutter/lib
mirrored_repositories/dino_run_flutter/lib/widgets/gameover_menu.dart
import 'dart:io'; import 'package:dino_run/ads/ad_state.dart'; import 'package:dino_run/game/store_manager.dart'; import 'package:dino_run/screens/main_menu.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:dino_run/game/game.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart'; class GameOverMenu extends StatefulWidget { final MyGame game; const GameOverMenu({ Key? key, required this.game, }) : super(key: key); @override _GameOverMenuState createState() => _GameOverMenuState(); } class _GameOverMenuState extends State<GameOverMenu> { BannerAd? banner; @override void didChangeDependencies() { super.didChangeDependencies(); if (!kIsWeb) { if (Platform.isAndroid || Platform.isIOS) { AdState.instance.initializations!.then((status) => { setState(() { banner = BannerAd( adUnitId: AdState.instance.bannerAdUntil, size: AdSize.banner, request: AdRequest(), listener: AdState.instance.adListener, )..load(); }) }); } } } @override Widget build(BuildContext context) { return Center( child: Card( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20.0), ), color: Colors.black.withOpacity(0.5), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 100, vertical: 50), child: Column( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Text('Game Over', style: TextStyle(fontSize: 30, color: Colors.white)), SizedBox(height: 10), Text( widget.game.score.toInt() < StoreManager.instance.highestScore! ? 'Your Score was ${widget.game.score.toInt()}' : 'New High Score! Your Score was ${StoreManager.instance.highestScore!}', style: TextStyle(fontSize: 30, color: Colors.white)), SizedBox(height: 10), Column( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ ElevatedButton( style: ButtonStyle( backgroundColor: MaterialStateProperty.all(Colors.blueGrey)), child: Row( mainAxisSize: MainAxisSize.min, children: [ Icon(Icons.replay_outlined), SizedBox(width: 10), Text( 'Retry', style: TextStyle(fontSize: 30.0), ), ], ), onPressed: () { resetGame(); }, ), SizedBox(height: 10), ElevatedButton( style: ButtonStyle( backgroundColor: MaterialStateProperty.all(Colors.blueGrey)), child: Text( 'Main Menu', style: TextStyle(fontSize: 30.0), ), onPressed: () { Navigator.of(context).pushReplacement( MaterialPageRoute( builder: (context) => MainMenu(), ), ); }, ), Container( child: Column( crossAxisAlignment: CrossAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end, children: [ banner == null ? SizedBox(height: 50) : Container( height: 50, width: MediaQuery.of(context).size.width, child: AdWidget( ad: banner!, ), ), ], ), ), ], ) ], ), ), ), ); } void resetGame() { this.widget.game.resetGame(); } }
0
mirrored_repositories/dino_run_flutter/lib
mirrored_repositories/dino_run_flutter/lib/widgets/store.dart
import 'package:dino_run/game/store_manager.dart'; import 'package:dino_run/models/dino_store.dart'; import 'package:flutter/material.dart'; class Store extends StatefulWidget { final Function()? onBackPressed; Store({ Key? key, required this.onBackPressed, }) : super(key: key); @override _StoreState createState() => _StoreState(); } class _StoreState extends State<Store> { @override Widget build(BuildContext context) { return Container( width: 500.0, child: Column( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ createPurchaseLifes(), ValueListenableBuilder( valueListenable: StoreManager.instance.listenableCoins!, builder: (context, int value, child) { return Row( children: [ Image.asset('assets/images/coin/Gold_1.png', width: 25), SizedBox( width: 10, ), Text(value.toString(), style: TextStyle(fontSize: 25, color: Colors.white)), ], ); }), ], ), SizedBox( height: 10, ), Text('Select your Dino!', style: TextStyle(fontSize: 25, color: Colors.white)), SizedBox( height: 10, ), ValueListenableBuilder( valueListenable: StoreManager.instance.listenableDinos!, builder: (context, List<DinoStore> dinos, child) { return Container( height: 120, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: listDinos(dinos), )); }), ElevatedButton( style: ButtonStyle( backgroundColor: MaterialStateProperty.all(Colors.blueGrey)), child: Row( mainAxisSize: MainAxisSize.min, children: [ Icon(Icons.arrow_back_ios_rounded), SizedBox(width: 10), Text( 'Menu', style: TextStyle(fontSize: 30.0), ), ], ), onPressed: widget.onBackPressed), ], ), ); } Row createLifeList(int numberLifes) { final list = <Widget>[]; for (int i = 0; i < 6; ++i) { list.add(Icon(i < numberLifes ? Icons.favorite : Icons.favorite_border, color: Colors.red, size: 30.0)); } return Row( children: list, ); } List<Widget> listDinos(List<DinoStore> dinos) { return dinos.map((dino) { return createDino(dino); }).toList(); } Widget createDino(DinoStore dino) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 8), child: Column( children: [ Container( child: Image.asset(dino.asset), ), dino.isPurchased ? Text( 'Acquired', style: TextStyle(color: Colors.white, fontSize: 16), ) : Row( children: [ SizedBox(width: 5), Image.asset('assets/images/coin/Gold_1.png', width: 10), SizedBox(width: 5), Text( dino.price.toString(), style: TextStyle(color: Colors.white, fontSize: 16), ), ], ), ValueListenableBuilder( valueListenable: StoreManager.instance.listenableCoins!, builder: (context, int currentCoins, child) { return ElevatedButton( style: ButtonStyle( backgroundColor: MaterialStateProperty.all( dino.isPurchased ? (dino.isSelected ? Colors.greenAccent : Colors.lightBlue) : dino.price > currentCoins ? Colors.grey.shade200 : Colors.yellow.shade600, )), child: Text( dino.isPurchased ? (dino.isSelected ? "Selected" : "Select") : 'Purchase', style: TextStyle(fontSize: 10.0, color: Colors.black87), ), onPressed: dino.isPurchased ? (dino.isSelected ? null : () { StoreManager.instance.selectDino(dino); }) : (dino.price > currentCoins ? null : () { StoreManager.instance.purchaseDino(dino); })); }), ], ), ); } createPurchaseLifes() { return ValueListenableBuilder( valueListenable: StoreManager.instance.listenableLifes!, builder: (context, int currentLifes, child) { var price = 25; if (currentLifes == 4) { price = 50; } if (currentLifes == 5) { price = 100; } return Row( children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ currentLifes != 6 ? Row( children: [ Text( 'Get a extra life ', style: TextStyle(color: Colors.white), ), Image.asset('assets/images/coin/Gold_1.png', width: 10), SizedBox(width: 5), Text( price.toString(), style: TextStyle(color: Colors.white, fontSize: 16), ), ], ) : Container(), SizedBox(height: 5), createLifeList(currentLifes) ], ), SizedBox( width: 10, ), ValueListenableBuilder( valueListenable: StoreManager.instance.listenableCoins!, builder: (context, int currentCoins, child) { return ElevatedButton( style: ButtonStyle( backgroundColor: MaterialStateProperty.all( currentLifes == 6 ? Colors.red.shade600 : (price > currentCoins ? Colors.grey.shade200 : Colors.yellow.shade600))), child: Text( currentLifes == 6 ? 'MAX' : 'Purchase', style: TextStyle(fontSize: 10.0, color: Colors.black87), ), onPressed: currentLifes == 6 || price > currentCoins ? null : () { StoreManager.instance.purchaseExtraLife(price); }); }), ], ); }); } }
0
mirrored_repositories/dino_run_flutter/lib
mirrored_repositories/dino_run_flutter/lib/widgets/menu.dart
import 'package:dino_run/game/store_manager.dart'; import 'package:dino_run/screens/game_play.dart'; import 'package:flutter/material.dart'; /// This class displays the first menu on [MainMenu] /// with play and settings buttons. class Menu extends StatelessWidget { final Function()? onSettingsPressed; final Function()? onStorePressed; final Function()? onCreditsPressed; const Menu({ Key? key, required this.onSettingsPressed, required this.onStorePressed, required this.onCreditsPressed, }) : super(key: key); @override Widget build(BuildContext context) { return Column( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Text( 'Dino Running', style: TextStyle(fontSize: 40.0, color: Colors.white), ), ElevatedButton( style: ButtonStyle( backgroundColor: MaterialStateProperty.all(Colors.blueGrey)), child: Text( 'Play', style: TextStyle(fontSize: 20.0), ), onPressed: () { Navigator.of(context).pushReplacement( MaterialPageRoute( builder: (context) => GamePlay(), ), ); }, ), SizedBox(height: 10), Row( mainAxisSize: MainAxisSize.min, children: [ SizedBox(width: 10), ElevatedButton( style: ButtonStyle( backgroundColor: MaterialStateProperty.all(Colors.blueGrey)), child: Text( 'Store', style: TextStyle(fontSize: 20.0), ), onPressed: onStorePressed, ), SizedBox(width: 10), ElevatedButton( style: ButtonStyle( backgroundColor: MaterialStateProperty.all(Colors.blueGrey)), child: Text( 'Settings', style: TextStyle(fontSize: 20.0), ), onPressed: onSettingsPressed, ), SizedBox(width: 10), ElevatedButton( style: ButtonStyle( backgroundColor: MaterialStateProperty.all(Colors.blueGrey)), child: Text( 'Credits', style: TextStyle(fontSize: 20.0), ), onPressed: onCreditsPressed, ) ], ), SizedBox(height: 10), StoreManager.instance.highestScore! > 0 ? Text( 'Best Score: ${StoreManager.instance.highestScore!}', style: TextStyle(fontSize: 20.0, color: Colors.white), ) : Container() ], ); } }
0
mirrored_repositories/dino_run_flutter/lib
mirrored_repositories/dino_run_flutter/lib/widgets/credits.dart
import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; class Credits extends StatelessWidget { final Function()? onBackPressed; const Credits({ Key? key, required this.onBackPressed, }) : super(key: key); @override Widget build(BuildContext context) { return Container( width: 300.0, child: Column( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Text( 'Credits', style: TextStyle(fontSize: 30.0, color: Colors.white), ), SizedBox(height: 10), Center( child: new RichText( text: new TextSpan( children: [ new TextSpan( text: 'Credits assets to ', style: new TextStyle(color: Colors.white), ), new TextSpan( text: 'ScissorMarks', style: new TextStyle(color: Colors.blue), recognizer: new TapGestureRecognizer() ..onTap = () { launch('https://twitter.com/ScissorMarks'); }, ), new TextSpan( text: ', ', style: new TextStyle(color: Colors.white), ), new TextSpan( text: 'Pixel Frog', style: new TextStyle(color: Colors.blue), recognizer: new TapGestureRecognizer() ..onTap = () { launch('https://pixelfrog-assets.itch.io/'); }, ), new TextSpan( text: ' and ', style: new TextStyle(color: Colors.white), ), new TextSpan( text: 'Jesse Munguia', style: new TextStyle(color: Colors.blue), recognizer: new TapGestureRecognizer() ..onTap = () { launch('https://jesse-m.itch.io/'); }, ), ], ), ), ), SizedBox(height: 10), Center( child: new RichText( text: new TextSpan(children: [ new TextSpan( text: 'Credits for teach me to ', style: new TextStyle(color: Colors.white), ), new TextSpan( text: 'DevKage', style: new TextStyle(color: Colors.blue), recognizer: new TapGestureRecognizer() ..onTap = () { launch( 'https://www.youtube.com/channel/UCgofYEUiBiD5lybABz5Kyag'); }, ), ]), ), ), SizedBox(height: 10), ElevatedButton( style: ButtonStyle( backgroundColor: MaterialStateProperty.all(Colors.blueGrey)), child: Row( mainAxisSize: MainAxisSize.min, children: [ Icon(Icons.arrow_back_ios_rounded), SizedBox(width: 10), Text( 'Menu', style: TextStyle(fontSize: 30.0), ), ], ), onPressed: onBackPressed), ], ), ); } }
0
mirrored_repositories/dino_run_flutter/lib
mirrored_repositories/dino_run_flutter/lib/widgets/settings.dart
import 'package:dino_run/game/audio_manager.dart'; import 'package:flutter/material.dart'; class Settings extends StatelessWidget { final Function()? onBackPressed; const Settings({ Key? key, required this.onBackPressed, }) : super(key: key); @override Widget build(BuildContext context) { return Container( width: 300.0, child: Column( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Text( 'Settings', style: TextStyle(fontSize: 60.0, color: Colors.white), ), ValueListenableBuilder( valueListenable: AudioManager.instance.listenableSfx!, builder: (context, bool isSfxOn, child) { return SwitchListTile( value: isSfxOn, title: Text( 'SFX', style: TextStyle(fontSize: 30.0, color: Colors.white), ), onChanged: (bool value) { AudioManager.instance.setSfx(value); }, ); }, ), ValueListenableBuilder( valueListenable: AudioManager.instance.listenableBgm!, builder: (context, bool isBgmOn, child) { return SwitchListTile( value: isBgmOn, title: Text( 'BGM', style: TextStyle(fontSize: 30.0, color: Colors.white), ), onChanged: (bool value) { AudioManager.instance.setBgm(value); }, ); }, ), ElevatedButton( style: ButtonStyle( backgroundColor: MaterialStateProperty.all(Colors.blueGrey)), child: Row( mainAxisSize: MainAxisSize.min, children: [ Icon(Icons.arrow_back_ios_rounded), SizedBox(width: 10), Text( 'Menu', style: TextStyle(fontSize: 30.0), ), ], ), onPressed: onBackPressed), ], ), ); } }
0
mirrored_repositories/dino_run_flutter/lib
mirrored_repositories/dino_run_flutter/lib/widgets/hud_game.dart
import 'package:dino_run/game/store_manager.dart'; import 'package:flutter/material.dart'; import 'package:dino_run/game/game.dart'; class HudGame extends StatelessWidget { final MyGame game; const HudGame({ Key? key, required this.game, }) : super(key: key); @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.only(top: 8, left: 4, right: 8), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ IconButton( icon: Icon(Icons.pause, color: Colors.white, size: 30.0), onPressed: () { pauseGame(); }), Row( children: [ ValueListenableBuilder( valueListenable: game.dino!.coins!, builder: (context, int value, child) { return Row( children: [ Container( child: Image.asset('assets/images/coin/Gold_1.png', width: 25), ), SizedBox( width: 5, ), Text(value.toString(), style: TextStyle(fontSize: 25, color: Colors.white)), ], ); }, ), SizedBox( width: 10, ), ValueListenableBuilder( valueListenable: game.dino!.life!, builder: (context, int value, child) { final list = <Widget>[]; for (int i = 0; i < StoreManager.instance.totalLifes!; ++i) { list.add(Icon( i < value ? Icons.favorite : Icons.favorite_border, color: Colors.red, size: 30.0)); } return Row(children: list); }) ], ), ], ), ); } void pauseGame() { game.pauseGame(); } }
0
mirrored_repositories/dino_run_flutter/lib
mirrored_repositories/dino_run_flutter/lib/widgets/pause_menu.dart
import 'package:dino_run/screens/main_menu.dart'; import 'package:flutter/material.dart'; import 'package:dino_run/game/game.dart'; class PauseMenu extends StatelessWidget { final MyGame game; const PauseMenu({ Key? key, required this.game, }) : super(key: key); @override Widget build(BuildContext context) { return Center( child: Card( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20.0), ), color: Colors.black.withOpacity(0.5), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 100, vertical: 50), child: Column( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Text('Paused', style: TextStyle(fontSize: 30, color: Colors.white)), SizedBox(height: 10), Column( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ ElevatedButton( style: ButtonStyle( backgroundColor: MaterialStateProperty.all(Colors.blueGrey)), child: Row( mainAxisSize: MainAxisSize.min, children: [ Icon(Icons.play_arrow), SizedBox(width: 10), Text( 'Continue', style: TextStyle(fontSize: 30.0), ), ], ), onPressed: () { resumeGame(); }, ), SizedBox(height: 10), ElevatedButton( style: ButtonStyle( backgroundColor: MaterialStateProperty.all(Colors.blueGrey)), child: Text( 'Main Menu', style: TextStyle(fontSize: 30.0), ), onPressed: () { Navigator.of(context).pushReplacement( MaterialPageRoute( builder: (context) => MainMenu(), ), ); }, ), ], ) ], ), ), ), ); } void resumeGame() { game.resumeGame(); } }
0
mirrored_repositories/dino_run_flutter/lib
mirrored_repositories/dino_run_flutter/lib/models/dino_store.dart
import 'package:hive/hive.dart'; part 'dino_store.g.dart'; @HiveType(typeId: 0) class DinoStore extends HiveObject { @HiveField(0) String name; @HiveField(1) String asset; @HiveField(2) String id; @HiveField(3) bool isSelected; @HiveField(4) bool isPurchased; @HiveField(5) int price; @HiveField(6) int dinoType; DinoStore( {required this.name, required this.asset, required this.id, required this.isSelected, required this.isPurchased, required this.price, required this.dinoType}); }
0
mirrored_repositories/dino_run_flutter/lib
mirrored_repositories/dino_run_flutter/lib/models/dino_store.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'dino_store.dart'; // ************************************************************************** // TypeAdapterGenerator // ************************************************************************** class DinoStoreAdapter extends TypeAdapter<DinoStore> { @override final int typeId = 0; @override DinoStore read(BinaryReader reader) { final numOfFields = reader.readByte(); final fields = <int, dynamic>{ for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), }; return DinoStore( name: fields[0] as String, asset: fields[1] as String, id: fields[2] as String, isSelected: fields[3] as bool, isPurchased: fields[4] as bool, price: fields[5] as int, dinoType: fields[6] as int, ); } @override void write(BinaryWriter writer, DinoStore obj) { writer ..writeByte(7) ..writeByte(0) ..write(obj.name) ..writeByte(1) ..write(obj.asset) ..writeByte(2) ..write(obj.id) ..writeByte(3) ..write(obj.isSelected) ..writeByte(4) ..write(obj.isPurchased) ..writeByte(5) ..write(obj.price) ..writeByte(6) ..write(obj.dinoType); } @override int get hashCode => typeId.hashCode; @override bool operator ==(Object other) => identical(this, other) || other is DinoStoreAdapter && runtimeType == other.runtimeType && typeId == other.typeId; }
0
mirrored_repositories/dino_run_flutter/lib
mirrored_repositories/dino_run_flutter/lib/game/store_manager.dart
import 'package:dino_run/models/dino_store.dart'; import 'package:flutter/foundation.dart'; import 'package:hive/hive.dart'; import 'dino.dart'; class StoreManager { StoreManager._internal(); static StoreManager _instance = StoreManager._internal(); static StoreManager get instance => _instance; Future<void> init() async { Hive.registerAdapter(DinoStoreAdapter()); store = await Hive.openBox("store"); dinos = await Hive.openBox<DinoStore>("dinos"); if (store!.get('lifes') == null) { store!.put('lifes', 3); } if (store!.get('coins') == null) { store!.put('coins', 0); } if (store!.get('selectedDino') == null) { store!.put('selectedDino', DinoType.Green.index); } if (store!.get('score') == null) { store!.put('score', 0); } if (dinos!.get('dinoGreen') == null) { dinos!.put( 'dinoGreen', DinoStore( name: 'Green Dino', asset: "assets/images/dinoGreen.gif", id: 'dinoGreen', dinoType: DinoType.Green.index, isPurchased: true, isSelected: true, price: 0, ), ); } if (dinos!.get('dinoYellow') == null) { dinos!.put( 'dinoYellow', DinoStore( name: 'Yellow Dino', asset: "assets/images/dinoYellow.gif", id: 'dinoYellow', dinoType: DinoType.Yellow.index, isPurchased: false, isSelected: false, price: 100, ), ); } if (dinos!.get('dinoBlue') == null) { dinos!.put( 'dinoBlue', DinoStore( name: 'Blue Dino', asset: "assets/images/dinoBlue.gif", id: 'dinoBlue', dinoType: DinoType.Blue.index, isPurchased: false, isSelected: false, price: 200, ), ); } if (dinos!.get('dinoRed') == null) { dinos!.put( 'dinoRed', DinoStore( name: 'Red Dino', asset: "assets/images/dinoRed.gif", id: 'dinoRed', dinoType: DinoType.Red.index, isPurchased: false, isSelected: false, price: 400, ), ); } _lifes = ValueNotifier(store!.get('lifes')); _coins = ValueNotifier(store!.get('coins')); _score = ValueNotifier(store!.get('score')); _dinos = ValueNotifier(getAllDinos()); } List<DinoStore> getAllDinos() { return [ dinos!.get('dinoGreen'), dinos!.get('dinoYellow'), dinos!.get('dinoBlue'), dinos!.get('dinoRed'), ]; } Box? store; Box? dinos; ValueNotifier<int>? _lifes; int? get totalLifes => _lifes!.value; ValueNotifier<int>? get listenableLifes => _lifes; void setLifes(int lifes) { store!.put('lifes', lifes); _lifes!.value = lifes; } ValueNotifier<int>? _score; int? get highestScore => _score!.value; ValueNotifier<int>? get listenableScore => _score; void setHighScore(int score) { if (score > highestScore!) { store!.put('score', score); _score!.value = score; } } ValueNotifier<int>? _coins; ValueNotifier<int>? get listenableCoins => _coins; int? get currentCoins => _coins!.value; void setCoins(int coins) { store!.put('coins', coins); _coins!.value = coins; } void addCoins(int coins) { setCoins(currentCoins! + coins); } DinoType get selectedDino => DinoType.values[store!.get('selectedDino')]; void setSelectedDino(int value) { store!.put('selectedDino', value); } ValueNotifier<List<DinoStore>>? _dinos; ValueNotifier<List<DinoStore>>? get listenableDinos => _dinos; void purchaseExtraLife(int price) { setCoins(currentCoins! - price); setLifes(totalLifes! + 1); } void purchaseDino(DinoStore purchaseDino) { purchaseDino.isPurchased = true; purchaseDino.save(); setCoins(currentCoins! - purchaseDino.price); _dinos!.value = getAllDinos(); } void selectDino(DinoStore selectDino) { var currentDino = _getSelectedDino(); currentDino!.isSelected = false; selectDino.isSelected = true; currentDino.save(); selectDino.save(); setSelectedDino(selectDino.dinoType); _dinos!.value = getAllDinos(); } DinoStore? _getSelectedDino() { switch (selectedDino) { case DinoType.Green: return dinos!.get("dinoGreen"); case DinoType.Yellow: return dinos!.get("dinoYellow"); case DinoType.Blue: return dinos!.get("dinoBlue"); case DinoType.Red: return dinos!.get("dinoRed"); default: dinos!.get(""); } } }
0
mirrored_repositories/dino_run_flutter/lib
mirrored_repositories/dino_run_flutter/lib/game/dino.dart
import 'package:dino_run/game/store_manager.dart'; import 'package:flame/assets.dart'; import 'package:flame/components.dart'; import 'package:flame/extensions.dart'; import 'package:flame/sprite.dart'; import 'package:flutter/widgets.dart' hide Image; // import 'package:flutter/widgets.dart'; import 'audio_manager.dart'; import 'constats.dart'; enum DinoType { Blue, Green, Red, Yellow } class DinoData { final String image; DinoData({ required this.image, }); } class Dino extends SpriteAnimationComponent { DinoData? _myData; static Map<DinoType, DinoData> _dinoDetails = { DinoType.Blue: DinoData( image: dinoBluePng, ), DinoType.Red: DinoData( image: dinoRedPng, ), DinoType.Yellow: DinoData( image: dinoYellowPng, ), DinoType.Green: DinoData( image: dinoGreenPng, ) }; SpriteAnimation? _runAnimation; SpriteAnimation? _hitAnimation; Timer? _timer; bool _isHit = false; double speedY = 0.0; double yMax = 0.0; ValueNotifier<int>? life; ValueNotifier<int>? coins; Dino(DinoType type, Images images) { _myData = _dinoDetails[type]; final spriteSheet = SpriteSheet.fromColumnsAndRows( image: images.fromCache(_myData!.image), columns: 24, rows: 1); _runAnimation = spriteSheet.createAnimation(row: 0, stepTime: 0.1, from: 4, to: 10); _hitAnimation = spriteSheet.createAnimation(row: 0, stepTime: 0.1, from: 14, to: 16); this.animation = _runAnimation; _timer = Timer(1, callback: () { run(); }); this.anchor = Anchor.center; life = ValueNotifier(StoreManager.instance.totalLifes!); coins = ValueNotifier(0); } @override void update(double dt) { super.update(dt); // final velocity = initial velocity + gravity * time; // v = u + ut this.speedY += GRAVITY * dt; //distace = speed * time; // d = s * t this.y += this.speedY * dt; if (isOnGround()) { this.y = this.yMax; this.speedY = 0.0; } _timer!.update(dt); } bool isOnGround() { return (this.y >= this.yMax); } var isRender = false; @override void onGameResize(Vector2 canvasSize) { super.onGameResize(canvasSize); if (isRender) { return; } this.height = this.width = canvasSize[0] / numberOfTilesAlongWidth; this.x = this.width; this.y = canvasSize[1] - groundHeight - (this.height / 2) + dinoTopBottomSpacing; this.yMax = this.y; isRender = true; } void run() { _isHit = false; this.animation = _runAnimation; } void hit() { if (!_isHit) { this.animation = _hitAnimation; life!.value -= 1; AudioManager.instance.playSfx('hurt7.wav'); _timer!.start(); _isHit = true; } } void getCoin() { AudioManager.instance.playSfx("coin.mp3"); coins!.value += 1; } void jump() { if (isOnGround()) { this.speedY = -500; AudioManager.instance.playSfx('jump14.wav'); } } }
0
mirrored_repositories/dino_run_flutter/lib
mirrored_repositories/dino_run_flutter/lib/game/state_manager.dart
import 'dart:math'; import 'package:flame/components.dart'; import 'coin.dart'; import 'enemy.dart'; import 'game.dart'; class StateManager extends Component with HasGameRef<MyGame> { Random? _random; Timer? _timer; int _spawnLevel = 0; StateManager() { _random = Random(); _timer = Timer(3, repeat: true, callback: () async { spawn(); }); _timer!.start(); } spawnRandomEnemy() { final randomNumber = _random!.nextInt(EnemyType.values.length); final randomEnemyType = EnemyType.values[randomNumber]; final newEnemy = new Enemy(randomEnemyType, gameRef.images); gameRef.add(newEnemy); } spawnCoin() { final coin = new Coin(gameRef.images); gameRef.add(coin); } spawn() { final randonSpawnCoin = _random!.nextInt(5); if (randonSpawnCoin == 4) { spawnCoin(); } else { spawnRandomEnemy(); } } @override void onMount() { super.onMount(); _timer!.start(); } @override void update(double dt) { _timer!.update(dt); var newSpawnLevel = (gameRef.score ~/ 500); if (_spawnLevel < newSpawnLevel) { _spawnLevel = newSpawnLevel; var newWaitTime = (3 / (1 + (0.1 * _spawnLevel))); _timer!.stop(); _timer = Timer(newWaitTime, repeat: true, callback: () async { spawn(); }); _timer!.start(); } } void reset() { _spawnLevel = 0; _timer = Timer(4, repeat: true, callback: () { spawn(); }); _timer!.start(); } }
0
mirrored_repositories/dino_run_flutter/lib
mirrored_repositories/dino_run_flutter/lib/game/constats.dart
const double groundHeight = 32; const double dinoTopBottomSpacing = 10; const double numberOfTilesAlongWidth = 10; const double GRAVITY = 1000; const dinoPng = 'dino.png'; const dinoBluePng = 'dinoBlue.png'; const dinoGreenPng = 'dinoGreen.png'; const dinoRedPng = 'dinoRed.png'; const dinoYellowPng = 'dinoYellow.png'; const angryPigGreenPng = 'AngryPig/Walk (36x30).png'; const angryPigRedPng = 'AngryPig/Run (36x30).png'; const batPng = 'Bat/Flying (46x30).png'; const rinoPng = 'Rino/Run (52x34).png'; const coinImages = [ "coin/Gold_1.png", "coin/Gold_2.png", "coin/Gold_3.png", "coin/Gold_4.png", "coin/Gold_5.png", "coin/Gold_6.png", "coin/Gold_7.png", "coin/Gold_8.png", "coin/Gold_9.png", "coin/Gold_10.png", ];
0
mirrored_repositories/dino_run_flutter/lib
mirrored_repositories/dino_run_flutter/lib/game/game.dart
import 'dart:ui'; import 'package:dino_run/game/audio_manager.dart'; import 'package:dino_run/game/state_manager.dart'; import 'package:dino_run/game/store_manager.dart'; import 'package:flame/components.dart'; import 'package:flame/game.dart'; import 'package:flame/gestures.dart'; import 'package:flame/parallax.dart'; import 'package:flutter/material.dart'; import 'audio_manager.dart'; import 'coin.dart'; import 'constats.dart'; import 'dino.dart'; import 'enemy.dart'; const double groundHeight = 32; const double dinoTopBottomSpacing = 10; const double numberOfTilesAlongWidth = 10; class MyGame extends BaseGame with TapDetector { Dino? dino; StateManager? stateManager; TextComponent? _scoreText; double score = 0; double _elapsedTime = 0.0; bool _isGameOver = false; bool _isGamePaused = false; @override Future<void> onLoad() async { await images.load(dinoBluePng); await images.load(dinoRedPng); await images.load(dinoGreenPng); await images.load(dinoYellowPng); await images.load(angryPigGreenPng); await images.load(angryPigRedPng); await images.load(batPng); await images.load(rinoPng); await Future.forEach( coinImages, (String coinImage) async => await images.load(coinImage)); final parallaxImages = [ loadParallaxImage('parallax/plx-1.png'), loadParallaxImage('parallax/plx-2.png'), loadParallaxImage('parallax/plx-3.png'), loadParallaxImage('parallax/plx-4.png'), loadParallaxImage('parallax/plx-5.png'), loadParallaxImage('parallax/plx-6.png', fill: LayerFill.none), ]; final layers = parallaxImages.map((image) async => ParallaxLayer( await image, velocityMultiplier: Vector2( parallaxImages.indexOf(image) == 5 ? 3.33 : parallaxImages.indexOf(image) * 1, 0))); final parallaxComponent = ParallaxComponent.fromParallax( Parallax( await Future.wait(layers), baseVelocity: Vector2(60, 0), ), ); add(parallaxComponent); dino = new Dino(StoreManager.instance.selectedDino, images); add(dino!); stateManager = new StateManager(); add(stateManager!); overlays.add("HudGame"); _scoreText = TextComponent(score.toInt().toString(), textRenderer: TextPaint( config: TextPaintConfig( fontFamily: 'Audiowide-Regular', color: Colors.white, ))); add(_scoreText!); AudioManager.instance.startBgm(); } @override void onResize(Vector2 canvasSize) { super.onResize(canvasSize); _scoreText?.x = (canvasSize[0] / 2) - (_scoreText!.width / 2); _scoreText?.y = canvasSize[1] - (canvasSize[1] + _scoreText!.height - 50); } @override void lifecycleStateChange(AppLifecycleState state) { switch (state) { case AppLifecycleState.resumed: break; case AppLifecycleState.inactive: pauseGame(); break; case AppLifecycleState.paused: pauseGame(); break; case AppLifecycleState.detached: pauseGame(); break; } } void pauseGame() { if (!_isGameOver) { AudioManager.instance.pauseBgm(); this.pauseEngine(); this._isGamePaused = true; this.overlays.add("PauseMenu"); } } @override void onTapDown(TapDownInfo event) { super.onTapDown(event); if (!_isGameOver && !_isGamePaused) { dino!.jump(); } } @override void update(double dt) { super.update(dt); _elapsedTime += dt; if (_elapsedTime > (1 / 60)) { score += 1; _scoreText!.text = score.toInt().toString(); } //enemy colission components.whereType<Enemy>().forEach((enemy) { if (dino!.distance(enemy) < 35) { dino!.hit(); } }); //get coin components.whereType<Coin>().forEach((coin) { if (dino!.distance(coin) < 25) { dino!.getCoin(); remove(coin); } }); if (dino!.life!.value <= 0) { gameOver(); } } void gameOver() { StoreManager.instance.setHighScore(score.toInt()); _isGameOver = true; StoreManager.instance.addCoins(dino!.coins!.value); AudioManager.instance.stopBgm(); this.pauseEngine(); this.overlays.add('GameOverMenu'); } void resetGame() { score = 0; dino!.run(); dino!.coins!.value = 0; dino!.life!.value = StoreManager.instance.totalLifes!; stateManager!.reset(); overlays.remove("GameOverMenu"); resumeEngine(); _isGameOver = false; AudioManager.instance.resumeBgm(); components.whereType<Enemy>().forEach((enemy) => {remove(enemy)}); } void resumeGame() { _isGamePaused = false; AudioManager.instance.resumeBgm(); resumeEngine(); overlays.remove("PauseMenu"); } @override void onDetach() { AudioManager.instance.stopBgm(); super.onDetach(); } }
0
mirrored_repositories/dino_run_flutter/lib
mirrored_repositories/dino_run_flutter/lib/game/coin.dart
import 'dart:math'; import 'package:flame/assets.dart'; import 'package:flame/components.dart'; import 'package:flame/sprite.dart'; import 'constats.dart'; class Coin extends SpriteAnimationComponent { SpriteAnimation? _coinAnimation; static Random _random = Random(); var isRender = false; final _speed = 250; Coin(Images images) { final coinSprites = coinImages .map((coinImage) => new Sprite(images.fromCache(coinImage))) .toList(); _coinAnimation = SpriteAnimation.spriteList(coinSprites, stepTime: 0.1); this.animation = _coinAnimation; this.anchor = Anchor.center; } @override void update(double dt) { super.update(dt); this.x -= _speed * dt; } @override void onGameResize(Vector2 canvasSize) { super.onGameResize(canvasSize); if (isRender) { return; } this.width = 30; this.height = 30; this.x = canvasSize[0] + this.width; this.y = canvasSize[1] - groundHeight - (this.height / 2); if (_random.nextBool()) { this.y -= groundHeight + _random.nextInt((this.height * 3).toInt()); } isRender = true; } }
0
mirrored_repositories/dino_run_flutter/lib
mirrored_repositories/dino_run_flutter/lib/game/audio_manager.dart
import 'package:flame_audio/flame_audio.dart'; import 'package:flutter/widgets.dart'; import 'package:hive/hive.dart'; class AudioManager { AudioManager._internal(); static AudioManager _instance = AudioManager._internal(); static AudioManager get instance => _instance; Future<void> init() async { FlameAudio.bgm.initialize(); // FlameAudio.bgm.play('bgloop.wav', volume: 0.50); settings = await Hive.openBox("settings"); if (settings!.get('bgm') == null) { settings!.put('bgm', true); } if (settings!.get('sfx') == null) { settings!.put('sfx', true); } _sfx = ValueNotifier(settings!.get('sfx')); _bgm = ValueNotifier(settings!.get('bgm')); } Box? settings; ValueNotifier<bool>? _sfx; ValueNotifier<bool>? _bgm; ValueNotifier<bool>? get listenableSfx => _sfx; ValueNotifier<bool>? get listenableBgm => _bgm; void setSfx(bool flag) { settings!.put('sfx', flag); _sfx!.value = flag; } void setBgm(bool flag) { settings!.put('bgm', flag); _bgm!.value = flag; } void startBgm() { if (_bgm!.value) { FlameAudio.bgm.play('bgloop.wav', volume: 0.4); } } // Pauses currently playing BGM if any. void pauseBgm() { if (_bgm!.value) { FlameAudio.bgm.pause(); } } // Resumes currently paused BGM if any. void resumeBgm() { if (_bgm!.value) { FlameAudio.bgm.resume(); } } // Stops currently playing BGM if any. void stopBgm() { if (_bgm!.value) { FlameAudio.bgm.stop(); } } // Plays the given audio file once. void playSfx(String fileName) { if (_sfx!.value) { FlameAudio.audioCache.play(fileName, volume: 1); } } }
0
mirrored_repositories/dino_run_flutter/lib
mirrored_repositories/dino_run_flutter/lib/game/enemy.dart
import 'dart:math'; import 'package:flame/assets.dart'; import 'package:flame/components.dart'; import 'package:flame/extensions.dart'; import 'package:flame/sprite.dart'; import 'constats.dart'; enum EnemyType { AngryPigGreen, AngryPigRed, Bat, Rino } class EnemyData { final String image; final int columns; final int rows; final int textureHeight; final int textureWidth; final int speed; final bool canFly; EnemyData({ required this.image, required this.columns, required this.rows, required this.textureHeight, required this.textureWidth, this.speed = 250, this.canFly = false, }); } class Enemy extends SpriteAnimationComponent { EnemyData? _myData; static Random _random = Random(); static Map<EnemyType, EnemyData> _enemyDetails = { EnemyType.AngryPigGreen: EnemyData( columns: 16, rows: 1, image: angryPigGreenPng, textureHeight: 30, textureWidth: 36, ), EnemyType.AngryPigRed: EnemyData( columns: 12, rows: 1, image: angryPigRedPng, textureHeight: 30, textureWidth: 36, ), EnemyType.Bat: EnemyData( columns: 7, rows: 1, image: batPng, textureHeight: 30, textureWidth: 46, speed: 300, canFly: true), EnemyType.Rino: EnemyData( columns: 6, rows: 1, image: rinoPng, textureHeight: 34, textureWidth: 52, speed: 350), }; Enemy(EnemyType type, Images images) { _myData = _enemyDetails[type]; final spriteSheet = new SpriteSheet.fromColumnsAndRows( image: images.fromCache(_myData!.image), columns: _myData!.columns, rows: _myData!.rows, ); this.animation = spriteSheet.createAnimation( row: 0, from: 0, to: (_myData!.columns - 1), stepTime: 0.1); this.anchor = Anchor.center; } @override void update(double dt) { super.update(dt); this.x -= _myData!.speed * dt; } var isRender = false; @override void onGameResize(Vector2 canvasSize) { super.onGameResize(canvasSize); if (isRender) { return; } double scaledFactor = (canvasSize[0] / numberOfTilesAlongWidth) / _myData!.textureWidth; this.height = _myData!.textureHeight * scaledFactor; this.width = _myData!.textureWidth * scaledFactor; this.x = canvasSize[0] + this.width; this.y = canvasSize[1] - groundHeight - (this.height / 2); if (_myData!.canFly && _random.nextBool()) { this.y -= _random.nextInt((this.height * 2).toInt()); } isRender = true; } }
0
mirrored_repositories/dino_run_flutter/lib
mirrored_repositories/dino_run_flutter/lib/ads/ad_state.dart
import 'dart:io'; import 'package:flutter/foundation.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart'; class AdState { AdState._internal(); static AdState _instance = AdState._internal(); static AdState get instance => _instance; Future<void> init() async { initializations = MobileAds.instance.initialize(); } Future<InitializationStatus>? initializations; String get bannerAdUntil { if (!kReleaseMode) { return BannerAd.testAdUnitId; } if (kIsWeb) { return ""; } if (Platform.isAndroid) { return dotenv.env['BannerAndroid'].toString(); } return ""; } BannerAdListener get adListener => _adListener; BannerAdListener _adListener = BannerAdListener( onAdLoaded: (Ad ad) => print('Ad loaded'), onAdFailedToLoad: (Ad ad, LoadAdError error) { ad.dispose(); print('Ad failed to load $error'); }, onAdOpened: (Ad ad) => print('Ad opened'), onAdClosed: (Ad ad) => print('Ad closed'), ); }
0
mirrored_repositories/dino_run_flutter/lib
mirrored_repositories/dino_run_flutter/lib/screens/main_menu.dart
import 'package:dino_run/widgets/credits.dart'; import 'package:dino_run/widgets/menu.dart'; import 'package:dino_run/widgets/settings.dart'; import 'package:dino_run/widgets/store.dart'; import 'package:flutter/material.dart'; class MainMenu extends StatefulWidget { const MainMenu({Key? key}) : super(key: key); @override _MainMenuState createState() => _MainMenuState(); } class _MainMenuState extends State<MainMenu> { String _menuOpt = 'Menu'; @override void initState() { super.initState(); } @override Widget build(BuildContext context) { return Scaffold( body: Container( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height, decoration: BoxDecoration( image: DecorationImage( image: AssetImage('assets/images/background.png'), fit: BoxFit.cover, ), ), child: AnimatedSwitcher( duration: const Duration(milliseconds: 500), child: Card( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20.0), ), color: Colors.black.withOpacity(0.4), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 90.0, vertical: 30.0), child: showOptions(), ), key: new ValueKey<String>(_menuOpt), ), ), ), ); } showOptions() { if (_menuOpt == 'Menu') { return Menu( onSettingsPressed: showSettings, onStorePressed: showStore, onCreditsPressed: showCredits, ); } if (_menuOpt == 'Settings') { return Settings( onBackPressed: showMenu, ); } if (_menuOpt == 'Store') { return Store( onBackPressed: showMenu, ); } if (_menuOpt == 'Credits') { return Credits( onBackPressed: showMenu, ); } } void showMenu() { setState(() { _menuOpt = 'Menu'; }); } void showSettings() { setState(() { _menuOpt = 'Settings'; }); } void showStore() { setState(() { _menuOpt = 'Store'; }); } void showCredits() { setState(() { _menuOpt = 'Credits'; }); } }
0
mirrored_repositories/dino_run_flutter/lib
mirrored_repositories/dino_run_flutter/lib/screens/game_play.dart
import 'package:dino_run/game/game.dart'; import 'package:dino_run/widgets/gameover_menu.dart'; import 'package:dino_run/widgets/hud_game.dart'; import 'package:dino_run/widgets/pause_menu.dart'; import 'package:flame/game.dart'; import 'package:flutter/material.dart'; /// This class is responsible for creating an instance of [DinoGame] /// and returning its widget. class GamePlay extends StatelessWidget { final MyGame myGame = MyGame(); GamePlay({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( body: GameWidget<MyGame>( game: myGame, overlayBuilderMap: { 'HudGame': (ctx, game) { return HudGame(game: game); }, 'PauseMenu': (ctx, game) { return PauseMenu(game: game); }, 'GameOverMenu': (ctx, game) { return GameOverMenu(game: game); } }, ), ); } }
0
mirrored_repositories
mirrored_repositories/flutterstudyjam_gdg/whatsapp_home.dart
import 'package:flutter/material.dart'; import 'package:flutter_whatsapp/pages/call_screen.dart'; import 'package:flutter_whatsapp/pages/camera_screen.dart'; import 'package:flutter_whatsapp/pages/chat_screen.dart'; import 'package:flutter_whatsapp/pages/status_screen.dart'; class WhatsAppHome extends StatefulWidget { @override _WhatsAppHomeState createState() => new _WhatsAppHomeState(); } class _WhatsAppHomeState extends State<WhatsAppHome> with SingleTickerProviderStateMixin { TabController _tabController; @override void initState() { // TODO: implement initState super.initState(); _tabController = new TabController(vsync: this, initialIndex: 1, length: 4); } @override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar( title: new Text("WhatsApp"), elevation: 0.7, bottom: new TabBar( controller: _tabController, indicatorColor: Colors.white, tabs: <Widget>[ new Tab(icon: new Icon(Icons.camera_alt)), new Tab( text: "CHATS", ), new Tab( text: "STATUS", ), new Tab( text: "CHATS", ) ], ), actions: <Widget>[ new Icon(Icons.search), new Padding( padding: const EdgeInsets.symmetric(horizontal: 5.0), ), new Icon(Icons.more_vert) ], ), body: new TabBarView( controller: _tabController, children: <Widget>[ new CameraScreen(), new ChatScreen(), new StatusScreen(), new CallScreen(), ], ), floatingActionButton: new FloatingActionButton( backgroundColor: Theme.of(context).accentColor, child: new Icon( Icons.message, color: Colors.white, ), onPressed: () => print("open chats"), ), ); } }
0
mirrored_repositories
mirrored_repositories/flutterstudyjam_gdg/main.dart
import 'package:flutter/material.dart'; import 'package:flutter_whatsapp/whatsapp_home.dart'; void main()=>runApp(new MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return new MaterialApp( title: "WhatsApp", theme: new ThemeData( primarySwatch: Colors.teal, accentColor: new Color(0xff25D366), brightness: Brightness.dark, ), debugShowCheckedModeBanner: false, home: new WhatsAppHome(), ); } }
0
mirrored_repositories/flutterstudyjam_gdg
mirrored_repositories/flutterstudyjam_gdg/Avinash Kumar- avinash.mallik62@gmail.com/main.dart
import 'package:flutter/material.dart'; import 'package:audioplayers/audio_cache.dart'; void main() { runApp(XylophoneApp()); } class XylophoneApp extends StatelessWidget { void playSound(int soundNumber) { final player = AudioCache(); player.play('note$soundNumber.wav'); } Expanded buildKey({Color color, int soundNumber}) { return Expanded( child: FlatButton( color: color, onPressed: () { playSound(soundNumber); }), ); } @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: Scaffold( appBar: AppBar( title: Text('XyloPhone'), backgroundColor: Colors.black, centerTitle: true, ), backgroundColor: Colors.black, body: SafeArea( child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ buildKey(color: Colors.red, soundNumber: 1), buildKey(color: Colors.orange, soundNumber: 2), buildKey(color: Colors.yellow, soundNumber: 3), buildKey(color: Colors.green, soundNumber: 4), buildKey(color: Colors.blue, soundNumber: 5), buildKey(color: Colors.indigo, soundNumber: 6), buildKey(color: Colors.purple, soundNumber: 7), ], ), ), ), ); } }
0
mirrored_repositories/flutterstudyjam_gdg
mirrored_repositories/flutterstudyjam_gdg/Ankit Dutta-dutta78963@gmail.com/main.dart
import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State<MyApp> { Color favColor = Colors.black; @override Widget build(BuildContext context) { return MaterialApp( title: 'Welcome to Flutter', home: Scaffold( appBar: AppBar( title: Text('Instagram', style: TextStyle(color: Colors.black),), leading: Icon(Icons.camera_alt, color: Colors.black,), backgroundColor: Colors.white, actions: <Widget>[ Icon(Icons.tv, color: Colors.black,), SizedBox(width: 8), Icon(Icons.send, color: Colors.black,), ] ), body: ListView.builder( physics: BouncingScrollPhysics(), itemBuilder: (BuildContext context, int index) { return buildInstagramTile(); }, itemCount: 10, ), ), ); } Widget buildInstagramTile() { return Column( children: <Widget>[ ListTile( leading: Image.network( 'https://cdn.shopify.com/s/files/1/1698/6547/files/starcatalog_600x600.jpg?v=1511346010', ), title: Text('Stars'), trailing: Icon(Icons.more_horiz), ), Image.network( 'https://www.abc.net.au/news/image/9744422-1x1-940x940.jpg', height: 200, fit: BoxFit.fill, ), Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Row( children: <Widget>[ IconButton( icon: Icon( Icons.favorite, color: favColor, ), onPressed: () { setState(() { favColor = Colors.red; }); favColor = Colors.red; }, ), SizedBox(width: 8), Icon(Icons.mode_comment), SizedBox(width: 8), Icon(Icons.share), ], ), Icon(Icons.bookmark_border), ], ) ], ); } }
0
mirrored_repositories/flutterstudyjam_gdg
mirrored_repositories/flutterstudyjam_gdg/Prateek Tewary- prats2241@gmail.com/main.dart
import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State<MyApp> { Color favColor = Colors.black; @override Widget build(BuildContext context) { return MaterialApp( title: 'Welcome to Flutter', home: Scaffold( appBar: AppBar( title: Text('Instagram',style: TextStyle(color: Colors.black),), leading: Icon(Icons.camera_alt, color: Colors.black,), //leading means before the insta heading backgroundColor: Colors.white, actions: <Widget>[ Icon(Icons.tv, color: Colors.black,), Icon(Icons.send, color: Colors.black,), //to take multiple widgets ], ), body: ListView.builder( physics: BouncingScrollPhysics(), itemBuilder: (BuildContext context, int index){ return buildInstagramTile(); }, itemCount: 1, ), // ... this line. ), ); } Widget buildInstagramTile(){ return Column( children: <Widget>[ ListTile( leading: Image.network ( 'https://images.unsplash.com/photo-1549221987-25a490f65d34?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1050&q=80', ), title: Text('PrateekT'), trailing: Icon(Icons.more_horiz), ), Image.network( 'https://images.unsplash.com/photo-1552933529-e359b2477252?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1050&q=80', height: 200, width: double.maxFinite, fit: BoxFit.cover, ), Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Row( children: <Widget>[ IconButton( icon: Icon( Icons.favorite, color: favColor, ), onPressed: (){ setState(() { favColor = Colors.red; }); }, ), SizedBox(width: 8), Icon(Icons.mode_comment), SizedBox(width: 8), Icon(Icons.share), ] ) ], )//By default already in flutter to get a row like the one above a insta post ], ); } Widget buildInstagramTile1(){ return Column( children: <Widget>[ ListTile( leading: Image.network ( 'https://images.unsplash.com/photo-1573314865460-10ef19098125?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1050&q=80', ), title: Text('RishavS'), trailing: Icon(Icons.more_horiz), ), Image.network( 'https://images.unsplash.com/photo-1573331519198-12325f010ae2?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1050&q=80', height: 200, width: double.maxFinite, fit: BoxFit.cover, ), Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Row( children: <Widget>[ IconButton( icon: Icon( Icons.favorite, color: favColor, ), onPressed: (){ setState(() { favColor = Colors.red; }); }, ), SizedBox(width: 8), Icon(Icons.mode_comment), SizedBox(width: 8), Icon(Icons.share), ] ) ], )//By default already in flutter to get a row like the one above a insta post ], ); } }
0
mirrored_repositories/flutterstudyjam_gdg
mirrored_repositories/flutterstudyjam_gdg/HARSHIT- harrymishra831@gmail.com/main.dart
import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State<MyApp> { Color favColor = Colors.black; @override Widget build(BuildContext context) { return MaterialApp( title: 'Welcome to Flutter', home: Scaffold( appBar: AppBar( title: Text('Instagram', style: TextStyle(color: Colors.black),), leading: Icon(Icons.camera_alt), backgroundColor: Colors.white, actions: <Widget>[ Icon(Icons.send, color: Colors.black,), Icon(Icons.tv, color: Colors.black,), ] ), body: ListView.builder( physics:BouncingScrollPhysics() , itemBuilder: (BuildContext context,int index){ return buildInstagramTile(); }, itemCount: 50, ), // ... this line. )); } Widget buildInstagramTile() { return Column( children: <Widget>[ ListTile( leading: Image.network( 'https://vignette.wikia.nocookie.net/marvelcinematicuniverse/images/3/35/IronMan-EndgameProfile.jpg/revision/latest/scale-to-width-down/2000?cb=20190423175213', ), title: Text('IRON MAN'), trailing: Icon(Icons.more_horiz), ), Image.network( 'https://www.impericon.com/360x520x85/media/catalog/product/a/b/abyacc243_lg.jpg', height: 500, width: double.infinity, fit: BoxFit.cover, ), Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Row( children: <Widget>[ IconButton( icon: Icon(Icons.favorite, color: favColor, ), onPressed: () { setState(() { favColor = Colors.red; }); }, ), SizedBox(width: 15), Icon(Icons.mode_comment), SizedBox(width:15), Icon(Icons.share), ], ), Icon(Icons.bookmark_border), ], ) ] ); } }
0
mirrored_repositories/flutterstudyjam_gdg
mirrored_repositories/flutterstudyjam_gdg/pages/status_screen.dart
import 'package:flutter/material.dart'; class StatusScreen extends StatelessWidget { @override Widget build(BuildContext context) { return new Center( child: new Text( "Status", style: new TextStyle(fontSize: 20.0), ), ); } }
0
mirrored_repositories/flutterstudyjam_gdg
mirrored_repositories/flutterstudyjam_gdg/pages/chat_screen.dart
import 'package:flutter/material.dart'; import 'package:flutter_whatsapp/models/chat_model.dart'; class ChatScreen extends StatefulWidget { @override _ChatScreenState createState() => _ChatScreenState(); } class _ChatScreenState extends State<ChatScreen> { @override Widget build(BuildContext context) { return new ListView.builder( itemCount: dummyData.length, itemBuilder: (context, i) => new Column( children: <Widget>[ new Divider( height: 10.0, ), new ListTile( leading: new CircleAvatar( foregroundColor: Theme.of(context).primaryColor, backgroundColor: Colors.grey, backgroundImage: NetworkImage(dummyData[i].avatarUrl), ), title: new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ new Text( dummyData[i].name, style: new TextStyle( fontWeight: FontWeight.bold, ), ), new Text( dummyData[i].time, style: new TextStyle( color: Colors.grey, fontSize: 14.0, ), ), ], ), subtitle: new Container( padding: const EdgeInsets.only(top: 5.0), child: new Text( dummyData[i].message, style: new TextStyle( color: Colors.grey, fontSize: 15.0, ), ), ), ), ], ), ); } }
0
mirrored_repositories/flutterstudyjam_gdg
mirrored_repositories/flutterstudyjam_gdg/pages/call_screen.dart
import 'package:flutter/material.dart'; class CallScreen extends StatelessWidget { @override Widget build(BuildContext context) { return new Center( child: new Text( "Calls", style: new TextStyle(fontSize: 20.0), ), ); } }
0
mirrored_repositories/flutterstudyjam_gdg
mirrored_repositories/flutterstudyjam_gdg/pages/camera_screen.dart
import 'package:flutter/material.dart'; class CameraScreen extends StatelessWidget { @override Widget build(BuildContext context) { return new Center( child: new Text( "Camera", style: new TextStyle(fontSize: 20.0), ), ); } }
0
mirrored_repositories/flutterstudyjam_gdg
mirrored_repositories/flutterstudyjam_gdg/models/chat_model.dart
import 'package:flutter/material.dart'; class ChatModel { final String name; final String message; final String time; final String avatarUrl; ChatModel({this.name, this.message, this.time, this.avatarUrl}); } List<ChatModel>dummyData = [ new ChatModel( name:"Avinash Kumar", message:"Hey Flutter,I love working with you!", time:"13:30", avatarUrl: "https://images.pexels.com/photos/220453/pexels-photo-220453.jpeg?auto=compress&cs=tinysrgb&h=650&w=940", ), new ChatModel( name:"Abhishek Sahai", message:"Hey! I have a doubt.Can I Call?", time:"12:30", avatarUrl: "https://images.pexels.com/photos/736716/pexels-photo-736716.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940", ), new ChatModel( name:"Mark Zuckerberg", message:"I am thinking of some more features for Facebook!", time:"17:30", avatarUrl: "https://timedotcom.files.wordpress.com/2019/04/mark-zuckerberg-time-100-2019.jpg?quality=85&zoom=2", ), new ChatModel( name:"Team Cook", message:"Hey I will surely gift u a Iphone-XR", time:"18:30", avatarUrl: "https://images.pexels.com/photos/36483/aroni-arsa-children-little.jpg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940", ), new ChatModel( name:"Jeff Bezos", message:"I am feeling very low!", time:"19:30", avatarUrl: "https://images.pexels.com/photos/288477/pexels-photo-288477.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940", ), new ChatModel( name:"Paytm", message:"Alert: Wallet Transaction!!", time:"13:30", avatarUrl: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTytAfemPYpIWXQMlIWjKPb1bC6gacWDOagAa8hsTmbWCXkwALv&s", ), ];
0
mirrored_repositories/flutterstudyjam_gdg
mirrored_repositories/flutterstudyjam_gdg/Avinash Kumar-Flutter_whatsapp ---avinash.mallik62@gmail.com/whatsapp_home.dart
import 'package:flutter/material.dart'; import 'package:flutter_whatsapp/pages/call_screen.dart'; import 'package:flutter_whatsapp/pages/camera_screen.dart'; import 'package:flutter_whatsapp/pages/chat_screen.dart'; import 'package:flutter_whatsapp/pages/status_screen.dart'; class WhatsAppHome extends StatefulWidget { @override _WhatsAppHomeState createState() => new _WhatsAppHomeState(); } class _WhatsAppHomeState extends State<WhatsAppHome> with SingleTickerProviderStateMixin { TabController _tabController; @override void initState() { // TODO: implement initState super.initState(); _tabController = new TabController(vsync: this, initialIndex: 1, length: 4); } @override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar( title: new Text("WhatsApp"), elevation: 0.7, bottom: new TabBar( controller: _tabController, indicatorColor: Colors.white, tabs: <Widget>[ new Tab(icon: new Icon(Icons.camera_alt)), new Tab( text: "CHATS", ), new Tab( text: "STATUS", ), new Tab( text: "CHATS", ) ], ), actions: <Widget>[ new Icon(Icons.search), new Padding( padding: const EdgeInsets.symmetric(horizontal: 5.0), ), new Icon(Icons.more_vert) ], ), body: new TabBarView( controller: _tabController, children: <Widget>[ new CameraScreen(), new ChatScreen(), new StatusScreen(), new CallScreen(), ], ), floatingActionButton: new FloatingActionButton( backgroundColor: Theme.of(context).accentColor, child: new Icon( Icons.message, color: Colors.white, ), onPressed: () => print("open chats"), ), ); } }
0
mirrored_repositories/flutterstudyjam_gdg
mirrored_repositories/flutterstudyjam_gdg/Avinash Kumar-Flutter_whatsapp ---avinash.mallik62@gmail.com/main.dart
import 'package:flutter/material.dart'; import 'package:flutter_whatsapp/whatsapp_home.dart'; void main()=>runApp(new MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return new MaterialApp( title: "WhatsApp", theme: new ThemeData( primarySwatch: Colors.teal, accentColor: new Color(0xff25D366), brightness: Brightness.dark, ), debugShowCheckedModeBanner: false, home: new WhatsAppHome(), ); } }
0
mirrored_repositories/flutterstudyjam_gdg/Avinash Kumar-Flutter_whatsapp ---avinash.mallik62@gmail.com
mirrored_repositories/flutterstudyjam_gdg/Avinash Kumar-Flutter_whatsapp ---avinash.mallik62@gmail.com/pages/status_screen.dart
import 'package:flutter/material.dart'; class StatusScreen extends StatelessWidget { @override Widget build(BuildContext context) { return new Center( child: new Text( "Status", style: new TextStyle(fontSize: 20.0), ), ); } }
0
mirrored_repositories/flutterstudyjam_gdg/Avinash Kumar-Flutter_whatsapp ---avinash.mallik62@gmail.com
mirrored_repositories/flutterstudyjam_gdg/Avinash Kumar-Flutter_whatsapp ---avinash.mallik62@gmail.com/pages/chat_screen.dart
import 'package:flutter/material.dart'; import 'package:flutter_whatsapp/models/chat_model.dart'; class ChatScreen extends StatefulWidget { @override _ChatScreenState createState() => _ChatScreenState(); } class _ChatScreenState extends State<ChatScreen> { @override Widget build(BuildContext context) { return new ListView.builder( itemCount: dummyData.length, itemBuilder: (context, i) => new Column( children: <Widget>[ new Divider( height: 10.0, ), new ListTile( leading: new CircleAvatar( foregroundColor: Theme.of(context).primaryColor, backgroundColor: Colors.grey, backgroundImage: NetworkImage(dummyData[i].avatarUrl), ), title: new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ new Text( dummyData[i].name, style: new TextStyle( fontWeight: FontWeight.bold, ), ), new Text( dummyData[i].time, style: new TextStyle( color: Colors.grey, fontSize: 14.0, ), ), ], ), subtitle: new Container( padding: const EdgeInsets.only(top: 5.0), child: new Text( dummyData[i].message, style: new TextStyle( color: Colors.grey, fontSize: 15.0, ), ), ), ), ], ), ); } }
0
mirrored_repositories/flutterstudyjam_gdg/Avinash Kumar-Flutter_whatsapp ---avinash.mallik62@gmail.com
mirrored_repositories/flutterstudyjam_gdg/Avinash Kumar-Flutter_whatsapp ---avinash.mallik62@gmail.com/pages/call_screen.dart
import 'package:flutter/material.dart'; class CallScreen extends StatelessWidget { @override Widget build(BuildContext context) { return new Center( child: new Text( "Calls", style: new TextStyle(fontSize: 20.0), ), ); } }
0
mirrored_repositories/flutterstudyjam_gdg/Avinash Kumar-Flutter_whatsapp ---avinash.mallik62@gmail.com
mirrored_repositories/flutterstudyjam_gdg/Avinash Kumar-Flutter_whatsapp ---avinash.mallik62@gmail.com/pages/camera_screen.dart
import 'package:flutter/material.dart'; class CameraScreen extends StatelessWidget { @override Widget build(BuildContext context) { return new Center( child: new Text( "Camera", style: new TextStyle(fontSize: 20.0), ), ); } }
0
mirrored_repositories/flutterstudyjam_gdg/Avinash Kumar-Flutter_whatsapp ---avinash.mallik62@gmail.com
mirrored_repositories/flutterstudyjam_gdg/Avinash Kumar-Flutter_whatsapp ---avinash.mallik62@gmail.com/models/chat_model.dart
import 'package:flutter/material.dart'; class ChatModel { final String name; final String message; final String time; final String avatarUrl; ChatModel({this.name, this.message, this.time, this.avatarUrl}); } List<ChatModel>dummyData = [ new ChatModel( name:"Avinash Kumar", message:"Hey Flutter,I love working with you!", time:"13:30", avatarUrl: "https://images.pexels.com/photos/220453/pexels-photo-220453.jpeg?auto=compress&cs=tinysrgb&h=650&w=940", ), new ChatModel( name:"Abhishek Sahai", message:"Hey! I have a doubt.Can I Call?", time:"12:30", avatarUrl: "https://images.pexels.com/photos/736716/pexels-photo-736716.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940", ), new ChatModel( name:"Mark Zuckerberg", message:"I am thinking of some more features for Facebook!", time:"17:30", avatarUrl: "https://timedotcom.files.wordpress.com/2019/04/mark-zuckerberg-time-100-2019.jpg?quality=85&zoom=2", ), new ChatModel( name:"Team Cook", message:"Hey I will surely gift u a Iphone-XR", time:"18:30", avatarUrl: "https://images.pexels.com/photos/36483/aroni-arsa-children-little.jpg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940", ), new ChatModel( name:"Jeff Bezos", message:"I am feeling very low!", time:"19:30", avatarUrl: "https://images.pexels.com/photos/288477/pexels-photo-288477.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940", ), new ChatModel( name:"Paytm", message:"Alert: Wallet Transaction!!", time:"13:30", avatarUrl: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTytAfemPYpIWXQMlIWjKPb1bC6gacWDOagAa8hsTmbWCXkwALv&s", ), ];
0
mirrored_repositories/flutterstudyjam_gdg
mirrored_repositories/flutterstudyjam_gdg/aniket_ani.oneseven@gmail.com/main.dart
import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State<MyApp> { Color favColor = Colors.black; int i = 0; @override Widget build(BuildContext context) { return MaterialApp( title: 'Welcome to Flutter', home: Scaffold( appBar: AppBar( title: Text('Instagram', style: TextStyle(color: Colors.black),), leading: Icon(Icons.camera_alt, color: Colors.black,), backgroundColor: Colors.white, actions: <Widget>[ Icon(Icons.tv, color: Colors.black,), Icon(Icons.send, color: Colors.black,), ], ), body: ListView.builder( physics: BouncingScrollPhysics(), itemBuilder: (BuildContext context, int index) { return buildInstagramTitle(); }, itemCount: 10, ), ) ); } buildInstagramTitle() { return Column( children: <Widget>[ ListTile( leading: Image.network( 'https://secure.meetupstatic.com/photos/event/4/a/b/5/600_466219125.jpeg' ), title: Text('Flutter'), trailing: Icon(Icons.more_horiz), ), Image.network( 'https://miro.medium.com/max/3200/1*73IgUxPfyXUKZAaIXgutrw.png', height: 200, width: double.infinity, fit: BoxFit.cover, ), Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Row(children: <Widget>[ SizedBox(width: 10), IconButton( icon: Icon(Icons.favorite), color: favColor, onPressed: () { if(i==0) { setState(() { favColor = Colors.red; i = 1; }); } else if(i==1) { setState(() { favColor = Colors.black; i = 0; }); } }, ), SizedBox(width: 10), Icon(Icons.mode_comment), SizedBox(width: 15), Icon(Icons.share), ],), Icon(Icons.bookmark_border) ], ) ], ); } }
0
mirrored_repositories/flutterstudyjam_gdg
mirrored_repositories/flutterstudyjam_gdg/SRINIDHI-keshrisrinidhi6@gmail.com/main.dart
import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State<MyApp> { Color favColor = Colors.black; @override Widget build(BuildContext context) { return MaterialApp( title: 'Welcome to Flutter', home: Scaffold( appBar: AppBar( title: Text('Instagram', style: TextStyle(color: Colors.black),), leading: Icon(Icons.camera_alt), backgroundColor: Colors.white, actions: <Widget>[ Icon(Icons.send, color: Colors.black,), Icon(Icons.tv, color: Colors.black,), ] ), body: ListView.builder( physics:BouncingScrollPhysics() , itemBuilder: (BuildContext context,int index){ return buildInstagramTile(); }, itemCount: 50, ), // ... this line. )); } Widget buildInstagramTile() { return Column( children: <Widget>[ ListTile( leading: Image.network( 'https://vignette.wikia.nocookie.net/marvelcinematicuniverse/images/3/35/IronMan-EndgameProfile.jpg/revision/latest/scale-to-width-down/2000?cb=20190423175213', ), title: Text('IRON MAN'), trailing: Icon(Icons.more_horiz), ), Image.network( 'https://www.impericon.com/360x520x85/media/catalog/product/a/b/abyacc243_lg.jpg', height: 500, width: double.infinity, fit: BoxFit.cover, ), Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Row( children: <Widget>[ IconButton( icon: Icon(Icons.favorite, color: favColor, ), onPressed: () { setState(() { favColor = Colors.red; }); }, ), SizedBox(width: 15), Icon(Icons.mode_comment), SizedBox(width:15), Icon(Icons.share), ], ), Icon(Icons.bookmark_border), ], ) ] ); } }
0
mirrored_repositories/flutterstudyjam_gdg
mirrored_repositories/flutterstudyjam_gdg/abhisheksahai-silentknight5245@gmail.com/startup_name_generator.dart
import 'package:flutter/material.dart'; import 'package:english_words/english_words.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Startup Name Generator', theme: ThemeData( // Add the 3 lines from here... primaryColor: Colors.indigo[700], ), home: RandomWords(), ); } } class RandomWordsState extends State<RandomWords> { final List<WordPair> _suggestions = <WordPair>[]; final Set<WordPair> _saved = Set<WordPair>(); final TextStyle _biggerFont = const TextStyle(fontSize: 18); @override Widget build(BuildContext context) { // TODO: implement build return Scaffold ( // Add from here... appBar: AppBar( title: Text('Startup Name Generator'), actions: <Widget>[ // Add 3 lines from here... IconButton(icon: Icon(Icons.list), onPressed: _pushSaved), ], ), body: _buildSuggestions(), ); } // TODO Add build method void _pushSaved() { Navigator.of(context).push( MaterialPageRoute<void>( builder: (BuildContext context) { final Iterable<ListTile> tiles = _saved.map( (WordPair pair) { return ListTile( title: Text( pair.asPascalCase, style: _biggerFont, ), ); }, ); final List<Widget> divided = ListTile .divideTiles( context: context, tiles: tiles, ) .toList(); return Scaffold( // Add 6 lines from here... appBar: AppBar( title: Text('Saved Suggestions'), ), body: ListView(children: divided), ); // ... to here. }, ), ); } Widget _buildSuggestions() { return ListView.builder( padding: const EdgeInsets.all(16), // The itemBuilder callback is called once per suggested // word pairing, and places each suggestion into a ListTile // row. For even rows, the function adds a ListTile row for // the word pairing. For odd rows, the function adds a // Divider widget to visually separate the entries. Note that // the divider may be difficult to see on smaller devices. itemBuilder: (BuildContext _context, int i) { // Add a one-pixel-high divider widget before each row // in the ListView. if (i.isOdd) { return Divider(); } // The syntax "i ~/ 2" divides i by 2 and returns an // integer result. // For example: 1, 2, 3, 4, 5 becomes 0, 1, 1, 2, 2. // This calculates the actual number of word pairings // in the ListView,minus the divider widgets. final int index = i ~/ 2; // If you've reached the end of the available word // pairings... if (index >= _suggestions.length) { // ...then generate 10 more and add them to the // suggestions list. _suggestions.addAll(generateWordPairs().take(10)); } return _buildRow(_suggestions[index]); } ); } Widget _buildRow(WordPair pair) { final bool alreadySaved = _saved.contains(pair); return ListTile( title: Text( pair.asPascalCase, style: _biggerFont, ), trailing: Icon( // Add the lines from here... alreadySaved ? Icons.favorite : Icons.favorite_border, color: alreadySaved ? Colors.lightBlue : null, ), onTap: () { setState(() { if (alreadySaved) { _saved.remove(pair); } else { _saved.add(pair); } }); }, ); } } class RandomWords extends StatefulWidget { @override RandomWordsState createState() => RandomWordsState(); }
0
mirrored_repositories/flutterstudyjam_gdg
mirrored_repositories/flutterstudyjam_gdg/abhisheksahai-silentknight5245@gmail.com/LoginPage(from scratch).dart
import 'dart:ui' as prefix0; import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData( primarySwatch: Colors.blue, brightness: Brightness.dark, ), home: loginpage(), ); } } class loginpage extends StatefulWidget { @override _loginpageState createState() => _loginpageState(); } class _loginpageState extends State<loginpage> with SingleTickerProviderStateMixin{ AnimationController _iconAnimationController; Animation<double> _iconAnimation; @override void initState(){ super.initState(); _iconAnimationController = new AnimationController( vsync: this, duration: Duration(milliseconds: 500) ); _iconAnimation = new CurvedAnimation(parent: _iconAnimationController, curve: Curves.easeOut); _iconAnimation.addListener(()=> this.setState((){})); _iconAnimationController.forward(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( centerTitle: true, title: Text("Login Page"), ), backgroundColor: Colors.black, body: Stack( fit: StackFit.expand, children: <Widget>[ Image( image: AssetImage("assets/girl.png"), fit: BoxFit.cover, color: Colors.black87, colorBlendMode: BlendMode.darken, ), Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ FlutterLogo( size: _iconAnimation.value * 100, ), Form( child: Theme( data: ThemeData( brightness: Brightness.dark, primarySwatch: Colors.teal, inputDecorationTheme: InputDecorationTheme( labelStyle: TextStyle( color: Colors.teal, fontSize: 20.0, ), ), ), child: Container( padding: const EdgeInsets.all(40.0), child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ TextFormField( decoration: InputDecoration( labelText: "Enter Email", ), keyboardType: TextInputType.emailAddress, ), TextFormField( decoration: InputDecoration( labelText: "Enter Password", ), keyboardType: TextInputType.text, obscureText: true, ), Padding( padding: const EdgeInsets.only(top: 20.0), ), MaterialButton( height: 40.0, minWidth: 100.0, color: Colors.teal, textColor: Colors.white, child: Text("Login"), onPressed: ()=>{}, splashColor: Colors.redAccent, ), ], ), ), ), ), ], ), ], ) ); } }
0
mirrored_repositories/flutterstudyjam_gdg
mirrored_repositories/flutterstudyjam_gdg/abhisheksahai-silentknight5245@gmail.com/main.dart
import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State<MyApp> { bool x = false; Color favColor = Colors.black; @override Widget build(BuildContext context) { return MaterialApp( title: 'Welcome to Flutter', home: Scaffold( appBar: AppBar( title: Text('Instagram', style: TextStyle(color: Colors.black)), leading: Icon(Icons.camera_alt, color: Colors.black), backgroundColor: Colors.white, actions: <Widget>[ Icon( Icons.tv, color: Colors.black, ), SizedBox( width: 10.0, ), Icon( Icons.send, color: Colors.black, ), ], ), body: ListView.builder( physics: BouncingScrollPhysics(), itemBuilder: (BuildContext context, int index) { return buildInstagramTile(); }, itemCount: 10, ), ), ); } Widget buildInstagramTile() { return Column( children: <Widget>[ ListTile( leading: Image.network( 'https://images.unsplash.com/photo-1503023345310-bd7c1de61c7d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&w=1000&q=80'), title: Text('Abhishek Sahai'), trailing: Icon(Icons.more_horiz), ), SizedBox( height: 10.0, ), Image.network( 'https://images.pexels.com/photos/67636/rose-blue-flower-rose-blooms-67636.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500', height: 200.0, width: double.infinity, fit: BoxFit.cover, ), Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Row( children: <Widget>[ IconButton( icon: Icon( Icons.favorite_border, color:favColor, ), onPressed: () { setState(() { if(x) { favColor = Colors.black; x = false; }else{ favColor = Colors.red; x = true; } }); }, ), SizedBox( width: 8, ), Icon(Icons.mode_comment), SizedBox( width: 8, ), Icon(Icons.share), ], ), Icon(Icons.bookmark_border), ], ), ], ); } }
0
mirrored_repositories/flutterstudyjam_gdg/abhisheksahai-silentknight5245@gmail.com/Dice_Shuffler
mirrored_repositories/flutterstudyjam_gdg/abhisheksahai-silentknight5245@gmail.com/Dice_Shuffler/lib/main.dart
import 'package:flutter/material.dart'; import 'dart:math'; void main() { return runApp( MaterialApp( debugShowCheckedModeBanner: false, home: Scaffold( backgroundColor: Colors.red, appBar: AppBar( centerTitle: true, title: Text('Dicee'), backgroundColor: Colors.red, ), body: DicePage(), ), ), ); } class DicePage extends StatefulWidget { @override _DicePageState createState() => _DicePageState(); } class _DicePageState extends State<DicePage> { int leftNumber = 1; int rightNumber = 1; void change() { setState(() { leftNumber = Random().nextInt(6) + 1; rightNumber = Random().nextInt(6) + 1; }); } @override Widget build(BuildContext context) { return Center( child: Row( children: <Widget>[ Expanded( child: FlatButton( onPressed: change, child: Image.asset('images/dice$leftNumber.png'), ), ), Expanded( child: FlatButton( onPressed: change, child: Image.asset('images/dice$rightNumber.png'), ), ), ], ), ); } }
0
mirrored_repositories/flutterstudyjam_gdg/abhisheksahai-silentknight5245@gmail.com/Profile_Card
mirrored_repositories/flutterstudyjam_gdg/abhisheksahai-silentknight5245@gmail.com/Profile_Card/lib/main.dart
import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'Profile Card', home: Scaffold( backgroundColor: Colors.teal, body: SafeArea( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ CircleAvatar( radius: 90.0, backgroundImage: AssetImage('assets/photo.jpeg'), ), Text( 'Abhishek Sahai', style: TextStyle( fontFamily: 'Pacifico', fontSize: 40.0, color: Colors.white, fontWeight: FontWeight.bold), ), Text( 'FLUTTER DEVELOPER', style: TextStyle( fontSize: 20.0, fontFamily: 'SourceSansPro', color: Colors.teal.shade100, letterSpacing: 2.5, fontWeight: FontWeight.bold, ), ), SizedBox( height: 20.0, width: 150.0, child: Divider( color: Colors.teal.shade900, ), ), Card( margin: EdgeInsets.symmetric(horizontal: 25.0, vertical: 10.0), child: ListTile( leading: Icon( Icons.phone, size: 40.0, color: Colors.teal.shade900, ), title: Text( '+91 6290764231', style: TextStyle( fontFamily: 'SourceSansPro', fontSize: 20.0, color: Colors.teal.shade900, ), ), ), ), Card( margin: EdgeInsets.symmetric(vertical: 10.0, horizontal: 25.0), child: ListTile( leading: Icon( Icons.mail, color: Colors.teal.shade900, size: 40.0, ), title: Text( 'silentknight5245@gmail.com', style: TextStyle( color: Colors.teal.shade900, fontFamily: 'SourceSansPro', fontSize: 18.0, ), ), ), ), ], ), ), ), ); } }
0
mirrored_repositories/flutterstudyjam_gdg/abhisheksahai-silentknight5245@gmail.com/AskMeAnything
mirrored_repositories/flutterstudyjam_gdg/abhisheksahai-silentknight5245@gmail.com/AskMeAnything/lib/main.dart
import 'package:flutter/material.dart'; import 'dart:math'; void main() => runApp( MaterialApp( debugShowCheckedModeBanner: false, home: BallPage(), ), ); class BallPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.lightBlue, appBar: AppBar( backgroundColor: Colors.blue[900], title: Text('Ask Me Anything'), ), body: Ball(), ); } } class Ball extends StatefulWidget { @override _BallState createState() => _BallState(); } class _BallState extends State<Ball> { int ballNumber = 1; @override Widget build(BuildContext context) { return SafeArea( child: Center( child: FlatButton( onPressed: () { setState(() { ballNumber = Random().nextInt(5) + 1; }); }, child: Image.asset('images/ball$ballNumber.png'), ), ), ); } }
0
mirrored_repositories/flutterstudyjam_gdg
mirrored_repositories/flutterstudyjam_gdg/RishavMishra_rishavm7@gmail.com/main.dart
import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State<MyApp> { Color favColor = Colors.black; @override Widget build(BuildContext context) { return MaterialApp( title: 'Welcome to Flutter', home: Scaffold( appBar: AppBar( title: Text('Instagram', style: TextStyle(color: Colors.black),), leading: Icon(Icons.camera_alt, color: Colors.black,), backgroundColor: Colors.white, actions: <Widget>[ Icon(Icons.tv, color: Colors.black,), SizedBox(width: 18), Icon(Icons.send, color: Colors.black,), ] ), body: ListView.builder( physics: BouncingScrollPhysics(), itemBuilder: (BuildContext context, int index) { return buildInstagramTile(); }, itemCount: 10, ), ), ); } Widget buildInstagramTile() { return Column( children: <Widget>[ ListTile( leading: Image.network( 'https://cdn.shopify.com/s/files/1/1698/6547/files/starcatalog_600x600.jpg?v=1511346010', ), title: Text('Stars'), trailing: Icon(Icons.more_horiz), ), Image.network( 'https://www.abc.net.au/news/image/9744422-1x1-940x940.jpg', height: 200, fit: BoxFit.fill, ), Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Row( children: <Widget>[ IconButton( icon: Icon( Icons.favorite, color: favColor, ), onPressed: () { setState(() { favColor = Colors.red; }); favColor = Colors.red; }, ), SizedBox(width: 8), Icon(Icons.mode_comment), SizedBox(width: 8), Icon(Icons.share), ], ), Icon(Icons.bookmark_border), ], ) ], ); } }
0