repo_id
stringlengths
21
168
file_path
stringlengths
36
210
content
stringlengths
1
9.98M
__index_level_0__
int64
0
0
mirrored_repositories/whatsapp-stacked-architecture/lib/ui/views/register
mirrored_repositories/whatsapp-stacked-architecture/lib/ui/views/register/widgets/register_first_name_text_field_widget.dart
import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:whatsapp_stacked_architecture/ui/views/common_widgets/text_field_widget.dart'; import 'package:whatsapp_stacked_architecture/ui/views/register/register_viewmodel.dart'; /// A widget for capturing the user's first name during registration. class RegisterFirstNameTextFieldWidget extends StatelessWidget { /// Reference to the view model for data control. final RegisterViewModel viewModel; /// Creates a [RegisterFirstNameTextFieldWidget] to capture user's first name. const RegisterFirstNameTextFieldWidget({ required this.viewModel, super.key, }); @override Widget build(BuildContext context) { // Returns a text field with a person icon and set width. return TextFieldWidget( textEditingController: viewModel.firstNameController, width: 0.39.sw, hintText: "First Name", prefixIcon: const Icon(Icons.person_outline), ); } }
0
mirrored_repositories/whatsapp-stacked-architecture/lib/ui/views/register
mirrored_repositories/whatsapp-stacked-architecture/lib/ui/views/register/widgets/register_email_text_field_widget.dart
import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:whatsapp_stacked_architecture/ui/views/common_widgets/text_field_widget.dart'; import 'package:whatsapp_stacked_architecture/ui/views/register/register_viewmodel.dart'; /// A widget for capturing the user's email during registration. class RegisterEmailTextFieldWidget extends StatelessWidget { /// Reference to the view model for data control. final RegisterViewModel viewModel; /// Creates a [RegisterEmailTextFieldWidget] to capture user's email. const RegisterEmailTextFieldWidget({ required this.viewModel, super.key, }); @override Widget build(BuildContext context) { // Returns a text field with an email icon and set width. return TextFieldWidget( textEditingController: viewModel.emailController, width: 0.78.sw, hintText: "Email", prefixIcon: const Icon(Icons.email_outlined), ); } }
0
mirrored_repositories/whatsapp-stacked-architecture/lib/ui/views/register
mirrored_repositories/whatsapp-stacked-architecture/lib/ui/views/register/widgets/register_last_name_text_field_widget.dart
import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:whatsapp_stacked_architecture/ui/views/common_widgets/text_field_widget.dart'; import 'package:whatsapp_stacked_architecture/ui/views/register/register_viewmodel.dart'; /// A widget for capturing the user's last name during registration. class RegisterLastNameTextFieldWidget extends StatelessWidget { /// Reference to the view model for data control. final RegisterViewModel viewModel; /// Creates a [RegisterLastNameTextFieldWidget] to capture user's last name. const RegisterLastNameTextFieldWidget({ required this.viewModel, super.key, }); @override Widget build(BuildContext context) { // Returns a text field with a person icon and set width. return TextFieldWidget( textEditingController: viewModel.lastNameController, width: 0.39.sw, hintText: "Last Name", prefixIcon: const Icon(Icons.person_outline), ); } }
0
mirrored_repositories/whatsapp-stacked-architecture/lib/ui/dialogs
mirrored_repositories/whatsapp-stacked-architecture/lib/ui/dialogs/info_alert/info_alert_dialog.dart
import 'package:flutter/material.dart'; import 'package:whatsapp_stacked_architecture/ui/common/ui_helpers.dart'; import 'package:stacked/stacked.dart'; import 'package:stacked_services/stacked_services.dart'; import 'info_alert_dialog_model.dart'; const double _graphicSize = 60; class InfoAlertDialog extends StackedView<InfoAlertDialogModel> { final DialogRequest request; final Function(DialogResponse) completer; const InfoAlertDialog({ Key? key, required this.request, required this.completer, }) : super(key: key); @override Widget builder( BuildContext context, InfoAlertDialogModel viewModel, Widget? child, ) { return Dialog( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), backgroundColor: Colors.white, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 20), child: Column( mainAxisSize: MainAxisSize.min, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( request.title!, style: const TextStyle( fontSize: 16, fontWeight: FontWeight.w900), ), verticalSpaceTiny, Text( request.description!, style: const TextStyle(fontSize: 14), maxLines: 3, softWrap: true, ), ], ), ), Container( width: _graphicSize, height: _graphicSize, decoration: const BoxDecoration( color: Color(0xffF6E7B0), borderRadius: BorderRadius.all( Radius.circular(_graphicSize / 2), ), ), alignment: Alignment.center, child: const Text( '⭐️', style: TextStyle(fontSize: 30), ), ) ], ), verticalSpaceMedium, GestureDetector( onTap: () => completer(DialogResponse( confirmed: true, )), child: Container( height: 50, width: double.infinity, alignment: Alignment.center, decoration: BoxDecoration( color: Colors.black, borderRadius: BorderRadius.circular(10), ), child: const Text( 'Got it', style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, fontSize: 16, ), ), ), ) ], ), ), ); } @override InfoAlertDialogModel viewModelBuilder(BuildContext context) => InfoAlertDialogModel(); }
0
mirrored_repositories/whatsapp-stacked-architecture/lib/ui/dialogs
mirrored_repositories/whatsapp-stacked-architecture/lib/ui/dialogs/info_alert/info_alert_dialog_model.dart
import 'package:stacked/stacked.dart'; class InfoAlertDialogModel extends BaseViewModel {}
0
mirrored_repositories/whatsapp-stacked-architecture/lib/ui/dialogs
mirrored_repositories/whatsapp-stacked-architecture/lib/ui/dialogs/should_exit/should_exit_dialog_model.dart
import 'package:stacked/stacked.dart'; class ShouldExitDialogModel extends BaseViewModel {}
0
mirrored_repositories/whatsapp-stacked-architecture/lib/ui/dialogs
mirrored_repositories/whatsapp-stacked-architecture/lib/ui/dialogs/should_exit/should_exit_dialog.dart
import 'package:flutter/material.dart'; import 'package:whatsapp_stacked_architecture/ui/common/ui_helpers.dart'; import 'package:stacked/stacked.dart'; import 'package:stacked_services/stacked_services.dart'; import 'should_exit_dialog_model.dart'; const double _graphicSize = 60; class ShouldExitDialog extends StackedView<ShouldExitDialogModel> { final DialogRequest request; final Function(DialogResponse) completer; const ShouldExitDialog({ Key? key, required this.request, required this.completer, }) : super(key: key); @override Widget builder( BuildContext context, ShouldExitDialogModel viewModel, Widget? child, ) { return Dialog( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), backgroundColor: Colors.white, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 20), child: Column( mainAxisSize: MainAxisSize.min, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( request.title ?? 'Hello Stacked Dialog!!', style: const TextStyle( fontSize: 16, fontWeight: FontWeight.w900, ), ), if (request.description != null) ...[ verticalSpaceTiny, Text( request.description!, style: const TextStyle( fontSize: 14, color: Colors.grey, ), maxLines: 3, softWrap: true, ), ], ], ), ), Container( width: _graphicSize, height: _graphicSize, decoration: const BoxDecoration( color: Color(0xFFF6E7B0), borderRadius: BorderRadius.all( Radius.circular(_graphicSize / 2), ), ), alignment: Alignment.center, child: const Text('⭐️', style: TextStyle(fontSize: 30)), ) ], ), verticalSpaceMedium, GestureDetector( onTap: () => completer(DialogResponse(confirmed: true)), child: Container( height: 50, width: double.infinity, alignment: Alignment.center, decoration: BoxDecoration( color: Colors.black, borderRadius: BorderRadius.circular(10), ), child: const Text( 'Got it', style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, fontSize: 16, ), ), ), ), ], ), ), ); } @override ShouldExitDialogModel viewModelBuilder(BuildContext context) => ShouldExitDialogModel(); }
0
mirrored_repositories/whatsapp-stacked-architecture/lib/ui
mirrored_repositories/whatsapp-stacked-architecture/lib/ui/common/app_colors.dart
import 'package:flutter/material.dart'; class AppColor { static const Color primary = Color(0xFF128c7e); static const Color secondary = Color.fromARGB(255, 185, 243, 187); static Color chatBackgroundColor = Colors.blueGrey.shade100; static MaterialColor primaryColor = const MaterialColor(0xFF128c7e, <int, Color>{ 50: Color(0xFFffffff), 100: Color(0xFFe7f4f2), 200: Color(0xFFd0e8e5), 300: Color(0xFFa0d1cb), 400: Color(0xFF89c6bf), 500: Color(0xFF71bab2), 600: Color(0xFF59afa5), 700: Color(0xFF41a398), 800: Color(0xFF2a988b), 900: Color(0xFF128c7e), }); }
0
mirrored_repositories/whatsapp-stacked-architecture/lib/ui
mirrored_repositories/whatsapp-stacked-architecture/lib/ui/common/ui_helpers.dart
import 'dart:math'; import 'package:flutter/material.dart'; const double _smallTinySize = 2.0; const double _tinySize = 5.0; const double _smallSize = 10.0; const double _mediumSize = 25.0; const double _largeSize = 50.0; const double _largerLage = 80.0; const double _massiveSize = 120.0; const Widget horizontalSpaceTiny = SizedBox(width: _tinySize); const Widget horizontalSpaceSmall = SizedBox(width: _smallSize); const Widget horizontalSpaceMedium = SizedBox(width: _mediumSize); const Widget horizontalSpaceLarge = SizedBox(width: _largeSize); const Widget verticalSpaceSmallTiny = SizedBox(height: _smallTinySize); const Widget verticalSpaceTiny = SizedBox(height: _tinySize); const Widget verticalSpaceSmall = SizedBox(height: _smallSize); const Widget verticalSpaceMedium = SizedBox(height: _mediumSize); const Widget verticalSpaceLarge = SizedBox(height: _largeSize); const Widget verticalSpaceLargerLarge = SizedBox(height: _largerLage); const Widget verticalSpaceMassive = SizedBox(height: _massiveSize); Widget spacedDivider = const Column( children: <Widget>[ verticalSpaceMedium, Divider(color: Colors.blueGrey, height: 5.0), verticalSpaceMedium, ], ); Widget verticalSpace(double height) => SizedBox(height: height); double screenWidth(BuildContext context) => MediaQuery.of(context).size.width; double screenHeight(BuildContext context) => MediaQuery.of(context).size.height; double screenHeightFraction(BuildContext context, {int dividedBy = 1, double offsetBy = 0, double max = 3000}) => min((screenHeight(context) - offsetBy) / dividedBy, max); double screenWidthFraction(BuildContext context, {int dividedBy = 1, double offsetBy = 0, double max = 3000}) => min((screenWidth(context) - offsetBy) / dividedBy, max); double halfScreenWidth(BuildContext context) => screenWidthFraction(context, dividedBy: 2); double thirdScreenWidth(BuildContext context) => screenWidthFraction(context, dividedBy: 3); double quarterScreenWidth(BuildContext context) => screenWidthFraction(context, dividedBy: 4); double getResponsiveHorizontalSpaceMedium(BuildContext context) => screenWidthFraction(context, dividedBy: 10); double getResponsiveSmallFontSize(BuildContext context) => getResponsiveFontSize(context, fontSize: 14, max: 15); double getResponsiveMediumFontSize(BuildContext context) => getResponsiveFontSize(context, fontSize: 16, max: 17); double getResponsiveLargeFontSize(BuildContext context) => getResponsiveFontSize(context, fontSize: 21, max: 31); double getResponsiveExtraLargeFontSize(BuildContext context) => getResponsiveFontSize(context, fontSize: 25); double getResponsiveMassiveFontSize(BuildContext context) => getResponsiveFontSize(context, fontSize: 30); double getResponsiveFontSize(BuildContext context, {double? fontSize, double? max}) { max ??= 100; var responsiveSize = min( screenWidthFraction(context, dividedBy: 10) * ((fontSize ?? 100) / 100), max); return responsiveSize; }
0
mirrored_repositories/whatsapp-stacked-architecture/lib/ui
mirrored_repositories/whatsapp-stacked-architecture/lib/ui/common/app_strings.dart
const String ksHomeBottomSheetTitle = 'Build Great Apps!'; const String ksHomeBottomSheetDescription = 'Stacked is built to help you build better apps. Give us a chance and we\'ll prove it to you. Check out stacked.filledstacks.com to learn more';
0
mirrored_repositories/whatsapp-stacked-architecture/lib/ui
mirrored_repositories/whatsapp-stacked-architecture/lib/ui/common/theme.dart
import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:whatsapp_stacked_architecture/ui/common/app_colors.dart'; import 'package:whatsapp_stacked_architecture/ui/common/app_font_sizes.dart'; class WhatsappTheme { static final ThemeData whatsappTheme = ThemeData( colorScheme: ColorScheme.fromSwatch( primarySwatch: AppColor.primaryColor, ), // appBarTheme: const AppBarTheme(color: AppColor.primary), // floatingActionButtonTheme: // const FloatingActionButtonThemeData(backgroundColor: AppColor.primary), textTheme: TextTheme( titleLarge: GoogleFonts.acme(fontSize: 50.sp), bodyMedium: const TextStyle( fontSize: AppFontSizes.small, ), titleMedium: TextStyle(fontSize: 20.sp, color: Colors.white), titleSmall: const TextStyle( fontSize: AppFontSizes.smallLarge, fontWeight: FontWeight.bold, ), bodyLarge: const TextStyle( fontSize: AppFontSizes.smallLarge, fontWeight: FontWeight.normal), labelSmall: const TextStyle( fontSize: AppFontSizes.smallMedium, fontWeight: FontWeight.normal), labelLarge: TextStyle( fontSize: 15.sp, fontWeight: FontWeight.normal, color: Colors.black)), ); // static }
0
mirrored_repositories/whatsapp-stacked-architecture/lib/ui
mirrored_repositories/whatsapp-stacked-architecture/lib/ui/common/app_font_sizes.dart
class AppFontSizes { static const smallest = 12.0; static const small = 14.0; static const smallMedium = 16.0; static const smallLarge = 17.0; static const medium = 20.0; static const mediumLarge = 22.0; static const mediumLarger = 25.0; static const mediumLargest = 28.0; }
0
mirrored_repositories/whatsapp-stacked-architecture/lib/ui/bottom_sheets
mirrored_repositories/whatsapp-stacked-architecture/lib/ui/bottom_sheets/notice/notice_sheet_model.dart
import 'package:stacked/stacked.dart'; class NoticeSheetModel extends BaseViewModel {}
0
mirrored_repositories/whatsapp-stacked-architecture/lib/ui/bottom_sheets
mirrored_repositories/whatsapp-stacked-architecture/lib/ui/bottom_sheets/notice/notice_sheet.dart
import 'package:flutter/material.dart'; import 'package:whatsapp_stacked_architecture/ui/common/ui_helpers.dart'; import 'package:stacked/stacked.dart'; import 'package:stacked_services/stacked_services.dart'; import 'notice_sheet_model.dart'; class NoticeSheet extends StackedView<NoticeSheetModel> { final Function(SheetResponse)? completer; final SheetRequest request; const NoticeSheet({ Key? key, required this.completer, required this.request, }) : super(key: key); @override Widget builder( BuildContext context, NoticeSheetModel viewModel, Widget? child, ) { return Container( padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15), decoration: const BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only( topLeft: Radius.circular(10), topRight: Radius.circular(10), ), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ Text( request.title!, style: const TextStyle(fontSize: 25, fontWeight: FontWeight.w900), ), verticalSpaceTiny, Text( request.description!, style: const TextStyle(fontSize: 14), maxLines: 3, softWrap: true, ), verticalSpaceLarge, ], ), ); } @override NoticeSheetModel viewModelBuilder(BuildContext context) => NoticeSheetModel(); }
0
mirrored_repositories/whatsapp-stacked-architecture/lib
mirrored_repositories/whatsapp-stacked-architecture/lib/services/create_new_user_service.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; /// A service class to create a new user in Firebase Authentication Service. class CreateNewUserService { final db = FirebaseFirestore.instance; /// Takes [email] and [password] as parameters. /// /// [email] is the Email and [password] is the Password of the user. /// /// A future method that calls the service to create new user from /// Firebase Auth with the given credentials. Future<String> requestCreateNewUserApi( {required String email, required String password}) async { try { /// Stores the user credential in the credential variable /// that is received through an async function that calls /// firebase authentication service. UserCredential userCredential = await FirebaseAuth.instance.createUserWithEmailAndPassword( email: email, password: password, ); /// Returns the credential retreived from Firebase Auth service by converting /// it into string. return "successful:${userCredential.user?.uid}"; // On errors catches the errors and returns the error code. } on FirebaseAuthException catch (e) { return e.code; } } /// Method that takes in the user description in Map type and /// adds the object into the Firestore Database. Future<void> requestAddUserInfoToDatabaseApi( Map<String, dynamic> user) async { db.collection("users").add(user).then((DocumentReference doc) => debugPrint('DocumentSnapshot added with ID: ${doc.id}')); } }
0
mirrored_repositories/whatsapp-stacked-architecture/lib
mirrored_repositories/whatsapp-stacked-architecture/lib/services/fetch_user_list_service.dart
// import 'dart:html'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:whatsapp_stacked_architecture/datamodels/user_model.dart'; /// A service class to fetch the users and their details for the home page. class FetchUserListService { final db = FirebaseFirestore.instance; Stream<List<Users>> fetchUserList() { /// Fetches the user details from the Firestore database and returns after /// converting the details that is in JSON into an instance of User model. return db .collection("users") .snapshots() .map((snapshot) => snapshot.docs) .map((docs) => docs.map((doc) => Users.fromJson(doc)).toList()); } }
0
mirrored_repositories/whatsapp-stacked-architecture/lib
mirrored_repositories/whatsapp-stacked-architecture/lib/services/login_service_service.dart
import 'package:firebase_auth/firebase_auth.dart'; /// A service class to log in into an existing user in Firebase /// Authentication Service. class LoginServiceService { String responseCode = ""; /// Takes [email] and [password] as arguments. /// /// [email] and [password] are the email and password of the user /// you're trying to log in as. /// /// Tries to authenticate and sign in with the given email /// and password in the Firebase Authentication Service. Future<String> requestLoginApi(String email, String password) async { try { await FirebaseAuth.instance .signInWithEmailAndPassword(email: email, password: password); responseCode = "Successful"; /// On facing errors during the authentication catches the /// error and returns the error code. } on FirebaseAuthException catch (e) { responseCode = e.code; } return responseCode; } }
0
mirrored_repositories/whatsapp-stacked-architecture/lib
mirrored_repositories/whatsapp-stacked-architecture/lib/services/chat_service.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:whatsapp_stacked_architecture/datamodels/chat_model.dart'; /// Service class that helps with different chat features. class ChatService { final db = FirebaseFirestore.instance; /// Stream method that takes [chatId] as argument and calls an API that fetches the /// chat messages of the given [chatId] from the database. Stream<List<ChatModel>> fetchChatMessages({required String chatId}) { return db .collection("messages") .doc(chatId) .collection("message") .orderBy("sentTime", descending: true) .snapshots() .map((snapshot) => snapshot.docs) .map((docs) => docs.map((doc) => ChatModel.fromJson(doc)).toList()); // debugPrint(list.toString()); } /// Future Method that takes in [chatId] and [messageInfo] as argument and /// adds the [messageInfo] in the database. Future<void> requestAddMessagesToDatabaseApi( {required Map<String, dynamic> messageInfo, required String chatId}) async { await db .collection("messages") .doc(chatId) .collection("message") .add(messageInfo); } }
0
mirrored_repositories/whatsapp-stacked-architecture/test
mirrored_repositories/whatsapp-stacked-architecture/test/viewmodels/chat_page_viewmodel_test.dart
import 'package:firebase_core/firebase_core.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; import 'package:whatsapp_stacked_architecture/app/app.locator.dart'; import 'package:whatsapp_stacked_architecture/ui/views/chat_page/chat_page_viewmodel.dart'; import '../helpers/test_helpers.dart'; class MockFirebase extends Mock implements Firebase {} void main() { group('ChatPageViewModel Tests -', () { setUp(() { registerServices(); }); tearDown(() => locator.reset()); test("Must return chat id separated by hyphen in alphabetical order", () { ChatPageViewModel model = ChatPageViewModel(); String chatId = model.getChatId("jk3jj4b3b4jh3b4", "3jk432kj4nj3k4buy34b"); expect(chatId, "jk3jj4b3b4jh3b4-3jk432kj4nj3k4buy34b"); }); }); }
0
mirrored_repositories/whatsapp-stacked-architecture/test
mirrored_repositories/whatsapp-stacked-architecture/test/viewmodels/register_viewmodel_test.dart
import 'package:flutter_test/flutter_test.dart'; import 'package:whatsapp_stacked_architecture/app/app.locator.dart'; import '../helpers/test_helpers.dart'; void main() { group('RegisterViewModel Tests -', () { setUp(() => registerServices()); tearDown(() => locator.reset()); }); }
0
mirrored_repositories/whatsapp-stacked-architecture/test
mirrored_repositories/whatsapp-stacked-architecture/test/viewmodels/home_viewmodel_test.dart
import 'package:flutter_test/flutter_test.dart'; import 'package:whatsapp_stacked_architecture/app/app.locator.dart'; import 'package:whatsapp_stacked_architecture/ui/views/home/home_viewmodel.dart'; import '../helpers/test_helpers.dart'; void main() { HomeViewModel getModel() => HomeViewModel(); group('HomeViewmodelTest -', () { setUp(() => registerServices()); tearDown(() => locator.reset()); }); }
0
mirrored_repositories/whatsapp-stacked-architecture/test
mirrored_repositories/whatsapp-stacked-architecture/test/viewmodels/should_exit_dialog_model_test.dart
import 'package:flutter_test/flutter_test.dart'; import 'package:whatsapp_stacked_architecture/app/app.locator.dart'; import '../helpers/test_helpers.dart'; void main() { group('ShouldExitDialogModel Tests -', () { setUp(() => registerServices()); tearDown(() => locator.reset()); }); }
0
mirrored_repositories/whatsapp-stacked-architecture/test
mirrored_repositories/whatsapp-stacked-architecture/test/viewmodels/info_alert_dialog_model_test.dart
import 'package:flutter_test/flutter_test.dart'; import 'package:whatsapp_stacked_architecture/app/app.locator.dart'; import '../helpers/test_helpers.dart'; void main() { group('InfoAlertDialogModel Tests -', () { setUp(() => registerServices()); tearDown(() => locator.reset()); }); }
0
mirrored_repositories/whatsapp-stacked-architecture/test
mirrored_repositories/whatsapp-stacked-architecture/test/viewmodels/login_viewmodel_test.dart
import 'package:flutter_test/flutter_test.dart'; import 'package:whatsapp_stacked_architecture/app/app.locator.dart'; import '../helpers/test_helpers.dart'; void main() { group('LoginViewModel Tests -', () { setUp(() => registerServices()); tearDown(() => locator.reset()); }); }
0
mirrored_repositories/whatsapp-stacked-architecture/test
mirrored_repositories/whatsapp-stacked-architecture/test/viewmodels/notice_sheet_model_test.dart
import 'package:flutter_test/flutter_test.dart'; import 'package:whatsapp_stacked_architecture/app/app.locator.dart'; import '../helpers/test_helpers.dart'; void main() { group('InfoAlertDialogModel Tests -', () { setUp(() => registerServices()); tearDown(() => locator.reset()); }); }
0
mirrored_repositories/whatsapp-stacked-architecture/test
mirrored_repositories/whatsapp-stacked-architecture/test/helpers/test_helpers.mocks.dart
// Mocks generated by Mockito 5.4.2 from annotations // in whatsapp_stacked_architecture/test/helpers/test_helpers.dart. // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i5; import 'dart:ui' as _i6; import 'package:cloud_firestore/cloud_firestore.dart' as _i2; import 'package:flutter/material.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; import 'package:stacked_services/stacked_services.dart' as _i3; import 'package:whatsapp_stacked_architecture/datamodels/chat_model.dart' as _i12; import 'package:whatsapp_stacked_architecture/datamodels/user_model.dart' as _i10; import 'package:whatsapp_stacked_architecture/services/chat_service.dart' as _i11; import 'package:whatsapp_stacked_architecture/services/create_new_user_service.dart' as _i7; import 'package:whatsapp_stacked_architecture/services/fetch_user_list_service.dart' as _i9; import 'package:whatsapp_stacked_architecture/services/login_service_service.dart' as _i8; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_setters_without_getters // ignore_for_file: comment_references // ignore_for_file: implementation_imports // ignore_for_file: invalid_use_of_visible_for_testing_member // ignore_for_file: prefer_const_constructors // ignore_for_file: unnecessary_parenthesis // ignore_for_file: camel_case_types // ignore_for_file: subtype_of_sealed_class class _FakeFirebaseFirestore_0 extends _i1.SmartFake implements _i2.FirebaseFirestore { _FakeFirebaseFirestore_0( Object parent, Invocation parentInvocation, ) : super( parent, parentInvocation, ); } /// A class which mocks [NavigationService]. /// /// See the documentation for Mockito's code generation for more information. class MockNavigationService extends _i1.Mock implements _i3.NavigationService { @override String get previousRoute => (super.noSuchMethod( Invocation.getter(#previousRoute), returnValue: '', returnValueForMissingStub: '', ) as String); @override String get currentRoute => (super.noSuchMethod( Invocation.getter(#currentRoute), returnValue: '', returnValueForMissingStub: '', ) as String); @override _i4.GlobalKey<_i4.NavigatorState>? nestedNavigationKey(int? index) => (super.noSuchMethod( Invocation.method( #nestedNavigationKey, [index], ), returnValueForMissingStub: null, ) as _i4.GlobalKey<_i4.NavigatorState>?); @override void config({ bool? enableLog, bool? defaultPopGesture, bool? defaultOpaqueRoute, Duration? defaultDurationTransition, bool? defaultGlobalState, _i3.Transition? defaultTransitionStyle, String? defaultTransition, }) => super.noSuchMethod( Invocation.method( #config, [], { #enableLog: enableLog, #defaultPopGesture: defaultPopGesture, #defaultOpaqueRoute: defaultOpaqueRoute, #defaultDurationTransition: defaultDurationTransition, #defaultGlobalState: defaultGlobalState, #defaultTransitionStyle: defaultTransitionStyle, #defaultTransition: defaultTransition, }, ), returnValueForMissingStub: null, ); @override _i5.Future<T?>? navigateWithTransition<T>( _i4.Widget? page, { bool? opaque, String? transition = r'', Duration? duration, bool? popGesture, int? id, _i4.Curve? curve, bool? fullscreenDialog = false, bool? preventDuplicates = true, _i3.Transition? transitionClass, _i3.Transition? transitionStyle, String? routeName, }) => (super.noSuchMethod( Invocation.method( #navigateWithTransition, [page], { #opaque: opaque, #transition: transition, #duration: duration, #popGesture: popGesture, #id: id, #curve: curve, #fullscreenDialog: fullscreenDialog, #preventDuplicates: preventDuplicates, #transitionClass: transitionClass, #transitionStyle: transitionStyle, #routeName: routeName, }, ), returnValueForMissingStub: null, ) as _i5.Future<T?>?); @override _i5.Future<T?>? replaceWithTransition<T>( _i4.Widget? page, { bool? opaque, String? transition = r'', Duration? duration, bool? popGesture, int? id, _i4.Curve? curve, bool? fullscreenDialog = false, bool? preventDuplicates = true, _i3.Transition? transitionClass, _i3.Transition? transitionStyle, String? routeName, }) => (super.noSuchMethod( Invocation.method( #replaceWithTransition, [page], { #opaque: opaque, #transition: transition, #duration: duration, #popGesture: popGesture, #id: id, #curve: curve, #fullscreenDialog: fullscreenDialog, #preventDuplicates: preventDuplicates, #transitionClass: transitionClass, #transitionStyle: transitionStyle, #routeName: routeName, }, ), returnValueForMissingStub: null, ) as _i5.Future<T?>?); @override bool back<T>({ dynamic result, int? id, }) => (super.noSuchMethod( Invocation.method( #back, [], { #result: result, #id: id, }, ), returnValue: false, returnValueForMissingStub: false, ) as bool); @override void popUntil( _i4.RoutePredicate? predicate, { int? id, }) => super.noSuchMethod( Invocation.method( #popUntil, [predicate], {#id: id}, ), returnValueForMissingStub: null, ); @override void popRepeated(int? popTimes) => super.noSuchMethod( Invocation.method( #popRepeated, [popTimes], ), returnValueForMissingStub: null, ); @override _i5.Future<T?>? navigateTo<T>( String? routeName, { dynamic arguments, int? id, bool? preventDuplicates = true, Map<String, String>? parameters, _i4.RouteTransitionsBuilder? transition, }) => (super.noSuchMethod( Invocation.method( #navigateTo, [routeName], { #arguments: arguments, #id: id, #preventDuplicates: preventDuplicates, #parameters: parameters, #transition: transition, }, ), returnValueForMissingStub: null, ) as _i5.Future<T?>?); @override _i5.Future<T?>? navigateToView<T>( _i4.Widget? view, { dynamic arguments, int? id, bool? opaque, _i4.Curve? curve, Duration? duration, bool? fullscreenDialog = false, bool? popGesture, bool? preventDuplicates = true, _i3.Transition? transition, _i3.Transition? transitionStyle, }) => (super.noSuchMethod( Invocation.method( #navigateToView, [view], { #arguments: arguments, #id: id, #opaque: opaque, #curve: curve, #duration: duration, #fullscreenDialog: fullscreenDialog, #popGesture: popGesture, #preventDuplicates: preventDuplicates, #transition: transition, #transitionStyle: transitionStyle, }, ), returnValueForMissingStub: null, ) as _i5.Future<T?>?); @override _i5.Future<T?>? replaceWith<T>( String? routeName, { dynamic arguments, int? id, bool? preventDuplicates = true, Map<String, String>? parameters, _i4.RouteTransitionsBuilder? transition, }) => (super.noSuchMethod( Invocation.method( #replaceWith, [routeName], { #arguments: arguments, #id: id, #preventDuplicates: preventDuplicates, #parameters: parameters, #transition: transition, }, ), returnValueForMissingStub: null, ) as _i5.Future<T?>?); @override _i5.Future<T?>? clearStackAndShow<T>( String? routeName, { dynamic arguments, int? id, Map<String, String>? parameters, }) => (super.noSuchMethod( Invocation.method( #clearStackAndShow, [routeName], { #arguments: arguments, #id: id, #parameters: parameters, }, ), returnValueForMissingStub: null, ) as _i5.Future<T?>?); @override _i5.Future<T?>? clearStackAndShowView<T>( _i4.Widget? view, { dynamic arguments, int? id, }) => (super.noSuchMethod( Invocation.method( #clearStackAndShowView, [view], { #arguments: arguments, #id: id, }, ), returnValueForMissingStub: null, ) as _i5.Future<T?>?); @override _i5.Future<T?>? clearTillFirstAndShow<T>( String? routeName, { dynamic arguments, int? id, bool? preventDuplicates = true, Map<String, String>? parameters, }) => (super.noSuchMethod( Invocation.method( #clearTillFirstAndShow, [routeName], { #arguments: arguments, #id: id, #preventDuplicates: preventDuplicates, #parameters: parameters, }, ), returnValueForMissingStub: null, ) as _i5.Future<T?>?); @override _i5.Future<T?>? clearTillFirstAndShowView<T>( _i4.Widget? view, { dynamic arguments, int? id, }) => (super.noSuchMethod( Invocation.method( #clearTillFirstAndShowView, [view], { #arguments: arguments, #id: id, }, ), returnValueForMissingStub: null, ) as _i5.Future<T?>?); @override _i5.Future<T?>? pushNamedAndRemoveUntil<T>( String? routeName, { _i4.RoutePredicate? predicate, dynamic arguments, int? id, }) => (super.noSuchMethod( Invocation.method( #pushNamedAndRemoveUntil, [routeName], { #predicate: predicate, #arguments: arguments, #id: id, }, ), returnValueForMissingStub: null, ) as _i5.Future<T?>?); } /// A class which mocks [BottomSheetService]. /// /// See the documentation for Mockito's code generation for more information. class MockBottomSheetService extends _i1.Mock implements _i3.BottomSheetService { @override void setCustomSheetBuilders(Map<dynamic, _i3.SheetBuilder>? builders) => super.noSuchMethod( Invocation.method( #setCustomSheetBuilders, [builders], ), returnValueForMissingStub: null, ); @override _i5.Future<_i3.SheetResponse<dynamic>?> showBottomSheet({ required String? title, String? description, String? confirmButtonTitle = r'Ok', String? cancelButtonTitle, bool? enableDrag = true, bool? barrierDismissible = true, bool? isScrollControlled = false, Duration? exitBottomSheetDuration, Duration? enterBottomSheetDuration, bool? ignoreSafeArea, bool? useRootNavigator = false, }) => (super.noSuchMethod( Invocation.method( #showBottomSheet, [], { #title: title, #description: description, #confirmButtonTitle: confirmButtonTitle, #cancelButtonTitle: cancelButtonTitle, #enableDrag: enableDrag, #barrierDismissible: barrierDismissible, #isScrollControlled: isScrollControlled, #exitBottomSheetDuration: exitBottomSheetDuration, #enterBottomSheetDuration: enterBottomSheetDuration, #ignoreSafeArea: ignoreSafeArea, #useRootNavigator: useRootNavigator, }, ), returnValue: _i5.Future<_i3.SheetResponse<dynamic>?>.value(), returnValueForMissingStub: _i5.Future<_i3.SheetResponse<dynamic>?>.value(), ) as _i5.Future<_i3.SheetResponse<dynamic>?>); @override _i5.Future<_i3.SheetResponse<T>?> showCustomSheet<T, R>({ dynamic variant, String? title, String? description, bool? hasImage = false, String? imageUrl, bool? showIconInMainButton = false, String? mainButtonTitle, bool? showIconInSecondaryButton = false, String? secondaryButtonTitle, bool? showIconInAdditionalButton = false, String? additionalButtonTitle, bool? takesInput = false, _i6.Color? barrierColor = const _i6.Color(2315255808), bool? barrierDismissible = true, bool? isScrollControlled = false, String? barrierLabel = r'', dynamic customData, R? data, bool? enableDrag = true, Duration? exitBottomSheetDuration, Duration? enterBottomSheetDuration, bool? ignoreSafeArea, bool? useRootNavigator = false, }) => (super.noSuchMethod( Invocation.method( #showCustomSheet, [], { #variant: variant, #title: title, #description: description, #hasImage: hasImage, #imageUrl: imageUrl, #showIconInMainButton: showIconInMainButton, #mainButtonTitle: mainButtonTitle, #showIconInSecondaryButton: showIconInSecondaryButton, #secondaryButtonTitle: secondaryButtonTitle, #showIconInAdditionalButton: showIconInAdditionalButton, #additionalButtonTitle: additionalButtonTitle, #takesInput: takesInput, #barrierColor: barrierColor, #barrierDismissible: barrierDismissible, #isScrollControlled: isScrollControlled, #barrierLabel: barrierLabel, #customData: customData, #data: data, #enableDrag: enableDrag, #exitBottomSheetDuration: exitBottomSheetDuration, #enterBottomSheetDuration: enterBottomSheetDuration, #ignoreSafeArea: ignoreSafeArea, #useRootNavigator: useRootNavigator, }, ), returnValue: _i5.Future<_i3.SheetResponse<T>?>.value(), returnValueForMissingStub: _i5.Future<_i3.SheetResponse<T>?>.value(), ) as _i5.Future<_i3.SheetResponse<T>?>); @override void completeSheet(_i3.SheetResponse<dynamic>? response) => super.noSuchMethod( Invocation.method( #completeSheet, [response], ), returnValueForMissingStub: null, ); } /// A class which mocks [DialogService]. /// /// See the documentation for Mockito's code generation for more information. class MockDialogService extends _i1.Mock implements _i3.DialogService { @override void registerCustomDialogBuilders( Map<dynamic, _i3.DialogBuilder>? builders) => super.noSuchMethod( Invocation.method( #registerCustomDialogBuilders, [builders], ), returnValueForMissingStub: null, ); @override void registerCustomDialogBuilder({ required dynamic variant, required _i4.Widget Function( _i4.BuildContext, _i3.DialogRequest<dynamic>, dynamic Function(_i3.DialogResponse<dynamic>), )? builder, }) => super.noSuchMethod( Invocation.method( #registerCustomDialogBuilder, [], { #variant: variant, #builder: builder, }, ), returnValueForMissingStub: null, ); @override _i5.Future<_i3.DialogResponse<dynamic>?> showDialog({ String? title, String? description, String? cancelTitle, _i6.Color? cancelTitleColor, String? buttonTitle = r'Ok', _i6.Color? buttonTitleColor, bool? barrierDismissible = false, _i3.DialogPlatform? dialogPlatform, }) => (super.noSuchMethod( Invocation.method( #showDialog, [], { #title: title, #description: description, #cancelTitle: cancelTitle, #cancelTitleColor: cancelTitleColor, #buttonTitle: buttonTitle, #buttonTitleColor: buttonTitleColor, #barrierDismissible: barrierDismissible, #dialogPlatform: dialogPlatform, }, ), returnValue: _i5.Future<_i3.DialogResponse<dynamic>?>.value(), returnValueForMissingStub: _i5.Future<_i3.DialogResponse<dynamic>?>.value(), ) as _i5.Future<_i3.DialogResponse<dynamic>?>); @override _i5.Future<_i3.DialogResponse<T>?> showCustomDialog<T, R>({ dynamic variant, String? title, String? description, bool? hasImage = false, String? imageUrl, bool? showIconInMainButton = false, String? mainButtonTitle, bool? showIconInSecondaryButton = false, String? secondaryButtonTitle, bool? showIconInAdditionalButton = false, String? additionalButtonTitle, bool? takesInput = false, _i6.Color? barrierColor = const _i6.Color(2315255808), bool? barrierDismissible = false, String? barrierLabel = r'', bool? useSafeArea = true, dynamic customData, R? data, }) => (super.noSuchMethod( Invocation.method( #showCustomDialog, [], { #variant: variant, #title: title, #description: description, #hasImage: hasImage, #imageUrl: imageUrl, #showIconInMainButton: showIconInMainButton, #mainButtonTitle: mainButtonTitle, #showIconInSecondaryButton: showIconInSecondaryButton, #secondaryButtonTitle: secondaryButtonTitle, #showIconInAdditionalButton: showIconInAdditionalButton, #additionalButtonTitle: additionalButtonTitle, #takesInput: takesInput, #barrierColor: barrierColor, #barrierDismissible: barrierDismissible, #barrierLabel: barrierLabel, #useSafeArea: useSafeArea, #customData: customData, #data: data, }, ), returnValue: _i5.Future<_i3.DialogResponse<T>?>.value(), returnValueForMissingStub: _i5.Future<_i3.DialogResponse<T>?>.value(), ) as _i5.Future<_i3.DialogResponse<T>?>); @override _i5.Future<_i3.DialogResponse<dynamic>?> showConfirmationDialog({ String? title, String? description, String? cancelTitle = r'Cancel', _i6.Color? cancelTitleColor, String? confirmationTitle = r'Ok', _i6.Color? confirmationTitleColor, bool? barrierDismissible = false, _i3.DialogPlatform? dialogPlatform, }) => (super.noSuchMethod( Invocation.method( #showConfirmationDialog, [], { #title: title, #description: description, #cancelTitle: cancelTitle, #cancelTitleColor: cancelTitleColor, #confirmationTitle: confirmationTitle, #confirmationTitleColor: confirmationTitleColor, #barrierDismissible: barrierDismissible, #dialogPlatform: dialogPlatform, }, ), returnValue: _i5.Future<_i3.DialogResponse<dynamic>?>.value(), returnValueForMissingStub: _i5.Future<_i3.DialogResponse<dynamic>?>.value(), ) as _i5.Future<_i3.DialogResponse<dynamic>?>); @override void completeDialog(_i3.DialogResponse<dynamic>? response) => super.noSuchMethod( Invocation.method( #completeDialog, [response], ), returnValueForMissingStub: null, ); } /// A class which mocks [CreateNewUserService]. /// /// See the documentation for Mockito's code generation for more information. class MockCreateNewUserService extends _i1.Mock implements _i7.CreateNewUserService { @override _i2.FirebaseFirestore get db => (super.noSuchMethod( Invocation.getter(#db), returnValue: _FakeFirebaseFirestore_0( this, Invocation.getter(#db), ), returnValueForMissingStub: _FakeFirebaseFirestore_0( this, Invocation.getter(#db), ), ) as _i2.FirebaseFirestore); @override _i5.Future<String> requestCreateNewUserApi({ required String? email, required String? password, }) => (super.noSuchMethod( Invocation.method( #requestCreateNewUserApi, [], { #email: email, #password: password, }, ), returnValue: _i5.Future<String>.value(''), returnValueForMissingStub: _i5.Future<String>.value(''), ) as _i5.Future<String>); @override _i5.Future<void> requestAddUserInfoToDatabaseApi( Map<String, dynamic>? user) => (super.noSuchMethod( Invocation.method( #requestAddUserInfoToDatabaseApi, [user], ), returnValue: _i5.Future<void>.value(), returnValueForMissingStub: _i5.Future<void>.value(), ) as _i5.Future<void>); } /// A class which mocks [LoginServiceService]. /// /// See the documentation for Mockito's code generation for more information. class MockLoginServiceService extends _i1.Mock implements _i8.LoginServiceService { @override String get responseCode => (super.noSuchMethod( Invocation.getter(#responseCode), returnValue: '', returnValueForMissingStub: '', ) as String); @override set responseCode(String? _responseCode) => super.noSuchMethod( Invocation.setter( #responseCode, _responseCode, ), returnValueForMissingStub: null, ); @override _i5.Future<String> requestLoginApi( String? email, String? password, ) => (super.noSuchMethod( Invocation.method( #requestLoginApi, [ email, password, ], ), returnValue: _i5.Future<String>.value(''), returnValueForMissingStub: _i5.Future<String>.value(''), ) as _i5.Future<String>); } /// A class which mocks [FetchUserListService]. /// /// See the documentation for Mockito's code generation for more information. class MockFetchUserListService extends _i1.Mock implements _i9.FetchUserListService { @override _i2.FirebaseFirestore get db => (super.noSuchMethod( Invocation.getter(#db), returnValue: _FakeFirebaseFirestore_0( this, Invocation.getter(#db), ), returnValueForMissingStub: _FakeFirebaseFirestore_0( this, Invocation.getter(#db), ), ) as _i2.FirebaseFirestore); @override _i5.Stream<List<_i10.Users>> fetchUserList() => (super.noSuchMethod( Invocation.method( #fetchUserList, [], ), returnValue: _i5.Stream<List<_i10.Users>>.empty(), returnValueForMissingStub: _i5.Stream<List<_i10.Users>>.empty(), ) as _i5.Stream<List<_i10.Users>>); } /// A class which mocks [ChatService]. /// /// See the documentation for Mockito's code generation for more information. class MockChatService extends _i1.Mock implements _i11.ChatService { @override _i2.FirebaseFirestore get db => (super.noSuchMethod( Invocation.getter(#db), returnValue: _FakeFirebaseFirestore_0( this, Invocation.getter(#db), ), returnValueForMissingStub: _FakeFirebaseFirestore_0( this, Invocation.getter(#db), ), ) as _i2.FirebaseFirestore); @override _i5.Stream<List<_i12.ChatModel>> fetchChatMessages( {required String? chatId}) => (super.noSuchMethod( Invocation.method( #fetchChatMessages, [], {#chatId: chatId}, ), returnValue: _i5.Stream<List<_i12.ChatModel>>.empty(), returnValueForMissingStub: _i5.Stream<List<_i12.ChatModel>>.empty(), ) as _i5.Stream<List<_i12.ChatModel>>); @override _i5.Future<void> requestAddMessagesToDatabaseApi({ required Map<String, dynamic>? messageInfo, required String? chatId, }) => (super.noSuchMethod( Invocation.method( #requestAddMessagesToDatabaseApi, [], { #messageInfo: messageInfo, #chatId: chatId, }, ), returnValue: _i5.Future<void>.value(), returnValueForMissingStub: _i5.Future<void>.value(), ) as _i5.Future<void>); } /// A class which mocks [SnackbarService]. /// /// See the documentation for Mockito's code generation for more information. class MockSnackbarService extends _i1.Mock implements _i3.SnackbarService { @override bool get isSnackbarOpen => (super.noSuchMethod( Invocation.getter(#isSnackbarOpen), returnValue: false, returnValueForMissingStub: false, ) as bool); @override void registerSnackbarConfig(_i3.SnackbarConfig? config) => super.noSuchMethod( Invocation.method( #registerSnackbarConfig, [config], ), returnValueForMissingStub: null, ); @override void registerCustomMainButtonBuilder({ dynamic variant, _i4.Widget Function( String?, Function?, )? builder, }) => super.noSuchMethod( Invocation.method( #registerCustomMainButtonBuilder, [], { #variant: variant, #builder: builder, }, ), returnValueForMissingStub: null, ); @override void registerCustomSnackbarConfig({ required dynamic variant, _i3.SnackbarConfig? config, _i3.SnackbarConfig Function()? configBuilder, }) => super.noSuchMethod( Invocation.method( #registerCustomSnackbarConfig, [], { #variant: variant, #config: config, #configBuilder: configBuilder, }, ), returnValueForMissingStub: null, ); @override void showSnackbar({ String? title = r'', required String? message, dynamic Function(dynamic)? onTap, Duration? duration, String? mainButtonTitle, void Function()? onMainButtonTapped, }) => super.noSuchMethod( Invocation.method( #showSnackbar, [], { #title: title, #message: message, #onTap: onTap, #duration: duration, #mainButtonTitle: mainButtonTitle, #onMainButtonTapped: onMainButtonTapped, }, ), returnValueForMissingStub: null, ); @override _i5.Future<dynamic>? showCustomSnackBar({ required String? message, _i4.TextStyle? messageTextStyle, required dynamic variant, String? title, _i4.TextStyle? titleTextStyle, String? mainButtonTitle, _i4.ButtonStyle? mainButtonStyle, void Function()? onMainButtonTapped, Function? onTap, Duration? duration, }) => (super.noSuchMethod( Invocation.method( #showCustomSnackBar, [], { #message: message, #messageTextStyle: messageTextStyle, #variant: variant, #title: title, #titleTextStyle: titleTextStyle, #mainButtonTitle: mainButtonTitle, #mainButtonStyle: mainButtonStyle, #onMainButtonTapped: onMainButtonTapped, #onTap: onTap, #duration: duration, }, ), returnValueForMissingStub: null, ) as _i5.Future<dynamic>?); @override _i5.Future<void> closeSnackbar() => (super.noSuchMethod( Invocation.method( #closeSnackbar, [], ), returnValue: _i5.Future<void>.value(), returnValueForMissingStub: _i5.Future<void>.value(), ) as _i5.Future<void>); }
0
mirrored_repositories/whatsapp-stacked-architecture/test
mirrored_repositories/whatsapp-stacked-architecture/test/helpers/test_helpers.dart
import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'package:whatsapp_stacked_architecture/app/app.locator.dart'; import 'package:stacked_services/stacked_services.dart'; import 'package:whatsapp_stacked_architecture/services/create_new_user_service.dart'; import 'package:whatsapp_stacked_architecture/services/login_service_service.dart'; import 'package:whatsapp_stacked_architecture/services/fetch_user_list_service.dart'; import 'package:whatsapp_stacked_architecture/services/chat_service.dart'; // @stacked-import import 'test_helpers.mocks.dart'; @GenerateMocks([], customMocks: [ MockSpec<NavigationService>(onMissingStub: OnMissingStub.returnDefault), MockSpec<BottomSheetService>(onMissingStub: OnMissingStub.returnDefault), MockSpec<DialogService>(onMissingStub: OnMissingStub.returnDefault), MockSpec<CreateNewUserService>(onMissingStub: OnMissingStub.returnDefault), MockSpec<LoginServiceService>(onMissingStub: OnMissingStub.returnDefault), MockSpec<FetchUserListService>(onMissingStub: OnMissingStub.returnDefault), MockSpec<ChatService>(onMissingStub: OnMissingStub.returnDefault), MockSpec<SnackbarService>(onMissingStub: OnMissingStub.returnDefault), // @stacked-mock-spec ]) void registerServices() { getAndRegisterNavigationService(); getAndRegisterBottomSheetService(); getAndRegisterDialogService(); getAndRegisterCreateNewUserService(); getAndRegisterLoginServiceService(); getAndRegisterFetchUserListService(); getAndRegisterChatService(); // @stacked-mock-register } MockNavigationService getAndRegisterNavigationService() { _removeRegistrationIfExists<NavigationService>(); final service = MockNavigationService(); locator.registerSingleton<NavigationService>(service); return service; } MockBottomSheetService getAndRegisterBottomSheetService<T>({ SheetResponse<T>? showCustomSheetResponse, }) { _removeRegistrationIfExists<BottomSheetService>(); final service = MockBottomSheetService(); when(service.showCustomSheet<T, T>( enableDrag: anyNamed('enableDrag'), enterBottomSheetDuration: anyNamed('enterBottomSheetDuration'), exitBottomSheetDuration: anyNamed('exitBottomSheetDuration'), ignoreSafeArea: anyNamed('ignoreSafeArea'), isScrollControlled: anyNamed('isScrollControlled'), barrierDismissible: anyNamed('barrierDismissible'), additionalButtonTitle: anyNamed('additionalButtonTitle'), variant: anyNamed('variant'), title: anyNamed('title'), hasImage: anyNamed('hasImage'), imageUrl: anyNamed('imageUrl'), showIconInMainButton: anyNamed('showIconInMainButton'), mainButtonTitle: anyNamed('mainButtonTitle'), showIconInSecondaryButton: anyNamed('showIconInSecondaryButton'), secondaryButtonTitle: anyNamed('secondaryButtonTitle'), showIconInAdditionalButton: anyNamed('showIconInAdditionalButton'), takesInput: anyNamed('takesInput'), barrierColor: anyNamed('barrierColor'), barrierLabel: anyNamed('barrierLabel'), customData: anyNamed('customData'), data: anyNamed('data'), description: anyNamed('description'), )).thenAnswer((realInvocation) => Future.value(showCustomSheetResponse ?? SheetResponse<T>())); locator.registerSingleton<BottomSheetService>(service); return service; } MockDialogService getAndRegisterDialogService() { _removeRegistrationIfExists<DialogService>(); final service = MockDialogService(); locator.registerSingleton<DialogService>(service); return service; } MockCreateNewUserService getAndRegisterCreateNewUserService() { _removeRegistrationIfExists<CreateNewUserService>(); final service = MockCreateNewUserService(); locator.registerSingleton<CreateNewUserService>(service); return service; } MockLoginServiceService getAndRegisterLoginServiceService() { _removeRegistrationIfExists<LoginServiceService>(); final service = MockLoginServiceService(); locator.registerSingleton<LoginServiceService>(service); return service; } MockFetchUserListService getAndRegisterFetchUserListService() { _removeRegistrationIfExists<FetchUserListService>(); final service = MockFetchUserListService(); locator.registerSingleton<FetchUserListService>(service); return service; } MockChatService getAndRegisterChatService() { _removeRegistrationIfExists<ChatService>(); final service = MockChatService(); locator.registerSingleton<ChatService>(service); return service; } // @stacked-mock-create void _removeRegistrationIfExists<T extends Object>() { if (locator.isRegistered<T>()) { locator.unregister<T>(); } }
0
mirrored_repositories/whatsapp-stacked-architecture/test
mirrored_repositories/whatsapp-stacked-architecture/test/services/fetch_user_list_service_test.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:fake_cloud_firestore/fake_cloud_firestore.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:whatsapp_stacked_architecture/app/app.locator.dart'; import '../helpers/test_helpers.dart'; void main() { final fakeFirebaseFirestore = FakeFirebaseFirestore(); group('FetchUserListServiceTest -', () { setUp(() => registerServices()); test( "must return an instance of QuerySnapshot on successful fetching from database", () async { final snapshot = await fakeFirebaseFirestore.collection("users").get(); expect(snapshot, isA<QuerySnapshot>()); }); tearDown(() => locator.reset()); }); }
0
mirrored_repositories/whatsapp-stacked-architecture/test
mirrored_repositories/whatsapp-stacked-architecture/test/services/create_new_user_service_test.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mock_exceptions/mock_exceptions.dart'; import 'package:whatsapp_stacked_architecture/app/app.locator.dart'; import 'package:firebase_auth_mocks/firebase_auth_mocks.dart'; import '../helpers/test_helpers.dart'; void main() async { group('CreateNewUserServiceTest -', () { final auth = MockFirebaseAuth(); setUp(() { registerServices(); }); test("must return an instance of UserCredential on successful API call", () async { final result = await auth.createUserWithEmailAndPassword( email: "[email protected]", password: "password"); expect(result, isA<UserCredential>()); }); test("must return FirebaseAuthException when wrong credential is given", () async { whenCalling(Invocation.method(#createUserWithEmailAndPassword, null)) .on(auth) .thenThrow(FirebaseAuthException(code: "invalid-email")); expect( () => auth.createUserWithEmailAndPassword( email: "agag", password: "Agdgd"), throwsA(FirebaseAuthException(code: "invalid-email"))); }); tearDown(() => locator.reset()); }); }
0
mirrored_repositories/whatsapp-stacked-architecture/test
mirrored_repositories/whatsapp-stacked-architecture/test/services/login_service_service_test.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:firebase_auth_mocks/firebase_auth_mocks.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mock_exceptions/mock_exceptions.dart'; import 'package:whatsapp_stacked_architecture/app/app.locator.dart'; import '../helpers/test_helpers.dart'; void main() async { final auth = MockFirebaseAuth(); group('LoginServiceServiceTest -', () { setUp(() => registerServices()); tearDown(() => locator.reset()); test("must return an instance of UserCredential on successful API call", () async { final result = await auth.signInWithEmailAndPassword( email: "[email protected]", password: "password"); expect(result, isA<UserCredential>()); }); }); test("must return FirebaseAuthException on error logging in", () async { whenCalling(Invocation.method(#signInWithEmailAndPassword, null)) .on(auth) .thenThrow(FirebaseAuthException(code: 'wrong-email')); expect( () => auth.signInWithEmailAndPassword(email: "agag", password: "Agdgd"), throwsA(FirebaseAuthException(code: "wrong-email"))); }); }
0
mirrored_repositories/whatsapp-stacked-architecture/test
mirrored_repositories/whatsapp-stacked-architecture/test/services/chat_service_test.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:fake_cloud_firestore/fake_cloud_firestore.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mock_exceptions/mock_exceptions.dart'; import 'package:whatsapp_stacked_architecture/app/app.locator.dart'; import '../helpers/test_helpers.dart'; void main() { final fakeFirebaseFirestore = FakeFirebaseFirestore(); const uid = "abc"; group('ChatServiceTest -', () { setUp(() { registerServices(); }); test("must return instance of query snapshot on successful fetch API call", () async { final snapshot = await fakeFirebaseFirestore .collection("path") .doc("chat-id") .collection("collectionPath") .get(); expect(snapshot, isA<QuerySnapshot>()); }); test('adds an entry in the database', () async { String expectedUserAfterDump = '{\n' ' "users": {\n' ' "abc": {\n' ' "name": "Bob",\n' ' "gender": "male"\n' ' }\n' ' }\n' '}'; final instance = FakeFirebaseFirestore(); final user = instance.collection('users').doc(uid); await user.set({'name': 'Bob', 'gender': "male"}); expect(instance.dump(), expectedUserAfterDump); }); test( "must return an instance of Document reference on successful API call to add entry in database", () async { final result = await fakeFirebaseFirestore .collection("path") .doc("chat-id") .collection("collectionPath") .add({}); expect(result, isA<DocumentReference>()); }); test("must return Exception on unsuccessful API call", () async { whenCalling(Invocation.method(#add, null)) .on(fakeFirebaseFirestore) .thenThrow(Exception("Error adding data")); expect( () => fakeFirebaseFirestore .collection("path") .doc("chat-id") .collection("collectionPath") .add({}), throwsA(Exception("Error adding data"))); }); tearDown(() => locator.reset()); }); }
0
mirrored_repositories/splash_screen_flutter
mirrored_repositories/splash_screen_flutter/lib/web_view.dart
import 'package:flutter/material.dart'; import 'package:webview_flutter/webview_flutter.dart'; class WebScreen extends StatefulWidget { @override _WebScreenState createState() => _WebScreenState(); } class _WebScreenState extends State<WebScreen> { @override Widget build(BuildContext context) { return Scaffold( body: SafeArea( child: WebView( initialUrl: 'https://github.com/siumhossain', ), ), ); } }
0
mirrored_repositories/splash_screen_flutter
mirrored_repositories/splash_screen_flutter/lib/main.dart
import 'dart:async'; import 'package:flutter/material.dart'; import 'web_view.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; void main() { runApp(MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData.dark(), home: FirstRoute(), )); } class FirstRoute extends StatefulWidget { @override _FirstRouteState createState() => _FirstRouteState(); } class _FirstRouteState extends State<FirstRoute> { @override void initState() { // TODO: implement initState super.initState(); Timer(Duration(seconds: 2),()=>Navigator.push(context,MaterialPageRoute(builder: (context) => WebScreen()),)); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('BasicWebView App',style: TextStyle( color: Colors.white, ),), ), body: SpinKitFadingCircle( color: Colors.greenAccent, size: 100.0, ), ); } } //Center( //child: ElevatedButton( //child: Text('Open route'), //onPressed: () {
0
mirrored_repositories/FlutterTraining-Sellthings
mirrored_repositories/FlutterTraining-Sellthings/lib/main.dart
import 'package:bvsik/models/user.dart'; import 'package:bvsik/screens/authenticate/register.dart'; import 'package:bvsik/screens/home/navigation_bar.dart'; import 'package:bvsik/screens/wrapper.dart'; import 'package:bvsik/services/auth.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:flare_splash_screen/flare_splash_screen.dart'; import 'package:flutter/services.dart'; Future<void> main() async { WidgetsFlutterBinding.ensureInitialized(); SystemChrome.setPreferredOrientations(<DeviceOrientation>[DeviceOrientation.portraitUp]) .then((_) async { runApp(MaterialApp( home: SplashScreen( 'assets/SplashSell.flr', MyApp(), startAnimation: 'start', backgroundColor: Colors.white, ))); }); } class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return StreamProvider<User>.value( value: AuthService().user, child: MaterialApp( home: Wrapper(), routes: <String, Widget Function(BuildContext)>{ AuthScreen.routeName: (BuildContext ctx) => AuthScreen(), NavigationBar.routeName: (BuildContext ctx) => NavigationBar(), }, ), ); } }
0
mirrored_repositories/FlutterTraining-Sellthings/lib
mirrored_repositories/FlutterTraining-Sellthings/lib/models/ItemModel.dart
import 'dart:io'; class ItemModel { ItemModel( {this.images, this.imagePath, this.name, this.price, this.description, this.date, this.shippingFees, this.author, this.state}); List<String> images; File imagePath; String name; String price; String description; String date; String shippingFees; String author; String state; }
0
mirrored_repositories/FlutterTraining-Sellthings/lib
mirrored_repositories/FlutterTraining-Sellthings/lib/models/ListItems.dart
import 'package:bvsik/models/ItemModel.dart'; List<ItemModel> it = <ItemModel>[ gnome, surface, bicycle, bose, fridge, gear, gearVr, guitar, iphoneX, piano, playstation, tablet ]; ItemModel gnome = ItemModel( images: <String>[ 'https://commentseruiner.com/32058-large_default/nain-de-jardin-i-m-sexy.jpg', ], name: 'Nain de jardin', price: '18.50', description: 'Ce nain de jardin est incroyable, encore plus beau en vrai', date: '2020-02-13T09:00:00Z', shippingFees: '3.24', author: 'Mike Lesgy', state: 'Bon Γ©tat'); ItemModel surface = ItemModel( images: <String>[ 'https://d1fmx1rbmqrxrr.cloudfront.net/cnet/optim/i/edit/2019/10/microsoft-surface-laptop-3-big__w770.jpg', ], name: 'Surface 3', price: '680', description: 'PC portable trΓ¨s peu utilisΓ©', date: '2020-02-13T09:00:00Z', shippingFees: '3.24', author: 'Gille Lafou', state: 'Comme neuf'); ItemModel playstation = ItemModel( images: <String>[ 'https://pic.clubic.com/v1/images/1711918/raw?width=1200&fit=max&hash=a7b5869dac0c9590341c92ee4dd0108c30e25916', 'https://cdn.eglobalcentral.fr/images/detailed/79/sony-playstation-4-ps4-slim-1tb-with-1pc-yibkt2-3.jpg' ], name: 'Playstation 4', price: '230', description: 'PS4 comme neuve fonctionne parfaitement', date: '2020-02-15T19:10:00Z', shippingFees: '6.00', author: 'Arthur kefa', state: 'Comme neuf'); ItemModel iphoneX = ItemModel( images: <String>[ 'https://media.paruvendu.fr/image/iphone-noir/WB15/7/9/WB157969024_1.jpeg' ], name: 'Iphone X - 256 Go', price: '750', description: 'Iphone X qui fonctionne parfaitement. Quelles traces de rayures.', date: '2020-04-02T13:17:00Z', shippingFees: '4.00', author: 'Lucie Pul', state: 'Bon Γ©tat'); ItemModel bicycle = ItemModel( images: <String>[ 'https://media.intersport.fr/is/image/intersportfr/55550__AKU_Q1?\$produit_l\$&\$product_grey\$', 'https://intersportfr.scene7.com/is/image/intersportfr/55550-1AKU_D1?\$produit_l\$&\$product_grey\$' ], name: 'VΓ©lo appartement - Cv 550 care', price: '199', description: 'Voici un vΓ©lo d\'appartement pour effectuer votre sport Γ  domicile', date: '2020-02-15T19:10:00Z', shippingFees: '6.00', author: 'Paul Velo', state: 'Comme neuf'); ItemModel piano = ItemModel( images: <String>[ 'https://www.thomann.de/pics/bdb/359614/9910221_800.jpg', 'https://images-na.ssl-images-amazon.com/images/I/61Z77pXWMlL._AC_SL1500_.jpg' ], name: 'Yamaha P45', price: '100', description: 'Piano numΓ©rique de chez Yamaha. Une touche est cassΓ© et ne fonctionne plus.', date: '2020-03-26-15T18:30:00Z', shippingFees: '6.00', author: 'Robert Terme', state: 'AbimΓ©'); ItemModel tablet = ItemModel( images: <String>[ 'https://www.grosbill.com/images.grosbill.com/imagesproduitnew/imagesgallery/BIG/204551.jpg', 'https://static.fnac-static.com/multimedia/Images/FR/NR/53/c9/51/5359955/1540-1/tsp20191022153220/Tablette-graphique-Wacom-Intuos-Pro-Small.jpg', 'https://boulanger.scene7.com/is/image/Boulanger/bfr_overlay?layer=comp&\$t1=&\$product_id=Boulanger/4949268620062_h_f_l_0&wid=350&hei=350' ], name: 'Tablette Wacom Intuos', price: '39', description: 'Tablette Graphique en excellent Γ©tat. Utile pour du graphisme.', date: '2020-03-29-15T13:23:00Z', shippingFees: '2.99', author: 'Julien Graphiste', state: 'Comme neuf'); ItemModel gearVr = ItemModel( images: <String>[ 'https://images-na.ssl-images-amazon.com/images/I/619VY7CqqkL._AC_SL1500_.jpg', 'https://images-na.ssl-images-amazon.com/images/I/61KMoivIjcL._AC_SX466_.jpg' ], name: 'Samsung Gear VR', price: '25', description: 'Excellent casque pour dΓ©buter en VR. Excellent Γ©tat', date: '2020-04-12-15T13:23:00Z', shippingFees: '3.50', author: 'Romain Gemvr', state: 'Comme neuf'); ItemModel fridge = ItemModel( images: <String>[ 'https://image.darty.com/gros_electromenager/refrigerateur-refrigerateur/refrigerateur_armoire/smeg_fab28rrd3_t1810014613830A_124134683.jpg', 'https://image.darty.com/gros_electromenager/refrigerateur-refrigerateur/refrigerateur_armoire/smeg_fab28rrd3_l1810014613830B_124131810.jpg' ], name: 'RΓ©frigirateur SMEG FAB28RRD3', price: '399', description: 'RΓ©frigirateur avec 1 porte. ProblΓ¨me avec le congΓ©lateur qui ne fonctionne plus.', date: '2020-04-16-15T11:11:00Z', shippingFees: '6.99', author: 'Louis Frigo', state: 'AbimΓ©'); ItemModel guitar = ItemModel( images: <String>[ 'https://media.paruvendu.fr/image/guitare-yamaha/WB15/4/4/WB154468386_1.jpeg' ], name: 'Guitare - Yamaha C70', price: '69', description: 'Super guitare. Les cordes viennent d\'Γͺtre changΓ©es.', date: '2020-04-20-15T19:39:00Z', shippingFees: '3.99', author: 'Arthur Guitariste', state: 'Comme neuf'); ItemModel bose = ItemModel( images: <String>[ 'https://d1fmx1rbmqrxrr.cloudfront.net/cnet/i/edit/2015/10/bose-soundlink-ii-3.jpg', 'https://d1fmx1rbmqrxrr.cloudfront.net/cnet/i/edit/2015/10/bose-soundlink-ii-1.jpg' ], name: 'Bose Soundlink 2', price: '149', description: 'Casque avec rΓ©duction de bruit. Excellent Γ©tat', date: '2020-04-28-15T19:54:00Z', shippingFees: '3.99', author: 'Nicolas Musique', state: 'Comme neuf'); ItemModel gear = ItemModel( images: <String>[ 'https://img.phonandroid.com/2016/08/samsung-gear-s3-prise-enmain.jpg' ], name: 'Samsung Gear S3', price: '99', description: 'Montre connectΓ©e Samsung. Aucune rayures et parfaitement fonctionnelle', date: '2020-03-12-15T18:59:00Z', shippingFees: '3.99', author: 'Matthieu Watch', state: 'Comme neuf');
0
mirrored_repositories/FlutterTraining-Sellthings/lib
mirrored_repositories/FlutterTraining-Sellthings/lib/models/user.dart
class User { User({ this.uid, this.pictureUrl = 'https://iupac.org/wp-content/uploads/2018/05/default-avatar.png', this.name = 'Anonymous'}); final String uid; final String pictureUrl; final String name; }
0
mirrored_repositories/FlutterTraining-Sellthings/lib
mirrored_repositories/FlutterTraining-Sellthings/lib/config/AppConfig.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; const Color primaryColor = Color.fromRGBO(255, 107, 107, 1); const Color primaryDarkTheme = Color.fromRGBO(41, 41, 41, 1); const Color secondaryDarkTheme = Color.fromRGBO(46, 46, 46, 1); const Color menuDarkTheme = Color.fromRGBO(29, 29, 29, 1); const Color veryDarkTheme = Color.fromRGBO(0, 0, 0, 1); const Color textDarkTheme = Color.fromRGBO(227, 227, 227, 1); const Color menuBackgroundColor = Colors.white; bool darkNightMode = false;
0
mirrored_repositories/FlutterTraining-Sellthings/lib
mirrored_repositories/FlutterTraining-Sellthings/lib/services/auth.dart
import 'package:bvsik/models/user.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:google_sign_in/google_sign_in.dart'; User finalUser = User(uid: null); class AuthService { final FirebaseAuth _auth = FirebaseAuth.instance; final GoogleSignIn googleSignIn = GoogleSignIn(); //create User() from FireBaseUser() User _userFromFirebaseUser(FirebaseUser user) { return user != null ? user.displayName != null ? User( name: user.displayName, uid: user.uid, pictureUrl: user.photoUrl) : User( uid: user.uid, ) : null; } //detect change user stream Stream<User> get user { return _auth.onAuthStateChanged .map((FirebaseUser user) => _userFromFirebaseUser(user)); } //signing Anon Future<dynamic> signInAnon() async { try { final AuthResult result = await _auth.signInAnonymously(); final FirebaseUser user = result.user; return _userFromFirebaseUser(user); } catch (e) { print(e.toString()); return null; } } //signing with email/password Future<dynamic> signInWithEmailPassword(String email, String password) async { try { print(email); print(password); final AuthResult result = await _auth.signInWithEmailAndPassword( email: email, password: password); final FirebaseUser user = result.user; return _userFromFirebaseUser(user); } catch (e) { print(e.toString()); return null; } } //register with email/password Future<dynamic> registerWithEmailPassword( String email, String password) async { try { final AuthResult result = await _auth.createUserWithEmailAndPassword( email: email, password: password); final FirebaseUser user = result.user; return _userFromFirebaseUser(user); } catch (e) { print(e.toString()); return null; } } //signOut Future<dynamic> signOut() async { try { return await _auth.signOut(); } catch (e) { print(e.toString()); return null; } } //signing with Google Future<User> signInWithGoogle() async { final GoogleSignInAccount googleSignInAccount = await googleSignIn.signIn(); final GoogleSignInAuthentication googleSignInAuthentication = await googleSignInAccount.authentication; final AuthCredential credential = GoogleAuthProvider.getCredential( accessToken: googleSignInAuthentication.accessToken, idToken: googleSignInAuthentication.idToken, ); final AuthResult authResult = await _auth.signInWithCredential(credential); final FirebaseUser user = authResult.user; assert(!user.isAnonymous); assert(await user.getIdToken() != null); final FirebaseUser currentUser = await _auth.currentUser(); assert(user.uid == currentUser.uid); print(user.displayName); finalUser = User( uid: user.uid, name: user.displayName, pictureUrl: user.photoUrl, ); return finalUser; } }
0
mirrored_repositories/FlutterTraining-Sellthings/lib
mirrored_repositories/FlutterTraining-Sellthings/lib/screens/wrapper.dart
import 'package:bvsik/models/user.dart'; import 'package:bvsik/screens/authenticate/authenticate.dart'; import 'package:bvsik/screens/home/navigation_bar.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class Wrapper extends StatelessWidget { @override Widget build(BuildContext context) { final User user = Provider.of<User>(context); //Auth wrapper return user == null ? Authenticate() : NavigationBar(); } }
0
mirrored_repositories/FlutterTraining-Sellthings/lib/screens
mirrored_repositories/FlutterTraining-Sellthings/lib/screens/authenticate/register.dart
import 'package:bvsik/config/AppConfig.dart'; import 'package:bvsik/services/auth.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; enum AuthMode { SignUp, Login } final AuthService _auth = AuthService(); class AuthScreen extends StatelessWidget { static const String routeName = '/auth'; @override Widget build(BuildContext context) { final Size deviceSize = MediaQuery.of(context).size; // final transformConfig = Matrix4.rotationZ(-8 * pi / 180); // transformConfig.translate(-10.0); return Scaffold( appBar: AppBar( backgroundColor: Colors.transparent, elevation: 0, iconTheme: IconThemeData(color: Colors.black), ), // resizeToAvoidBottomInset: false, body: Center( child: Column( children: <Widget>[ Container( margin: const EdgeInsets.only(top: 0), width: 175, child: Container( child: Image.asset( 'assets/logo.png', )), ), Padding( padding: const EdgeInsets.only(top: 15.0), child: Container( child: Hero( tag: 'registerSVG', child: SvgPicture.asset( 'assets/register.svg', width: MediaQuery.of(context).size.width * 0.2, ), ), ), ), const SizedBox( height: 30, ), Flexible( flex: deviceSize.width > 600 ? 2 : 1, child: const AuthCard(), ), ], ), ), ); } } class AuthCard extends StatefulWidget { const AuthCard({ Key key, }) : super(key: key); @override _AuthCardState createState() => _AuthCardState(); } class _AuthCardState extends State<AuthCard> { final GlobalKey<FormState> _formKey = GlobalKey(); AuthMode _authMode = AuthMode.Login; final Map<String, String> _authData = <String, String>{ 'email': '', 'password': '', 'firstname': '', 'lastname': '', }; bool _isLoading = false; final TextEditingController _passwordController = TextEditingController(); Future<void> _submit() async { if (!_formKey.currentState.validate()) { // Invalid! return; } _formKey.currentState.save(); setState(() { _isLoading = true; }); if (_authMode == AuthMode.Login) { final dynamic result = await _auth.signInWithEmailPassword( _authData['email'], _authData['password']); if (result == null) { AlertDialog( title: const Text('Alert Dialog title'), content: const Text('Alert Dialog body'), actions: <Widget>[ // usually buttons at the bottom of the dialog FlatButton( child: const Text('Close'), onPressed: () { Navigator.of(context).pop(); }, ), ], ); } else { Navigator.of(context).pop(); } } else { await _auth.registerWithEmailPassword( _authData['email'], _authData['password']); Navigator.of(context).pop(); // Sign user up } setState(() { _isLoading = false; }); } void _switchAuthMode() { if (_authMode == AuthMode.Login) { setState(() { _authMode = AuthMode.SignUp; }); } else { setState(() { _authMode = AuthMode.Login; }); } } @override Widget build(BuildContext context) { final Size deviceSize = MediaQuery.of(context).size; return SingleChildScrollView( child: Column(children: <Widget>[ Container( height: _authMode == AuthMode.SignUp ? 520 : 460, constraints: BoxConstraints( minHeight: _authMode == AuthMode.SignUp ? 520 : 460), width: deviceSize.width * 0.90, padding: const EdgeInsets.all(16.0), child: Form( key: _formKey, child: SingleChildScrollView( child: Column( children: <Widget>[ TextFormField( decoration: const InputDecoration(labelText: 'E-Mail'), keyboardType: TextInputType.emailAddress, validator: (String value) { if (value.isEmpty || !value.contains('@')) { return 'Invalid email!'; } return null; }, onSaved: (String value) { _authData['email'] = value; }, ), TextFormField( decoration: const InputDecoration(labelText: 'Password'), obscureText: true, controller: _passwordController, validator: (String value) { if (value.isEmpty || value.length < 6) { return 'Password is too short!'; } return null; }, onSaved: (String value) { _authData['password'] = value; }, ), if (_authMode == AuthMode.SignUp) TextFormField( enabled: _authMode == AuthMode.SignUp, decoration: const InputDecoration(labelText: 'Confirm Password'), obscureText: true, validator: _authMode == AuthMode.SignUp ? (String value) { if (value != _passwordController.text) { return 'Passwords do not match!'; } return null; } : null, ), if (_authMode == AuthMode.SignUp) TextFormField( decoration: const InputDecoration(labelText: 'First Name'), validator: (String value) { if (value.isEmpty) { return 'Invalid name !'; } return null; }, onSaved: (String value) { _authData['firstname'] = value; }, ), if (_authMode == AuthMode.SignUp) TextFormField( decoration: const InputDecoration(labelText: 'Last Name'), validator: (String value) { if (value.isEmpty) { return 'Invalid name !'; } return null; }, onSaved: (String value) { _authData['lastname'] = value; }, ), const SizedBox( height: 20, ), if (_isLoading) const CircularProgressIndicator() else RaisedButton( child: Text( _authMode == AuthMode.Login ? 'LOGIN' : 'SIGN UP'), onPressed: _submit, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(30), ), padding: const EdgeInsets.symmetric( horizontal: 30.0, vertical: 8.0), color: primaryColor, textColor: Theme.of(context).primaryTextTheme.button.color, ), FlatButton( child: Text( '${_authMode == AuthMode.Login ? 'SIGNUP' : 'LOGIN'} INSTEAD'), onPressed: _switchAuthMode, padding: const EdgeInsets.symmetric( horizontal: 30.0, vertical: 4), materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, textColor: primaryColor, ), ], ), ), ), ), ]), ); } }
0
mirrored_repositories/FlutterTraining-Sellthings/lib/screens
mirrored_repositories/FlutterTraining-Sellthings/lib/screens/authenticate/authenticate.dart
import 'package:bvsik/screens/authenticate/social_signin.dart'; import 'package:flutter/material.dart'; class Authenticate extends StatefulWidget { @override _AuthenticateState createState() => _AuthenticateState(); } class _AuthenticateState extends State<Authenticate> { @override Widget build(BuildContext context) { return Container( child: SignIn(), ); } }
0
mirrored_repositories/FlutterTraining-Sellthings/lib/screens
mirrored_repositories/FlutterTraining-Sellthings/lib/screens/authenticate/social_signin.dart
import 'package:bvsik/config/AppConfig.dart'; import 'package:bvsik/screens/authenticate/register.dart'; import 'package:bvsik/services/auth.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; class SignIn extends StatefulWidget { @override State<StatefulWidget> createState() => _SignInState(); } class _SignInState extends State<SignIn> { final Widget _descText = RichText( text: TextSpan( style: TextStyle(color: Colors.black, fontSize: 18), children: <TextSpan>[ const TextSpan(text: 'Vendez ou acheter '), TextSpan( text: 'facilement', style: TextStyle(fontWeight: FontWeight.bold)), const TextSpan(text: ' vos objets\ngrΓ’ce Γ  '), TextSpan( text: 'Sell', style: TextStyle(fontWeight: FontWeight.bold, color: primaryColor)), TextSpan( text: 'Things', style: TextStyle(fontWeight: FontWeight.bold)), const TextSpan(text: '\nRejoignez-nous au plus vite !'), ], ), softWrap: true, overflow: TextOverflow.fade, textAlign: TextAlign.center); final AuthService _auth = AuthService(); @override Widget build(BuildContext context) { return WillPopScope( child: Scaffold( body: Center( child: Column( children: <Widget>[ Container( margin: const EdgeInsets.only(top: 70), width: 175, child: Container( child: Image.asset( 'assets/logo.png', )), ), Padding( padding: const EdgeInsets.only(top: 25.0), child: Container( child: Hero( tag: 'registerSVG', child: SvgPicture.asset( 'assets/register.svg', width: MediaQuery.of(context).size.width * 0.6, ), ), ), ), _desc(), Container( padding: const EdgeInsets.only(top: 20.0), child: Container()), _buildSocialSignIn('CONNEXION AVEC GOOGLE', _auth.signInWithGoogle), _buildSocialSignIn('SE CONNECTER / S\'INSCRIRE', registerSignIn), _buildSocialSignIn('CONTINUER SANS SE CONNECTER', signInAnonymous, outlineButton: true), ], ), ), ), onWillPop: () async => false); } Widget _desc() { return Container( padding: const EdgeInsets.only(top: 50.0), child: Column( children: <Widget>[_descText], ), ); } Widget _buildSocialSignIn(String label, void Function() handler, {bool outlineButton = false}) { return Container( width: MediaQuery.of(context).size.width * 0.7, child: outlineButton ? OutlineButton( child: Text( label, style: TextStyle(fontWeight: FontWeight.bold, color: primaryColor), ), borderSide: BorderSide(color: primaryColor), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(5.0)), onPressed: handler, ) : RaisedButton( child: Text( label, style: TextStyle(fontWeight: FontWeight.bold, color: Colors.white), ), color: primaryColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(5.0)), onPressed: handler, ), ); } Future<String> signInAnonymous() async { final dynamic result = await _auth.signInAnon(); if (result == null) { print('Error User signin'); } else { print('User signin'); print(result.uid); } return 'Ok'; } String registerSignIn() { Navigator.of(context).pushNamed( AuthScreen.routeName, ); return 'Ok'; } }
0
mirrored_repositories/FlutterTraining-Sellthings/lib/screens
mirrored_repositories/FlutterTraining-Sellthings/lib/screens/product/ProductPage.dart
import 'package:carousel_slider/carousel_slider.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:bvsik/models/ItemModel.dart'; import 'package:bvsik/config/AppConfig.dart'; import 'package:bvsik/models/ListItems.dart'; class ProductPage extends StatefulWidget { const ProductPage({@required this.item, @required this.index}); final ItemModel item; final int index; @override State<StatefulWidget> createState() => _ProductPage(); } List<T> map<T>(List<dynamic> list, Function handler) { final List<T> result = <T>[]; for (int i = 0; i < list.length; i++) { result.add(handler(i, list[i]) as T); } return result; } class _ProductPage extends State<ProductPage> { int _currentImage = 0; List<Widget> child; @override void initState() { super.initState(); if (widget.item.images != null) { child = map<Widget>( _getImages(), (int index, String i) { return Container( margin: const EdgeInsets.all(0), child: ClipRRect( borderRadius: const BorderRadius.all(Radius.circular(5.0)), child: Stack(children: <Widget>[ Image.network(i, fit: BoxFit.cover, width: 1000.0), Positioned( bottom: 0.0, left: 0.0, right: 0.0, child: Container( decoration: BoxDecoration( gradient: LinearGradient( colors: const <Color>[ Color.fromARGB(200, 0, 0, 0), Color.fromARGB(0, 0, 0, 0) ], begin: Alignment.bottomCenter, end: Alignment.topCenter, ), ), padding: const EdgeInsets.symmetric( vertical: 10.0, horizontal: 20.0), ), ), ]), ), ); }, ).toList(); } } List<String> _getImages() { return widget.item.images; } @override Widget build(BuildContext context) { return SafeArea( child: Scaffold( body: Container( color: darkNightMode ? menuDarkTheme : Colors.white, child: ListView( children: <Widget>[ if (widget.item.images == null) imageWidget() else carouselWidget(), authorWidget(), itemHeaderWidget(), buyButtonWidget() ], ), ), ), ); } Widget imageWidget() { return Stack( children: <Widget>[ Hero( tag: 'hero' + widget.index.toString(), child: Image.file( widget.item.imagePath, fit: BoxFit.cover, width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height * 0.5, ), ), Container(child: const BackButton()), ], ); } Widget buyButtonWidget() { return Column( children: <Widget>[ Padding( padding: const EdgeInsets.only(top: 10.0), child: Container( width: MediaQuery.of(context).size.width * 0.7, child: RaisedButton( child: Text( 'ACHETER', style: TextStyle(fontWeight: FontWeight.bold, color: Colors.white), ), color: primaryColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(5.0)), onPressed: () { // _loginPressed(context); }, ), ), ), ], ); } Widget itemHeaderWidget() { return Padding( padding: const EdgeInsets.only(left: 20.0, top: 15), child: ListView( physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, children: <Widget>[ Text(widget.item.name, style: TextStyle( fontWeight: FontWeight.w500, fontSize: 18, color: darkNightMode ? textDarkTheme : Colors.black)), Padding( padding: const EdgeInsets.only(top: 4.0, bottom: 2.0), child: Text(widget.item.state, style: TextStyle( fontWeight: FontWeight.w300, fontSize: 18, color: darkNightMode ? Colors.white70 : Colors.grey, )), ), Padding( padding: const EdgeInsets.only(bottom: 8.0), child: Text(widget.item.description, style: TextStyle( fontWeight: FontWeight.w300, fontSize: 18, color: darkNightMode ? textDarkTheme : Colors.black)), ), RichText( text: TextSpan( style: TextStyle( color: darkNightMode ? textDarkTheme : Colors.black), children: <TextSpan>[ TextSpan( text: '${widget.item.price} €', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 18, color: darkNightMode ? textDarkTheme : Colors.black)), TextSpan( text: ' + ${widget.item.shippingFees} € de frais de port', style: TextStyle( fontWeight: FontWeight.bold, color: primaryColor, fontSize: 12)) ])), ], ), ); } bool isInfiniteScroll() { if (widget.item.images.length > 1) { return true; } return false; } Widget carouselWidget() { return Stack( children: <Widget>[ CarouselSlider( enableInfiniteScroll: isInfiniteScroll(), height: MediaQuery.of(context).size.height * 0.5, autoPlay: false, viewportFraction: 1.0, aspectRatio: MediaQuery.of(context).size.aspectRatio, onPageChanged: (int index) { setState(() { _currentImage = index; }); }, items: _getImages().map( (String url) { return Container( child: ClipRRect( borderRadius: const BorderRadius.all(Radius.circular(0.0)), child: Hero( tag: 'hero' + widget.index.toString(), child: Image.network( url, fit: BoxFit.cover, width: MediaQuery.of(context).size.width, ), ), ), ); }, ).toList(), ), Container(child: const BackButton()), if (widget.item.images.length > 1) Positioned( top: MediaQuery.of(context).size.height * 0.5 - 20, left: MediaQuery.of(context).size.width * 0.5 - (12 * widget.item.images.length / 2), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: map<Widget>( child, (int index, dynamic url) { return Container( width: 12.0, height: 8.0, decoration: BoxDecoration( shape: BoxShape.circle, color: _currentImage == index ? Colors.white : Colors.grey), ); }, ), ), ) else Container(), ], ); } Widget authorWidget() { return Container( height: MediaQuery.of(context).size.height * 0.09, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Padding( padding: const EdgeInsets.only(left: 20.0), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Row( children: <Widget>[ CircleAvatar( backgroundImage: getImage(), ), Padding( padding: const EdgeInsets.only(left: 15.0), child: Text( widget.item.author, style: TextStyle( fontWeight: FontWeight.bold, color: darkNightMode ? textDarkTheme : Colors.black), ), ) ], ) ], ), ), Padding( padding: const EdgeInsets.only(right: 20.0), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ RichText( text: TextSpan( style: TextStyle( color: darkNightMode ? textDarkTheme : Colors.black), children: <TextSpan>[ TextSpan( text: getNbrOffers().toString(), style: TextStyle( color: primaryColor, fontWeight: FontWeight.bold)), TextSpan( text: getNbrOffers() > 1 ? ' annonces en cours' : ' annonce en cours') ])) ], ), ) ], ), decoration: const BoxDecoration( border: Border( bottom: BorderSide(width: 0.5, color: Colors.grey), ), )); } ImageProvider<dynamic> getImage() { if (widget.item.images == null) return FileImage(widget.item.imagePath); else return NetworkImage(widget.item.images[0]); } int getNbrOffers() { int res = 0; for (int i = 0; i < it.length; i++) { if (it[i].author == widget.item.author) { res++; } } return res; } }
0
mirrored_repositories/FlutterTraining-Sellthings/lib/screens
mirrored_repositories/FlutterTraining-Sellthings/lib/screens/product/AddProduct.dart
import 'dart:io'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:image_picker_gallery_camera/image_picker_gallery_camera.dart'; import 'package:bvsik/config/AppConfig.dart'; import 'package:bvsik/models/ItemModel.dart'; import 'package:bvsik/models/ListItems.dart'; import 'package:bvsik/models/user.dart'; import 'package:provider/provider.dart'; class AddProduct extends StatefulWidget { @override State<StatefulWidget> createState() => _AddProduct(); } class _AddProduct extends State<AddProduct> { File _image; final TextEditingController _titleController = TextEditingController(); final TextEditingController _descController = TextEditingController(); final TextEditingController _priceController = TextEditingController(); final TextEditingController _fdpController = TextEditingController(); final TextEditingController _stateController = TextEditingController(); Future<void> getImage(ImgSource source) async { final File image = await ImagePickerGC.pickImage( context: context, source: source, cameraIcon: Icon( Icons.add, color: Colors.red, ), ) as File; setState(() { _image = image; }); } @override Widget build(BuildContext context) { final User user = Provider.of<User>(context); return SafeArea( child: Scaffold( body: Container( color: darkNightMode ? menuDarkTheme : Colors.white, child: Padding( padding: const EdgeInsets.all(10.0), child: ListView( children: <Widget>[ header(), addPhotos(), title(), desc(), state(), price(), sendButton(user), ], ), ), ), ), ); } Widget header() { return Container( child: Row( children: <Widget>[ Container(child: const BackButton()), Center( child: Text( 'Vendez votre produit', style: TextStyle( fontSize: 20, color: darkNightMode ? textDarkTheme : Colors.black), ), ) ], ), ); } Widget addPhotos() { return Padding( padding: const EdgeInsets.only(top: 15.0), child: Center( child: SingleChildScrollView( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Container( child: RaisedButton( onPressed: () => getImage(ImgSource.Both), color: primaryColor, child: Text( 'Ajouter une photo'.toUpperCase(), style: const TextStyle(color: Colors.white), ), ), ), if (_image != null) Padding( padding: const EdgeInsets.only(top: 15.0), child: Container( child: Image.file(_image), constraints: const BoxConstraints(maxWidth: 200), ), ) else Container(), ], ), ), ), ); } Widget title() { return Container( child: TextField( controller: _titleController, cursorColor: primaryColor, decoration: InputDecoration( hintText: 'Titre', hintStyle: TextStyle( color: darkNightMode ? Colors.white60 : Colors.black), labelText: 'Titre', labelStyle: const TextStyle(color: primaryColor), ), style: TextStyle(color: darkNightMode ? textDarkTheme : Colors.black), ), ); } Widget desc() { return Container( child: TextField( controller: _descController, cursorColor: primaryColor, decoration: InputDecoration( hintText: 'Description', hintStyle: TextStyle( color: darkNightMode ? Colors.white60 : Colors.black), labelText: 'Description', labelStyle: const TextStyle(color: primaryColor), ), style: TextStyle(color: darkNightMode ? textDarkTheme : Colors.black), ), ); } Widget state() { return Container( child: TextField( controller: _stateController, cursorColor: primaryColor, decoration: InputDecoration( hintText: 'Ex: neuf, comme neuf, bon Γ©tat, en l\'Γ©tat...', hintStyle: TextStyle( color: darkNightMode ? Colors.white60 : Colors.black), labelText: 'Etat', labelStyle: const TextStyle(color: primaryColor), ), style: TextStyle(color: darkNightMode ? textDarkTheme : Colors.black), ), ); } Widget price() { return ListView( shrinkWrap: true, children: <Widget>[ Container( child: TextField( controller: _priceController, cursorColor: primaryColor, decoration: InputDecoration( hintText: 'Prix', hintStyle: TextStyle( color: darkNightMode ? Colors.white60 : Colors.black), labelText: 'Prix', labelStyle: const TextStyle(color: primaryColor), ), keyboardType: TextInputType.number, style: TextStyle(color: darkNightMode ? textDarkTheme : Colors.black), ), ), Container( child: TextField( controller: _fdpController, cursorColor: primaryColor, decoration: InputDecoration( hintText: 'Frais de port', hintStyle: TextStyle( color: darkNightMode ? Colors.white60 : Colors.black), labelText: 'Frais de port', labelStyle: const TextStyle(color: primaryColor), ), keyboardType: TextInputType.number, style: TextStyle(color: darkNightMode ? textDarkTheme : Colors.black), ), ), ], ); } Widget sendButton(User user) { return Padding( padding: const EdgeInsets.only(top: 20.0), child: Container( child: RaisedButton( onPressed: () => isReady() ? sellThing(user) : null, color: isReady() ? primaryColor : Colors.grey, child: Text( 'Mettre en vente'.toUpperCase(), style: const TextStyle(color: Colors.white), ), ), ), ); } bool isReady() { if (_titleController.text.isNotEmpty && _descController.text.isNotEmpty && _priceController.text.isNotEmpty && _stateController.text.isNotEmpty && _fdpController.text.isNotEmpty && _image != null) return true; else return false; } void sellThing(User user) { final ItemModel newItem = ItemModel( imagePath: _image, name: _titleController.text, description: _descController.text, price: _priceController.text, shippingFees: _fdpController.text, state: _stateController.text, author: user.name ?? 'Jack Leborgne'); it.insert(0, newItem); Navigator.pop(context); } }
0
mirrored_repositories/FlutterTraining-Sellthings/lib/screens
mirrored_repositories/FlutterTraining-Sellthings/lib/screens/home/navigation_bar.dart
import 'package:bvsik/config/AppConfig.dart'; import 'package:bvsik/screens/home/homepage/HomePage.dart'; import 'package:bvsik/screens/home/profile/profile.dart'; import 'package:flutter/material.dart'; class NavigationBar extends StatefulWidget { static const String routeName = '/navigation'; @override State<StatefulWidget> createState() => _NavigationBar(); } class _NavigationBar extends State<NavigationBar> { int _selectedIndex = 0; final List<Widget> navBar = <Widget>[ HomePage(), ProfilePage() ]; void _onItemTapped(int index) { setState(() { _selectedIndex = index; }); } @override Widget build(BuildContext context) { return Scaffold( bottomNavigationBar: BottomNavigationBar( items: const <BottomNavigationBarItem>[ BottomNavigationBarItem( icon: Icon(Icons.home), title: Text('Accueil'), ), BottomNavigationBarItem( icon: Icon(Icons.person), title: Text('Profil'), ), ], currentIndex: _selectedIndex, selectedItemColor: primaryColor, unselectedItemColor: darkNightMode ? textDarkTheme : Colors.black, backgroundColor: darkNightMode ? menuDarkTheme : Colors.white, onTap: _onItemTapped, ), body: navBar[_selectedIndex], ); } }
0
mirrored_repositories/FlutterTraining-Sellthings/lib/screens/home
mirrored_repositories/FlutterTraining-Sellthings/lib/screens/home/profile/profile_drawer.dart
import 'package:bvsik/config/AppConfig.dart'; import 'package:bvsik/screens/home/navigation_bar.dart'; import 'package:flutter/material.dart'; import 'package:bvsik/services/auth.dart'; class MainDrawer extends StatelessWidget { Widget buildListTile(String title, IconData icon, Function tapHandler) { return ListTile( leading: Icon(icon, size: 20, color: darkNightMode ? textDarkTheme : Colors.black), title: Text( title, style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, color: darkNightMode ? textDarkTheme : Colors.black, ), ), onTap: () => tapHandler(), ); } final AuthService _auth = AuthService(); @override Widget build(BuildContext context) { final List<Widget> aboutBoxChildren = <Widget>[ const Text('SellThings, l app inutile qu il vous faut !'), ]; return Drawer( child: Container( color: darkNightMode ? menuDarkTheme : Colors.white, child: Column( children: <Widget>[ Container( height: (MediaQuery.of(context).size.height - AppBar().preferredSize.height - MediaQuery.of(context).padding.top) * 0.12, width: double.infinity, padding: EdgeInsets.only( top: (MediaQuery.of(context).size.height - AppBar().preferredSize.height - MediaQuery.of(context).padding.top) * 0.04, ), alignment: Alignment.center, color: darkNightMode ? menuDarkTheme : Colors.white, child: darkNightMode ? Image.asset( 'assets/logoWhite.png', ) : Image.asset( 'assets/logo.png', ), ), SizedBox( height: (MediaQuery.of(context).size.height - AppBar().preferredSize.height - MediaQuery.of(context).padding.top) * 0.02, ), buildListTile('Dark Knight Mode', Icons.brightness_2, () { darkNightMode = !darkNightMode; Navigator.of(context) .pushReplacementNamed(NavigationBar.routeName); }), buildListTile('Se dΓ©connecter', Icons.exit_to_app, () async { await _auth.signOut(); }), Expanded( child: Align( alignment: Alignment.bottomCenter, child: AboutListTile( child: Text( 'CrΓ©dits', style: TextStyle( fontSize: 18, color: darkNightMode ? textDarkTheme : Colors.black, fontWeight: FontWeight.bold, ), ), icon: Icon(Icons.info, color: darkNightMode ? textDarkTheme : Colors.black), applicationIcon: Image.asset( 'assets/logo.png', height: (MediaQuery.of(context).size.height - AppBar().preferredSize.height - MediaQuery.of(context).padding.top) * 0.07, width: (MediaQuery.of(context).size.height - AppBar().preferredSize.height - MediaQuery.of(context).padding.top) * 0.13, ), applicationName: 'SellThings', applicationVersion: '1.0.0', applicationLegalese: 'by Enzo CONTY, Hadrien GOUTAS, Romain KANIA', aboutBoxChildren: aboutBoxChildren, ), ), ), SizedBox( height: (MediaQuery.of(context).size.height - AppBar().preferredSize.height - MediaQuery.of(context).padding.top) * 0.03, ) ], ), ), ); } }
0
mirrored_repositories/FlutterTraining-Sellthings/lib/screens/home
mirrored_repositories/FlutterTraining-Sellthings/lib/screens/home/profile/profile.dart
import 'package:bvsik/config/AppConfig.dart'; import 'package:bvsik/models/ItemModel.dart'; import 'package:bvsik/models/ListItems.dart'; import 'package:bvsik/models/user.dart'; import 'package:bvsik/screens/home/profile/profile_drawer.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class ProfilePage extends StatefulWidget { @override State<StatefulWidget> createState() => _ProfilePage(); } class _ProfilePage extends State<ProfilePage> { List<ItemModel> profileOffers = <ItemModel>[]; User user = User(); @override void initState() { for (int i = 0; i < it.length; i++) { if (it[i].author == user.name) { profileOffers.add(it[i]); } } super.initState(); } @override Widget build(BuildContext context) { user = Provider.of<User>(context); return SafeArea( child: Scaffold( appBar: AppBar( backgroundColor: primaryColor, elevation: 0, ), endDrawer: MainDrawer(), body: Stack( children: <Widget>[ Container( height: MediaQuery.of(context).size.height, color: primaryColor, child: ListView( physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, children: <Widget>[ Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Container( child: CircleAvatar( radius: 40, backgroundImage: NetworkImage(user.pictureUrl), ), ), ]), Padding( padding: const EdgeInsets.only(top: 15.0), child: Center( child: Text( user.name, style: TextStyle( fontWeight: FontWeight.w700, fontSize: 20, color: Colors.white), )), ), ], ), ), Padding( padding: EdgeInsets.only( top: (MediaQuery.of(context).size.height - MediaQuery.of(context).padding.top) * 0.20, ), child: ClipRRect( borderRadius: const BorderRadius.only( topLeft: Radius.circular(20), topRight: Radius.circular(20)), child: Container( height: MediaQuery.of(context).size.height, color: darkNightMode ? menuDarkTheme : Colors.white, child: Column( children: <Widget>[_titleOffersWidget(), _myOffersWidget()], ), ), ), ) ], ), ), ); } Widget _titleOffersWidget() { return Padding( padding: const EdgeInsets.only(top: 20.0, left: 10), child: RichText( text: TextSpan( text: 'Mes annonces', style: TextStyle( color: darkNightMode ? textDarkTheme : Colors.black, fontWeight: FontWeight.bold, fontSize: 25), ), ), ); } Widget _myOffersWidget() { if (profileOffers.isNotEmpty) { return Container( height: (MediaQuery.of(context).size.height - AppBar().preferredSize.height - MediaQuery.of(context).padding.top) * 0.60, padding: const EdgeInsets.only(top: 15.0), child: ListView.builder( shrinkWrap: true, itemCount: profileOffers.length, itemBuilder: (BuildContext context, int index) => _offerCard(profileOffers[index])), ); } else { return Container( height: (MediaQuery.of(context).size.height - AppBar().preferredSize.height - MediaQuery.of(context).padding.top) * 0.60, width: MediaQuery.of(context).size.width, padding: const EdgeInsets.only(top: 15.0), child: Center( child: Text( 'Vous n\'avez pas encore postΓ© d\'annonce !', style: TextStyle( fontSize: 18, color: darkNightMode ? textDarkTheme : Colors.black), )), ); } } Widget _offerCard(ItemModel item) { return Card( elevation: 2, margin: const EdgeInsets.only(right: 15, left: 15, bottom: 15), child: Row( children: <Widget>[ Column( children: <Widget>[ if (item.images != null) Image.network(item.images[0], width: 110, height: 110, fit: BoxFit.cover) else Image.file(item.imagePath, width: 110, height: 110, fit: BoxFit.cover), ], ), Container( height: 110, width: MediaQuery.of(context).size.width - MediaQuery.of(context).padding.right - 140, padding: const EdgeInsets.only(left: 10, top: 10), color: darkNightMode ? secondaryDarkTheme : Colors.white, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text('${item.name}', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 16, color: darkNightMode ? Colors.white : Colors.black)), Text( item.description.length > 70 ? '${item.description.substring(0, 70)}...' : '${item.description}', style: TextStyle( color: darkNightMode ? textDarkTheme : Colors.black), ), // SizedBox(height: 30,), Expanded( child: Container( padding: const EdgeInsets.only(bottom: 10), alignment: Alignment.bottomLeft, child: Text('${item.price}€', style: TextStyle( color: primaryColor, fontWeight: FontWeight.w600, )), ), ) ], ), ) ], ), ); } }
0
mirrored_repositories/FlutterTraining-Sellthings/lib/screens/home
mirrored_repositories/FlutterTraining-Sellthings/lib/screens/home/homepage/homepage.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:bvsik/config/AppConfig.dart'; import 'package:bvsik/models/ItemModel.dart'; import 'package:infinite_widgets/infinite_widgets.dart'; import 'package:bvsik/screens/product/ProductPage.dart'; import 'package:bvsik/screens/product/AddProduct.dart'; import 'package:bvsik/models/ListItems.dart'; class HomePage extends StatefulWidget { @override State<StatefulWidget> createState() => _HomePage(); } class _HomePage extends State<HomePage> { int nbrItems = 0; final List<ItemModel> _listItem = <ItemModel>[]; @override void initState() { addItems(); super.initState(); } void addItems() { int i = 0; while (nbrItems < it.length && i < 8) { setState(() { _listItem.add(it[nbrItems++]); i++; }); } if (nbrItems >= it.length) { nbrItems = 0; } } ImageProvider<dynamic> getImage(int index) { if (_listItem[index].images == null) return FileImage(_listItem[index].imagePath); else return NetworkImage(_listItem[index].images[0]); } Widget _tileItem(int index) { return Container( color: darkNightMode ? menuDarkTheme : Colors.white, child: Padding( padding: const EdgeInsets.all(4.0), child: Column( children: <Widget>[ Padding( padding: const EdgeInsets.only(bottom: 8.0), child: Row( children: <Widget>[ CircleAvatar( backgroundImage: getImage(index), radius: 15, ), Padding( padding: const EdgeInsets.only(left: 8.0), child: Text( _listItem[index].author, style: TextStyle( fontWeight: FontWeight.w300, color: darkNightMode ? textDarkTheme : Colors.black, ), ), ), ], ), ), GestureDetector( child: Hero( tag: 'hero' + index.toString(), child: _listItem[index].images == null ? Image.file( _listItem[index].imagePath, fit: BoxFit.cover, height: MediaQuery.of(context).size.height * 0.3, ) : Image.network( _listItem[index].images[0], fit: BoxFit.cover, height: MediaQuery.of(context).size.height * 0.3, ), ), onTap: () { Navigator.push(context, MaterialPageRoute<void>(builder: (_) { return ProductPage( item: _listItem[index], index: index, ); })); }, ), Padding( padding: const EdgeInsets.only(left: 8.0, top: 8.0), child: ListView( physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, children: <Widget>[ Text(_listItem[index].price + '€', style: TextStyle( fontWeight: FontWeight.w700, color: darkNightMode ? textDarkTheme : Colors.black, )), Text(_listItem[index].name, style: TextStyle( fontWeight: FontWeight.w400, color: darkNightMode ? textDarkTheme : Colors.black, )), Text(_listItem[index].state, style: TextStyle( fontWeight: FontWeight.w300, color: darkNightMode ? Colors.white70 : Colors.grey, )), ], ), ) ], ), ), ); } @override Widget build(BuildContext context) { return Scaffold( body: InfiniteGridView( gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent( maxCrossAxisExtent: MediaQuery.of(context).size.height * 0.4, mainAxisSpacing: 0.0, crossAxisSpacing: 0.0, childAspectRatio: 0.5, ), itemBuilder: (BuildContext context, int index) { return _tileItem(index); }, itemCount: _listItem.length, hasNext: _listItem.length < 200, nextData: loadNextData, ), floatingActionButton: FloatingActionButton( onPressed: () { Navigator.push(context, MaterialPageRoute<void>(builder: (_) { return AddProduct(); })); }, child: Icon(Icons.add), backgroundColor: primaryColor, ), ); } void loadNextData() { addItems(); } }
0
mirrored_repositories/FlutterTraining-Sellthings
mirrored_repositories/FlutterTraining-Sellthings/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:bvsik/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/evil_word
mirrored_repositories/evil_word/lib/main.dart
import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:evil_word/data/data_source/joke_data_source_impl.dart'; import 'package:evil_word/data/repository/joke_repository_impl.dart'; import 'package:evil_word/presentation/home_page/state/joke_bloc/joke_bloc.dart'; import 'package:evil_word/presentation/home_page/state/network_connection_cubit/internet_cubit.dart'; import 'package:evil_word/presentation/home_page/home_page.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; void main() { WidgetsFlutterBinding.ensureInitialized(); SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MultiBlocProvider( providers: [ BlocProvider( create: (context) => JokeBloc( jokeRepository: JokeRepositoryImpl( jokeDataSource: JokeDataSourceImpl(), ), ), ), BlocProvider( create: (context) => InternetCubit( connectivity: Connectivity(), ), ), ], child: MaterialApp( debugShowCheckedModeBanner: false, title: '🀬 Evil word', theme: ThemeData( useMaterial3: true, textTheme: TextTheme( titleLarge: TextStyle( color: Theme.of(context).colorScheme.secondary, ), ), visualDensity: VisualDensity.adaptivePlatformDensity, colorSchemeSeed: Colors.red, ), home: const HomePage(), ), ); } }
0
mirrored_repositories/evil_word/lib/data
mirrored_repositories/evil_word/lib/data/repository/joke_repository_impl.dart
import 'package:evil_word/data/data_source/joke_data_source.dart'; import 'package:evil_word/domain/entities/joke_entity.dart'; import 'package:evil_word/domain/repository/joke_repository.dart'; class JokeRepositoryImpl extends JokeRepository { JokeRepositoryImpl({required JokeDataSource jokeDataSource}) : _jokeDataSource = jokeDataSource; final JokeDataSource _jokeDataSource; @override Future<JokeEntity> fetchJoke() async { final rawJoke = await _jokeDataSource.fetchJoke(); return rawJoke.toEntity(); } }
0
mirrored_repositories/evil_word/lib/data
mirrored_repositories/evil_word/lib/data/data_source/joke_data_source.dart
import 'package:evil_word/data/dto/joke_dto.dart'; abstract class JokeDataSource { Future<JokeDTO> fetchJoke(); }
0
mirrored_repositories/evil_word/lib/data
mirrored_repositories/evil_word/lib/data/data_source/joke_data_source_impl.dart
import 'package:dio/dio.dart'; import 'package:evil_word/data/dto/joke_dto.dart'; import 'package:evil_word/data/data_source/joke_data_source.dart'; class JokeDataSourceImpl implements JokeDataSource { final _jokeUrl = 'https://evilinsult.com/generate_insult.php?lang=en&type=json'; final _dio = Dio(); @override Future<JokeDTO> fetchJoke() async { try { final request = await _dio.get(_jokeUrl); final mapData = request.data as Map<String, dynamic>; return JokeDTO.fromJson(mapData); } catch (_) { throw 'Error!'; } } }
0
mirrored_repositories/evil_word/lib/data
mirrored_repositories/evil_word/lib/data/dto/joke_dto.dart
// ignore_for_file: public_member_api_docs, sort_constructors_first import 'package:evil_word/domain/entities/joke_entity.dart'; class JokeDTO { JokeDTO({ required this.number, required this.language, required this.insult, required this.created, required this.shown, required this.createdby, required this.active, required this.comment, }); final String number; final String language; final String insult; final String created; final String shown; final String createdby; final String active; final String comment; Map<String, dynamic> toMap() { return <String, dynamic>{ 'number': number, 'language': language, 'insult': insult, 'created': created, 'shown': shown, 'createdby': createdby, 'active': active, 'comment': comment, }; } factory JokeDTO.fromJson(Map<String, dynamic> map) { return JokeDTO( number: map['number'], language: map['language'], insult: map['insult'], created: map['created'], shown: map['shown'], createdby: map['createdby'], active: map['active'], comment: map['comment'], ); } JokeEntity toEntity() => JokeEntity( active: active, comment: comment, created: created, createdby: createdby, insult: insult, language: language, number: number, shown: shown, ); }
0
mirrored_repositories/evil_word/lib/presentation
mirrored_repositories/evil_word/lib/presentation/home_page/home_page.dart
import 'package:evil_word/presentation/home_page/state/joke_bloc/joke_bloc.dart'; import 'package:evil_word/presentation/home_page/widgets/error_text_widget.dart'; import 'package:evil_word/presentation/home_page/widgets/loaded_joke_widget.dart'; import 'package:evil_word/services/snackbar_service.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'state/network_connection_cubit/internet_cubit.dart'; import 'state/network_connection_cubit/internet_state.dart'; class HomePage extends StatelessWidget { const HomePage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( floatingActionButton: BlocConsumer<InternetCubit, InternetCubitState>( listener: (context, state) { if (state is InternetDisconnectedState) { SnackbarService.showSnackbar( context: context, message: 'No internet', ); } }, builder: (context, state) { return FloatingActionButton( child: const Icon(Icons.add), onPressed: state is InternetConnectedState ? () => context.read<JokeBloc>().add(LoadJokesEvent()) : null, ); }, ), backgroundColor: Colors.black, appBar: AppBar( backgroundColor: Theme.of(context).colorScheme.secondary, centerTitle: true, title: const Text( '🀬 Evil word', style: TextStyle( fontWeight: FontWeight.w500, fontSize: 25, color: Colors.white, ), ), ), body: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Padding( padding: const EdgeInsets.symmetric(horizontal: 30), child: BlocBuilder<JokeBloc, JokeState>( builder: (__, jokeState) { if (jokeState is JokeInitialState) { context.read<JokeBloc>().add(LoadJokesEvent()); return const Center( child: CircularProgressIndicator.adaptive(), ); } if (jokeState is JokeLoadedState) { return LoadedJokeWidget(jokeEntity: jokeState.joke); } if (jokeState is JokeLoadedWithErrorState) { return ErrorTextWidget(message: jokeState.message); } return const SizedBox(); }, ), ), ], ), ); } }
0
mirrored_repositories/evil_word/lib/presentation/home_page
mirrored_repositories/evil_word/lib/presentation/home_page/widgets/error_text_widget.dart
import 'package:flutter/material.dart'; class ErrorTextWidget extends StatelessWidget { const ErrorTextWidget({ Key? key, required this.message, }) : super(key: key); final String message; @override Widget build(BuildContext context) { return Center( child: Text( message, softWrap: true, textAlign: TextAlign.center, style: const TextStyle( fontSize: 25, fontWeight: FontWeight.w400, color: Colors.white, ), ), ); } }
0
mirrored_repositories/evil_word/lib/presentation/home_page
mirrored_repositories/evil_word/lib/presentation/home_page/widgets/loaded_joke_widget.dart
import 'package:evil_word/domain/entities/joke_entity.dart'; import 'package:flutter/material.dart'; class LoadedJokeWidget extends StatelessWidget { const LoadedJokeWidget({ Key? key, required this.jokeEntity, }) : super(key: key); final JokeEntity jokeEntity; @override Widget build(BuildContext context) { return Center( child: Material( elevation: 1, color: Colors.transparent, shadowColor: Theme.of(context).colorScheme.secondary, child: Container( padding: const EdgeInsets.all(7), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), border: Border.all( width: 3, color: Theme.of(context).colorScheme.secondary, ), ), child: Text( "${jokeEntity.insult}.", softWrap: true, textAlign: TextAlign.center, style: const TextStyle( fontSize: 25, fontWeight: FontWeight.w400, color: Colors.white, ), ), ), ), ); } }
0
mirrored_repositories/evil_word/lib/presentation/home_page/state
mirrored_repositories/evil_word/lib/presentation/home_page/state/network_connection_cubit/internet_cubit.dart
import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:evil_word/presentation/home_page/state/network_connection_cubit/internet_state.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; class InternetCubit extends Cubit<InternetCubitState> { final Connectivity connectivity; InternetCubit({required this.connectivity}) : super(const InternetDisconnectedState()) { connectivity.onConnectivityChanged.listen((connectivityResult) { connectivityResult == ConnectivityResult.none ? emit(const InternetDisconnectedState()) : emit(const InternetConnectedState()); }); } }
0
mirrored_repositories/evil_word/lib/presentation/home_page/state
mirrored_repositories/evil_word/lib/presentation/home_page/state/network_connection_cubit/internet_state.dart
import 'package:equatable/equatable.dart'; class InternetCubitState extends Equatable { const InternetCubitState(); @override List<Object> get props => []; } class InternetConnectedState extends InternetCubitState { const InternetConnectedState(); } class InternetDisconnectedState extends InternetCubitState { const InternetDisconnectedState(); }
0
mirrored_repositories/evil_word/lib/presentation/home_page/state
mirrored_repositories/evil_word/lib/presentation/home_page/state/joke_bloc/joke_bloc.dart
import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; import 'package:evil_word/domain/entities/joke_entity.dart'; import 'package:evil_word/domain/repository/joke_repository.dart'; import 'package:meta/meta.dart'; part 'joke_event.dart'; part 'joke_state.dart'; class JokeBloc extends Bloc<JokeEvent, JokeState> { JokeBloc({required this.jokeRepository}) : super(JokeInitialState()) { on<JokeEvent>((event, emit) async { await _onLoadJokeEvent(event, emit); }); } final JokeRepository jokeRepository; Future<JokeEntity> _getJoke() async => await jokeRepository.fetchJoke(); Future<void> _onLoadJokeEvent( JokeEvent event, Emitter<JokeState> emit) async { if (event is LoadJokesEvent) { emit(JokeLoadState()); try { final joke = await _getJoke(); emit(JokeLoadedState(joke: joke)); } catch (e) { emit(JokeLoadedWithErrorState(message: e.toString())); } } } }
0
mirrored_repositories/evil_word/lib/presentation/home_page/state
mirrored_repositories/evil_word/lib/presentation/home_page/state/joke_bloc/joke_event.dart
part of 'joke_bloc.dart'; @immutable abstract class JokeEvent extends Equatable { @override List<Object> get props => []; } class LoadJokesEvent extends JokeEvent {}
0
mirrored_repositories/evil_word/lib/presentation/home_page/state
mirrored_repositories/evil_word/lib/presentation/home_page/state/joke_bloc/joke_state.dart
part of 'joke_bloc.dart'; @immutable abstract class JokeState extends Equatable { @override List<Object> get props => []; } class JokeInitialState extends JokeState {} class JokeLoadState extends JokeState {} class JokeLoadedState extends JokeState { final JokeEntity joke; JokeLoadedState({required this.joke}); } class JokeLoadedWithErrorState extends JokeState { final String message; JokeLoadedWithErrorState({required this.message}); }
0
mirrored_repositories/evil_word/lib/domain
mirrored_repositories/evil_word/lib/domain/repository/joke_repository.dart
import 'package:evil_word/domain/entities/joke_entity.dart'; abstract class JokeRepository { Future<JokeEntity> fetchJoke(); }
0
mirrored_repositories/evil_word/lib/domain
mirrored_repositories/evil_word/lib/domain/entities/joke_entity.dart
// ignore_for_file: public_member_api_docs, sort_constructors_first import 'package:equatable/equatable.dart'; class JokeEntity extends Equatable { const JokeEntity({ required this.number, required this.language, required this.insult, required this.created, required this.shown, required this.createdby, required this.active, required this.comment, }); final String number; final String language; final String insult; final String created; final String shown; final String createdby; final String active; final String comment; @override List<Object> get props => [ number, language, insult, created, shown, createdby, active, comment, ]; }
0
mirrored_repositories/evil_word/lib
mirrored_repositories/evil_word/lib/services/snackbar_service.dart
import 'package:flutter/material.dart'; class SnackbarService { static ScaffoldFeatureController<SnackBar, SnackBarClosedReason> showSnackbar({ required BuildContext context, required String message, int milliseconds = 2500, }) { FocusScope.of(context).unfocus(); return ScaffoldMessenger.of(context).showSnackBar( SnackBar( padding: const EdgeInsets.only(bottom: 600), elevation: 0, behavior: SnackBarBehavior.floating, backgroundColor: Colors.transparent, content: Container( width: double.infinity, height: 50, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10.0), color: Colors.black.withOpacity(0.8), ), child: Center( child: Text( message, maxLines: null, ), ), ), duration: Duration(milliseconds: milliseconds), ), ); } }
0
mirrored_repositories/evil_word
mirrored_repositories/evil_word/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'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. // 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/Profile-Screen
mirrored_repositories/Profile-Screen/lib/theme.dart
import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; class MyConfigThemeData { static String fontFamily = 'Vazir'; final Color primaryTextColor; final Color secondaryTextColor; final Color backGroundColor; final Color primaryColor; final Color appBarColor; final Brightness brightness; MyConfigThemeData.dark() : primaryTextColor = const Color.fromARGB(255, 255, 255, 255), secondaryTextColor = const Color.fromARGB(255, 170, 170, 170), backGroundColor = const Color.fromARGB(255, 24, 24, 24), primaryColor = const Color.fromARGB(255, 25, 39, 52), appBarColor = const Color.fromARGB(255, 33, 33, 33), brightness = Brightness.dark; MyConfigThemeData.light() : primaryTextColor = const Color.fromARGB(255, 0, 0, 0), secondaryTextColor = const Color.fromARGB(255, 85, 85, 85), backGroundColor = const Color.fromARGB(255, 230, 230, 230), primaryColor = const Color.fromARGB(255, 87, 155, 177), appBarColor = const Color.fromARGB(255, 222, 222, 222), brightness = Brightness.light; ThemeData themeData(String languageCode) { return ThemeData( primaryColor: primaryColor, brightness: brightness, elevatedButtonTheme: ElevatedButtonThemeData( style: ButtonStyle( backgroundColor: MaterialStateProperty.all(primaryColor), shape: MaterialStateProperty.all( RoundedRectangleBorder( borderRadius: BorderRadius.circular(12), ), ), ), ), inputDecorationTheme: InputDecorationTheme( border: OutlineInputBorder( borderRadius: BorderRadius.circular(12), borderSide: BorderSide.none), filled: true, ), dividerTheme: DividerThemeData( space: 36, thickness: 2, indent: 15, endIndent: 15, color: appBarColor, ), scaffoldBackgroundColor: backGroundColor, appBarTheme: AppBarTheme( elevation: 0, backgroundColor: appBarColor, foregroundColor: primaryTextColor, ), textTheme: languageCode == 'en' ? enPrimaryTextTheme() : faPrimaryTextTheme(), ); } TextTheme enPrimaryTextTheme() { return GoogleFonts.latoTextTheme( TextTheme( titleLarge: TextStyle( fontWeight: FontWeight.w900, color: primaryTextColor, ), bodyLarge: TextStyle( fontSize: 17, fontWeight: FontWeight.w900, color: primaryTextColor, ), bodyMedium: TextStyle( fontSize: 15, color: primaryTextColor, fontWeight: FontWeight.w900, ), bodySmall: TextStyle( fontSize: 15, color: secondaryTextColor, ), ), ); } TextTheme faPrimaryTextTheme() { return TextTheme( titleLarge: TextStyle( fontWeight: FontWeight.w900, color: primaryTextColor, fontFamily: fontFamily, ), bodyLarge: TextStyle( fontSize: 17, fontWeight: FontWeight.w900, color: primaryTextColor, fontFamily: fontFamily, ), bodyMedium: TextStyle( fontSize: 15, color: primaryTextColor, fontWeight: FontWeight.w900, fontFamily: fontFamily, ), bodySmall: TextStyle( fontSize: 15, color: secondaryTextColor, fontFamily: fontFamily, ), ); } }
0
mirrored_repositories/Profile-Screen
mirrored_repositories/Profile-Screen/lib/main.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:profile_screen/theme.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatefulWidget { const MyApp({super.key}); @override State<MyApp> createState() => _MyAppState(); } class _MyAppState extends State<MyApp> { bool _themeMode = true; Locale _locale = const Locale('en'); @override Widget build(BuildContext context) { return MaterialApp( localizationsDelegates: const [ AppLocalizations.delegate, // Add this line GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, GlobalCupertinoLocalizations.delegate, ], supportedLocales: const [ Locale('en'), // English Locale('fa'), // Farsi ], locale: _locale, title: 'Flutter Demo', theme: _themeMode ? MyConfigThemeData.dark().themeData(_locale.languageCode) : MyConfigThemeData.light().themeData(_locale.languageCode), home: ProfileScreen(selectedLanguageByUser: (Language newLanguageByUser) { setState(() { _locale = newLanguageByUser == Language.en ? const Locale('en') : const Locale('fa'); }); }, toggleTheme: () { setState(() { _themeMode = !_themeMode; }); }), ); } } class ProfileScreen extends StatefulWidget { final Function() toggleTheme; final Function(Language) selectedLanguageByUser; const ProfileScreen( {super.key, required this.toggleTheme, required this.selectedLanguageByUser}); @override State<ProfileScreen> createState() => _ProfileScreenState(); } class _ProfileScreenState extends State<ProfileScreen> { SkillType _skillType = SkillType.photoshop; bool _isLiked = false; Language _language = Language.en; void updateSkillType(SkillType skillSelected) { setState(() { _skillType = skillSelected; }); } void updateSelectedLanguage(Language languageSelected) { widget.selectedLanguageByUser(languageSelected); setState(() { { _language = languageSelected; } }); } @override Widget build(BuildContext context) { AppLocalizations appLocalization = AppLocalizations.of(context)!; bool showCursor = false; Color fillColorTextField = Theme.of(context).brightness==Brightness.dark?Colors.grey.shade700:Colors.grey.shade50; return GestureDetector( onTap: () { FocusScopeNode currentFocus = FocusScope.of(context); if (!currentFocus.hasPrimaryFocus) { currentFocus.unfocus(); } }, child: Scaffold( appBar: AppBar( title: Text(appLocalization.profileTitle), actions: [ InkWell( onTap: widget.toggleTheme, child: Padding( padding: const EdgeInsets.fromLTRB(8, 0, 8, 0), child: Theme.of(context).brightness == Brightness.dark ? const Icon( Icons.sunny, color: Colors.white, ) : const Icon( CupertinoIcons.moon_stars_fill, color: Colors.black, ), ), ), ], ), body: SingleChildScrollView( physics: const BouncingScrollPhysics(), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.all(32), child: Row( children: [ ClipRRect( borderRadius: BorderRadius.circular(8), child: Image.asset( 'assets/images/profile_image.png', width: 60, height: 60, ), ), const SizedBox(width: 20), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( appLocalization.name, style: Theme.of(context).textTheme.bodyMedium, ), const SizedBox(height: 3), Text( appLocalization.job, style: Theme.of(context).textTheme.bodySmall, ), Row( children: [ Icon( Icons.location_on_outlined, size: 15, color: Theme.of(context) .textTheme .bodySmall! .color, ), Text( appLocalization.location, style: Theme.of(context).textTheme.bodySmall, ), ], ), ], ), ), IconButton( enableFeedback: false, splashColor: Colors.transparent, onPressed: () { setState(() { _isLiked = !_isLiked; }); }, icon: Icon( _isLiked ? CupertinoIcons.heart_fill : CupertinoIcons.heart, color: Colors.red.shade900, ), ), ], ), ), Padding( padding: const EdgeInsets.fromLTRB(32, 0, 32, 0), child: Text( appLocalization.summary, style: Theme.of(context).textTheme.bodySmall, ), ), const Divider(), Padding( padding: const EdgeInsets.fromLTRB(32, 0, 32, 00), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( appLocalization.selectedLanguage, style: Theme.of(context).textTheme.bodyLarge, ), CupertinoSlidingSegmentedControl<Language>( thumbColor: Theme.of(context).primaryColor, groupValue: _language, children: { Language.en: Text( appLocalization.enLanguage, style: Theme.of(context) .textTheme .bodyMedium! .copyWith(fontWeight: FontWeight.w100), ), Language.fa: Text( appLocalization.faLanguage, style: Theme.of(context) .textTheme .bodyMedium! .copyWith(fontWeight: FontWeight.w100), ), }, onValueChanged: (value) => {if (value != null) updateSelectedLanguage(value)}, ), ], ), ), const Divider(), Padding( padding: const EdgeInsets.only(left: 32, bottom: 16, right: 32), child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( appLocalization.skills, style: Theme.of(context).textTheme.bodyLarge, ), ], ), ), Center( child: Wrap( direction: Axis.horizontal, spacing: 8, runSpacing: 8, children: [ ItemSkills( imageAddress: 'assets/images/app_icon_01.png', skillName: 'Photoshop', shadowColor: Colors.indigo.shade800, isActive: _skillType == SkillType.photoshop, onTap: () { updateSkillType( SkillType.photoshop, ); }, ), ItemSkills( imageAddress: 'assets/images/app_icon_02.png', skillName: 'Lightroom', shadowColor: Colors.indigo.shade800, isActive: _skillType == SkillType.lightroom, onTap: () { updateSkillType( SkillType.lightroom, ); }, ), ItemSkills( imageAddress: 'assets/images/app_icon_03.png', skillName: 'Aftereffect', shadowColor: Colors.indigo.shade900, isActive: _skillType == SkillType.aftereffect, onTap: () { updateSkillType( SkillType.aftereffect, ); }, ), ItemSkills( imageAddress: 'assets/images/app_icon_04.png', skillName: 'Illustrator', shadowColor: Colors.deepOrange.shade900, isActive: _skillType == SkillType.illustrator, onTap: () { updateSkillType( SkillType.illustrator, ); }, ), ItemSkills( imageAddress: 'assets/images/app_icon_05.png', skillName: 'Adobe XD', shadowColor: Colors.pink.shade400, isActive: _skillType == SkillType.adobeXD, onTap: () { updateSkillType( SkillType.adobeXD, ); }, ), ], ), ), const Divider(), Padding( padding: const EdgeInsets.only(left: 32, right: 32, bottom: 32), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( appLocalization.personalInformation, style: Theme.of(context).textTheme.bodyLarge, ), const SizedBox(height: 10), TextField( showCursor: showCursor, decoration: InputDecoration( fillColor: fillColorTextField, labelText: appLocalization.email, labelStyle: TextStyle(color: Theme.of(context).primaryColor), prefixIconColor: Theme.of(context).primaryColor, prefixIcon: const Icon( Icons.alternate_email_sharp, size: 18, ), ), ), const SizedBox(height: 10), TextField( showCursor: showCursor, decoration: InputDecoration( fillColor: fillColorTextField, labelText: appLocalization.password, labelStyle: TextStyle(color: Theme.of(context).primaryColor), prefixIconColor: Theme.of(context).primaryColor, prefixIcon: const Icon( Icons.password, size: 18, ), ), ), const SizedBox(height: 10), SizedBox( width: double.infinity, height: 48, child: ElevatedButton( onPressed: () {}, child: Text( appLocalization.save, style: Theme.of(context).textTheme.bodyMedium, ), ), ), ], ), ), ], ), ), ), ); } } class ItemSkills extends StatelessWidget { final String imageAddress; final String skillName; final Color shadowColor; final bool isActive; final Function() onTap; const ItemSkills({ super.key, required this.imageAddress, required this.skillName, required this.shadowColor, required this.isActive, required this.onTap, }); @override Widget build(BuildContext context) { return InkWell( onTap: onTap, borderRadius: BorderRadius.circular(12), child: Container( width: 110, height: 110, decoration: isActive ? BoxDecoration( color: Colors.white.withOpacity(0.05), borderRadius: BorderRadius.circular(12), ) : null, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( decoration: isActive ? BoxDecoration(boxShadow: [ BoxShadow( color: shadowColor, blurRadius: 20, ), ]) : null, child: Image.asset( imageAddress, width: 40, height: 40, ), ), const SizedBox(height: 8), Text( skillName, style: Theme.of(context).textTheme.bodySmall!.copyWith( fontWeight: FontWeight.w900, ), ), ], ), ), ); } } enum SkillType { photoshop, lightroom, aftereffect, illustrator, adobeXD, } enum Language { fa, en, }
0
mirrored_repositories/Profile-Screen
mirrored_repositories/Profile-Screen/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility 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:profile_screen/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/PrimeiroAppEmFlutter
mirrored_repositories/PrimeiroAppEmFlutter/lib/main.dart
import 'package:flutter/material.dart'; import 'package:numero_aleatorio/pages/pagina_inicial.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: PaginaInicial(), ); } }
0
mirrored_repositories/PrimeiroAppEmFlutter/lib
mirrored_repositories/PrimeiroAppEmFlutter/lib/widgets/numero_aleatorio.dart
import 'package:flutter/material.dart'; import 'dart:math'; class NumeroAleatorio extends StatefulWidget { @override _NumeroAleatorio createState() => _NumeroAleatorio(); } class _NumeroAleatorio extends State<NumeroAleatorio> { int _numero = 0; void _gerarnumero() { setState(() { Random numeroAleatorio = new Random(); _numero = numeroAleatorio.nextInt(10); }); } @override Widget build(BuildContext context) { return Container( child: Column( children: [ Text( '$_numero', style: TextStyle(fontSize: 28), ), SizedBox(height: 30), RaisedButton( onPressed: _gerarnumero, child: Text("Gerar NΓΊmero!"), ) ], ), ); } }
0
mirrored_repositories/PrimeiroAppEmFlutter/lib
mirrored_repositories/PrimeiroAppEmFlutter/lib/widgets/titulo.dart
import 'package:flutter/material.dart'; class Titulo extends StatelessWidget { @override Widget build(BuildContext context) { return Container( child: Text("Gerador de nΓΊmeros", style: TextStyle(fontSize: 28))); } }
0
mirrored_repositories/PrimeiroAppEmFlutter/lib
mirrored_repositories/PrimeiroAppEmFlutter/lib/pages/pagina_inicial.dart
import 'package:flutter/material.dart'; import 'package:numero_aleatorio/widgets/numero_aleatorio.dart'; import 'package:numero_aleatorio/widgets/titulo.dart'; class PaginaInicial extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text("Gerador aleatΓ³rio")), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [Titulo(), SizedBox(height: 30), NumeroAleatorio()], ), )); } }
0
mirrored_repositories/PrimeiroAppEmFlutter
mirrored_repositories/PrimeiroAppEmFlutter/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:numero_aleatorio/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/programming_quiz
mirrored_repositories/programming_quiz/lib/main.dart
import 'package:flutter/material.dart'; import 'package:programming_quiz/view/dificult_game_view.dart'; import 'view/login_view.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Programming Quiz', debugShowCheckedModeBanner: false, theme: ThemeData( appBarTheme: const AppBarTheme( backgroundColor: Color.fromARGB(250, 82, 103, 255), )), initialRoute: HomePageView.routeName, routes: { HomePageView.routeName: (context) => const HomePageView(), DificultGamePageView.routeName: (context) => const DificultGamePageView(), }); } }
0
mirrored_repositories/programming_quiz/lib
mirrored_repositories/programming_quiz/lib/view/login_view.dart
import 'package:flutter/material.dart'; class HomePageView extends StatefulWidget { const HomePageView({Key? key}) : super(key: key); static const routeName = '/home'; @override State<HomePageView> createState() => _HomePageViewState(); } class _HomePageViewState extends State<HomePageView> { @override Widget build(BuildContext context) { return Scaffold( body: Container( width: double.maxFinite, padding: const EdgeInsets.only( left: 54.0, top: 54.0, right: 54.0, bottom: 0.0), decoration: const BoxDecoration(color: Color.fromARGB(255, 255, 200, 0)), child: ListView( children: <Widget>[ SizedBox( width: 300, height: 300, child: Image.asset( 'assets/images/principles-of-programming-logo.png'), ), Material( borderRadius: BorderRadius.all(Radius.circular(30)), child: InkWell( borderRadius: BorderRadius.all(Radius.circular(30)), child: Ink( height: 54, width: double.maxFinite, decoration: const BoxDecoration( color: Color.fromARGB(250, 82, 103, 255), borderRadius: BorderRadius.all(Radius.circular(15))), child: const Center( child: Text( 'Login', style: TextStyle( color: Color.fromARGB(255, 255, 200, 0), fontSize: 20), )), ), ), ), const SizedBox( height: 10, ), Material( borderRadius: BorderRadius.all(Radius.circular(30)), child: InkWell( borderRadius: BorderRadius.all(Radius.circular(30)), child: Ink( height: 54, width: double.maxFinite, decoration: const BoxDecoration( color: Color.fromARGB(250, 82, 103, 255), borderRadius: BorderRadius.all(Radius.circular(15))), child: const Center( child: Text( 'Cadastro', style: TextStyle( color: Color.fromARGB(255, 255, 200, 0), fontSize: 20), )), ), ), ), const SizedBox( height: 10, ), Material( borderRadius: BorderRadius.all(Radius.circular(30)), child: InkWell( borderRadius: BorderRadius.all(Radius.circular(30)), child: Ink( height: 54, width: double.maxFinite, decoration: const BoxDecoration( color: Color.fromARGB(250, 82, 103, 255), borderRadius: BorderRadius.all(Radius.circular(15))), child: const Center( child: Text( 'Jogar Como Convidado', style: TextStyle( color: Color.fromARGB(255, 255, 200, 0), fontSize: 20), )), ), onTap: () => {Navigator.popAndPushNamed(context, '/dificult')}, ), ), const SizedBox( height: 30, ) ], ), ), ); } }
0
mirrored_repositories/programming_quiz/lib
mirrored_repositories/programming_quiz/lib/view/dificult_game_view.dart
import 'package:flutter/material.dart'; class DificultGamePageView extends StatefulWidget { const DificultGamePageView({Key? key}) : super(key: key); static const routeName = '/dificult'; @override State<DificultGamePageView> createState() => _DificultGamePageViewState(); } class _DificultGamePageViewState extends State<DificultGamePageView> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Center( child: Text('Programming Quiz', style: TextStyle(fontSize: 25))), ), body: Container( padding: const EdgeInsets.all(30), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ //Easy Button Material( borderRadius: BorderRadius.all(Radius.circular(30)), child: InkWell( borderRadius: BorderRadius.all(Radius.circular(30)), child: Ink( height: 54, width: double.maxFinite, decoration: const BoxDecoration( color: Color.fromARGB(250, 82, 103, 255), borderRadius: BorderRadius.all(Radius.circular(15))), child: const Center( child: Text( 'Easy', style: TextStyle(color: Colors.white, fontSize: 20), )), ), ), ), const SizedBox( height: 10, ), Material( borderRadius: BorderRadius.all(Radius.circular(30)), child: InkWell( borderRadius: BorderRadius.all(Radius.circular(30)), child: Ink( height: 54, width: double.maxFinite, decoration: const BoxDecoration( color: Color.fromARGB(250, 82, 103, 255), borderRadius: BorderRadius.all(Radius.circular(15))), child: const Center( child: Text( 'Medium', style: TextStyle(color: Colors.white, fontSize: 20), )), ), ), ), const SizedBox( height: 10, ), Material( borderRadius: BorderRadius.all(Radius.circular(30)), child: InkWell( borderRadius: BorderRadius.all(Radius.circular(30)), child: Ink( height: 54, width: double.maxFinite, decoration: const BoxDecoration( color: Color.fromARGB(250, 82, 103, 255), borderRadius: BorderRadius.all(Radius.circular(15))), child: const Center( child: Text( 'Hard', style: TextStyle(color: Colors.white, fontSize: 20), )), ), ), ), ])), ); } }
0
mirrored_repositories/programming_quiz/lib
mirrored_repositories/programming_quiz/lib/model/question_model.dart
class Question { String _question; String _answerOne; String _answerTwo; String _answerThree; String _answerFour; String _correctAnswer; Question(this._question, this._answerOne, this._answerTwo, this._answerThree, this._answerFour, this._correctAnswer); String get _getQuestion => _question; String get _getAnswerOne => _answerOne; String get _getAnswerTwo => _answerTwo; String get _getAnswerThree => _answerThree; String get _getAnswerFour => _answerFour; } List<Question> defaultQuestions = [ Question("Pergunta", "_answerOne", "_answerTwo", "_answerThree", "_answerFour", "_correctAnswer") ];
0
mirrored_repositories/programming_quiz
mirrored_repositories/programming_quiz/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:programming_quiz/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(const MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/flutter_instagram_clone_app
mirrored_repositories/flutter_instagram_clone_app/lib/main.dart
import 'package:flutter/material.dart'; import 'package:flutter_instagram_clone_app/screens/home_page_screen.dart'; import 'package:flutter_instagram_clone_app/widget/bottom_navigation_widget.dart'; /* Title:Entry Point of a App Purpose:Entry Point of a App Created By:Kalpesh Khandla */ void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', debugShowCheckedModeBanner: false, theme: ThemeData( primarySwatch: Colors.blue, ), home: BottomNavigationBarWidget(), ); } }
0
mirrored_repositories/flutter_instagram_clone_app/lib
mirrored_repositories/flutter_instagram_clone_app/lib/widget/post_item_widget.dart
import 'package:flutter/material.dart'; import 'package:flutter_instagram_clone_app/common/colors_constants.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:line_icons/line_icons.dart'; /* Title:PostItemWidget Purpose:PostItemWidget Created By:Kalpesh Khandla */ class PostItemWidget extends StatelessWidget { final String profileImg; final String name; final String postImg; final String caption; final isLoved; final String likedBy; final String viewCount; final String dayAgo; PostItemWidget({ Key? key, required this.profileImg, required this.name, required this.postImg, required this.isLoved, required this.likedBy, required this.viewCount, required this.dayAgo, required this.caption, }) : super(key: key); @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.only(bottom: 10), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Padding( padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 15), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Row( children: <Widget>[ Container( width: 40, height: 40, decoration: BoxDecoration( shape: BoxShape.circle, image: DecorationImage( image: NetworkImage(profileImg), fit: BoxFit.cover)), ), SizedBox( width: 15, ), Text( name, style: TextStyle( color: white, fontSize: 15, fontWeight: FontWeight.w500), ) ], ), // Icon( // LineIcons.ellipsis_h, // color: white, // ) ], ), ), SizedBox( height: 12, ), Container( height: 400, decoration: BoxDecoration( image: DecorationImage( image: NetworkImage(postImg), fit: BoxFit.cover)), ), SizedBox( height: 10, ), Padding( padding: const EdgeInsets.only(left: 15, right: 15, top: 3), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Row( children: <Widget>[ isLoved ? SvgPicture.asset( "assets/images/loved_icon.svg", width: 27, ) : SvgPicture.asset( "assets/images/love_icon.svg", width: 27, ), SizedBox( width: 20, ), SvgPicture.asset( "assets/images/comment_icon.svg", width: 27, ), SizedBox( width: 20, ), SvgPicture.asset( "assets/images/message_icon.svg", width: 27, ), ], ), SvgPicture.asset( "assets/images/save_icon.svg", width: 27, ), ], ), ), SizedBox( height: 12, ), Padding( padding: const EdgeInsets.only(left: 15, right: 15), child: RichText( text: TextSpan( children: [ TextSpan( text: "Liked by ", style: TextStyle(fontSize: 15, fontWeight: FontWeight.w500), ), TextSpan( text: "$likedBy ", style: TextStyle(fontSize: 15, fontWeight: FontWeight.w700), ), TextSpan( text: "and ", style: TextStyle(fontSize: 15, fontWeight: FontWeight.w500), ), TextSpan( text: "Other", style: TextStyle(fontSize: 15, fontWeight: FontWeight.w700), ), ], ), ), ), SizedBox( height: 12, ), Padding( padding: EdgeInsets.only(left: 15, right: 15), child: RichText( text: TextSpan(children: [ TextSpan( text: "$name ", style: TextStyle(fontSize: 15, fontWeight: FontWeight.w700)), TextSpan( text: "$caption", style: TextStyle(fontSize: 15, fontWeight: FontWeight.w500)), ]))), SizedBox( height: 12, ), Padding( padding: EdgeInsets.only(left: 15, right: 15), child: Text( "View $viewCount comments", style: TextStyle( color: white.withOpacity(0.5), fontSize: 15, fontWeight: FontWeight.w500), ), ), SizedBox( height: 12, ), Padding( padding: EdgeInsets.only(left: 15, right: 15), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Row( children: <Widget>[ Container( width: 30, height: 30, decoration: BoxDecoration( shape: BoxShape.circle, image: DecorationImage( image: NetworkImage(profileImg), fit: BoxFit.cover)), ), SizedBox( width: 15, ), Text( "Add a comment...", style: TextStyle( color: white.withOpacity(0.5), fontSize: 15, fontWeight: FontWeight.w500), ), ], ), Row( children: <Widget>[ Text( "πŸ˜‚", style: TextStyle(fontSize: 20), ), SizedBox( width: 10, ), Text( "😍", style: TextStyle(fontSize: 20), ), SizedBox( width: 10, ), Icon( Icons.add_circle, color: white.withOpacity(0.5), size: 18, ) ], ) ], )), SizedBox( height: 12, ), Padding( padding: EdgeInsets.only(left: 15, right: 15), child: Text( "$dayAgo", style: TextStyle( color: white.withOpacity(0.5), fontSize: 15, fontWeight: FontWeight.w500), ), ) ], ), ); } }
0
mirrored_repositories/flutter_instagram_clone_app/lib
mirrored_repositories/flutter_instagram_clone_app/lib/widget/bottom_navigation_widget.dart
import 'package:flutter/material.dart'; import 'package:flutter_instagram_clone_app/common/colors_constants.dart'; import 'package:flutter_instagram_clone_app/screens/home_page_screen.dart'; import 'package:flutter_instagram_clone_app/screens/search_screen.dart'; import 'package:flutter_svg/svg.dart'; /* Title:BottomNavigationBarWidget Purpose:BottomNavigationBarWidget Created By:Kalpesh Khandla */ class BottomNavigationBarWidget extends StatefulWidget { @override _RootAppState createState() => _RootAppState(); } class _RootAppState extends State<BottomNavigationBarWidget> { int pageIndex = 0; @override Widget build(BuildContext context) { return Scaffold( appBar: PreferredSize( preferredSize: Size.fromHeight(100.0), child: getAppBar(), ), backgroundColor: black, body: getBody(), bottomNavigationBar: getFooter(), ); } Widget getBody() { List<Widget> pages = [ HomePageScreen(), SearchPageScreen(), Center( child: Text( "Upload Page", style: TextStyle( fontSize: 20, fontWeight: FontWeight.bold, color: white, ), ), ), Center( child: Text( "Activity Page", style: TextStyle( fontSize: 20, fontWeight: FontWeight.bold, color: white, ), ), ), Center( child: Text( "Account Page", style: TextStyle( fontSize: 20, fontWeight: FontWeight.bold, color: white, ), ), ) ]; return IndexedStack( index: pageIndex, children: pages, ); } Widget getAppBar() { if (pageIndex == 0) { return AppBar( backgroundColor: appBarColor, title: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ SvgPicture.asset( "assets/images/camera_icon.svg", width: 30, ), Text( "Instagram", style: TextStyle(fontFamily: 'Billabong', fontSize: 35), ), SvgPicture.asset( "assets/images/message_icon.svg", width: 30, ), ], ), ); } else if (pageIndex == 1) { return Container(); } else if (pageIndex == 2) { return AppBar( backgroundColor: appBarColor, title: Text("Upload"), ); } else if (pageIndex == 3) { return AppBar( backgroundColor: appBarColor, title: Text("Activity"), ); } else { return AppBar( backgroundColor: appBarColor, title: Text("Account"), ); } } Widget getFooter() { List bottomItems = [ pageIndex == 0 ? "assets/images/home_active_icon.svg" : "assets/images/home_icon.svg", pageIndex == 1 ? "assets/images/search_active_icon.svg" : "assets/images/search_icon.svg", pageIndex == 2 ? "assets/images/upload_active_icon.svg" : "assets/images/upload_icon.svg", pageIndex == 3 ? "assets/images/love_active_icon.svg" : "assets/images/love_icon.svg", pageIndex == 4 ? "assets/images/account_active_icon.svg" : "assets/images/account_icon.svg", ]; return Container( width: double.infinity, height: 80, decoration: BoxDecoration(color: appFooterColor), child: Padding( padding: const EdgeInsets.only(left: 20, right: 20, bottom: 20, top: 15), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: List.generate(bottomItems.length, (index) { return InkWell( onTap: () { selectedTab(index); }, child: SvgPicture.asset( bottomItems[index], width: 27, )); }), ), ), ); } selectedTab(index) { setState(() { pageIndex = index; }); } }
0
mirrored_repositories/flutter_instagram_clone_app/lib
mirrored_repositories/flutter_instagram_clone_app/lib/widget/story_item_widget.dart
import 'package:flutter/material.dart'; import 'package:flutter_instagram_clone_app/common/colors_constants.dart'; /* Title:StoryItemWidget Purpose:StoryItemWidget Created By:Kalpesh Khandla */ class StoryItemWidget extends StatelessWidget { final String img; final String name; StoryItemWidget({ Key? key, required this.img, required this.name, }) : super(key: key); @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.only(right: 20, bottom: 10), child: Column( children: <Widget>[ Container( width: 68, height: 68, decoration: BoxDecoration( shape: BoxShape.circle, gradient: LinearGradient( begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: storyBorderColor)), child: Padding( padding: const EdgeInsets.all(3.0), child: Container( width: 65, height: 65, decoration: BoxDecoration( border: Border.all(color: black, width: 2), shape: BoxShape.circle, image: DecorationImage( image: NetworkImage( img, ), fit: BoxFit.cover)), ), ), ), SizedBox( height: 8, ), SizedBox( width: 70, child: Text( name, overflow: TextOverflow.ellipsis, style: TextStyle(color: white), ), ) ], ), ); } }
0
mirrored_repositories/flutter_instagram_clone_app/lib
mirrored_repositories/flutter_instagram_clone_app/lib/widget/category_story_item_widget.dart
import 'package:flutter/material.dart'; import 'package:flutter_instagram_clone_app/common/colors_constants.dart'; /* Title:CategoryStoryItemWidget Purpose:CategoryStoryItemWidget Created By:Kalpesh Khandla */ class CategoryStoryItemWidget extends StatelessWidget { final String name; const CategoryStoryItemWidget({ Key? key, required this.name, }) : super(key: key); @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.only(right: 10), child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: black, border: Border.all( color: white.withOpacity(0.2), ), ), child: Padding( padding: const EdgeInsets.only(left: 20, right: 25, top: 10, bottom: 10), child: Text( name, style: TextStyle( color: white, fontWeight: FontWeight.w500, fontSize: 15, ), ), ), ), ); } }
0
mirrored_repositories/flutter_instagram_clone_app/lib
mirrored_repositories/flutter_instagram_clone_app/lib/widget/search_category_item.dart
import 'package:flutter/material.dart'; import 'package:flutter_instagram_clone_app/common/colors_constants.dart'; /* Title:CategoryStoryItemWidget Purpose:CategoryStoryItemWidget Created By:Kalpesh Khandla */ class CategoryStoryItemWidget extends StatelessWidget { final String name; const CategoryStoryItemWidget({ required Key key, required this.name, }) : super(key: key); @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.only(right: 10), child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: black, border: Border.all(color: white.withOpacity(0.2))), child: Padding( padding: const EdgeInsets.only(left: 20, right: 25, top: 10, bottom: 10), child: Text( name, style: TextStyle( color: white, fontWeight: FontWeight.w500, fontSize: 15, ), ), ), ), ); } }
0
mirrored_repositories/flutter_instagram_clone_app/lib
mirrored_repositories/flutter_instagram_clone_app/lib/common/colors_constants.dart
import 'package:flutter/material.dart'; /* Title:Color Constants for app Purpose:Color Constants for app Created By:Kalpesh Khandla */ const appBarColor = Color(0xFF131313); const appFooterColor = Color(0xFF131313); const primary = Color(0xFF000000); const white = Color(0xFFFFFFFF); const black = Color(0xFF000000); const textFieldBackground = Color(0xFF262626); const buttonFollowColor = Color(0xFF0494F5); const storyBorderColor = [Color(0xFF9B2282), Color(0xFFEEA863)];
0
mirrored_repositories/flutter_instagram_clone_app/lib/utils
mirrored_repositories/flutter_instagram_clone_app/lib/utils/constant/post_json.dart
List posts = [ { "id": 1, "name": "panhchaneath_ung", "profileImg": "https://images.unsplash.com/photo-1503185912284-5271ff81b9a8?ixid=MnwxMjA3fDB8MHxzZWFyY2h8NHx8Z2lybHxlbnwwfHwwfHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60", "postImg": "https://images.unsplash.com/photo-1503185912284-5271ff81b9a8?ixid=MnwxMjA3fDB8MHxzZWFyY2h8NHx8Z2lybHxlbnwwfHwwfHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60", "caption": " SERIOUS MODE during SERIOUS RAINY DAY", "isLoved": true, "commentCount": "10", "likedBy": "whereavygoes", "timeAgo": "1 day ago" }, { "id": 2, "name": "whereavygoes", "profileImg": "https://images.unsplash.com/photo-1529626455594-4ff0802cfb7e?ixid=MnwxMjA3fDB8MHxzZWFyY2h8NXx8Z2lybHxlbnwwfHwwfHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60", "postImg": "https://images.unsplash.com/photo-1529626455594-4ff0802cfb7e?ixid=MnwxMjA3fDB8MHxzZWFyY2h8NXx8Z2lybHxlbnwwfHwwfHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60", "caption": " αž‘αžΉαž€αž˜αž»αžαž“αŸ…αž–αŸαž›αž™αžΎαž„αž’αžαŸ‹αž…αž„αŸ‹αžαžαžšαžΌαž”αž“αŸ…αž€αž“αŸ’αž›αŸ‚αž„αžŸαž½αž“αž•αŸ’αž€αžΆ αž αžΎαž™αž‚αŸαž”αž„αŸ’αžαŸ†αž’αŸ„αž™αž™αžΎαž„αžαžαŸ” πŸ˜πŸ˜’", "isLoved": true, "commentCount": "10", "likedBy": "sonitakhoun", "timeAgo": "1 day ago" }, { "id": 3, "name": "allef_vinicius", "profileImg": "https://images.unsplash.com/photo-1545912452-8aea7e25a3d3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60", "postImg": "https://images.unsplash.com/photo-1578616070222-50c4de9d5ade?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60", "caption": " It is a good to day", "isLoved": false, "commentCount": "60", "likedBy": "babysweetiepie", "timeAgo": "3 day ago" }, { "id": 4, "name": "babysweetiepie", "profileImg": "https://images.unsplash.com/photo-1513207565459-d7f36bfa1222?ixid=MnwxMjA3fDB8MHxzZWFyY2h8N3x8Z2lybHxlbnwwfHwwfHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60", "postImg": "https://images.unsplash.com/photo-1513207565459-d7f36bfa1222?ixid=MnwxMjA3fDB8MHxzZWFyY2h8N3x8Z2lybHxlbnwwfHwwfHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60", "caption": "I love how a 6-year-old kid took better photos than many of my friends out there πŸ˜‚", "isLoved": false, "commentCount": "70", "likedBy": "sonitakhoun", "timeAgo": "3 day ago" } ];
0
mirrored_repositories/flutter_instagram_clone_app/lib/utils
mirrored_repositories/flutter_instagram_clone_app/lib/utils/constant/story_json.dart
// user prfile String profile = "https://images.unsplash.com/photo-1599842057874-37393e9342df?ixid=MnwxMjA3fDB8MHxzZWFyY2h8MTF8fGdpcmx8ZW58MHx8MHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60"; String name = "panhchaneath_ung"; // stories List stories = [ { "id": 1, "img": "https://images.unsplash.com/photo-1503185912284-5271ff81b9a8?ixid=MnwxMjA3fDB8MHxzZWFyY2h8NHx8Z2lybHxlbnwwfHwwfHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60", "name": "sonitakhoun" }, { "id": 2, "img": "https://images.unsplash.com/photo-1529626455594-4ff0802cfb7e?ixid=MnwxMjA3fDB8MHxzZWFyY2h8NXx8Z2lybHxlbnwwfHwwfHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60", "name": "babysweetiepie" }, { "id": 3, "img": "https://images.unsplash.com/photo-1545912452-8aea7e25a3d3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60", "name": "whereavygoes" }, { "id": 4, "img": "https://images.unsplash.com/photo-1525879000488-bff3b1c387cf?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60", "name": "collins_lesulie" }, { "id": 5, "img": "https://images.unsplash.com/photo-1517070208541-6ddc4d3efbcb?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60", "name": "tyler_nix" } ];
0
mirrored_repositories/flutter_instagram_clone_app/lib/utils
mirrored_repositories/flutter_instagram_clone_app/lib/utils/constant/search_json.dart
List searchCategories = [ "Shop", "Decor", "Travel", "Architechture", "Food", "Art", "Style", "TV & Movies", "Music", "DIY", "Comics" ]; List searchImages = [ "https://images.unsplash.com/photo-1529626455594-4ff0802cfb7e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60", "https://images.unsplash.com/photo-1514315384763-ba401779410f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60", "https://images.unsplash.com/photo-1496440737103-cd596325d314?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60", "https://images.unsplash.com/photo-1504276048855-f3d60e69632f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60", "https://images.unsplash.com/photo-1510832198440-a52376950479?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60", "https://images.unsplash.com/photo-1545912452-8aea7e25a3d3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60", "https://images.unsplash.com/photo-1510520434124-5bc7e642b61d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60", "https://images.unsplash.com/photo-1474073705359-5da2a8270c64?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60", "https://images.unsplash.com/photo-1500917293891-ef795e70e1f6?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60", "https://images.unsplash.com/photo-1514846226882-28b324ef7f28?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60", "https://images.unsplash.com/photo-1504730030853-eff311f57d3c?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60", "https://images.unsplash.com/photo-1506901437675-cde80ff9c746?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60", "https://images.unsplash.com/photo-1500336624523-d727130c3328?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60", "https://images.unsplash.com/photo-1504933350103-e840ede978d4?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60", "https://images.unsplash.com/photo-1467632499275-7a693a761056?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60" ];
0
mirrored_repositories/flutter_instagram_clone_app/lib
mirrored_repositories/flutter_instagram_clone_app/lib/screens/home_page_screen.dart
import 'package:flutter/material.dart'; import 'package:flutter_instagram_clone_app/common/colors_constants.dart'; import 'package:flutter_instagram_clone_app/utils/constant/post_json.dart'; import 'package:flutter_instagram_clone_app/utils/constant/story_json.dart'; import 'package:flutter_instagram_clone_app/widget/post_item_widget.dart'; import 'package:flutter_instagram_clone_app/widget/story_item_widget.dart'; /* Title:HomePageScreen Purpose:HomePageScreen Created By:Kalpesh Khandla */ class HomePageScreen extends StatefulWidget { @override _HomePageState createState() => _HomePageState(); } class _HomePageState extends State<HomePageScreen> { @override Widget build(BuildContext context) { return getBody(); } Widget getBody() { return SingleChildScrollView( child: Column( children: <Widget>[ SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( children: <Widget>[ Padding( padding: const EdgeInsets.only(right: 20, left: 15, bottom: 10), child: Column( children: <Widget>[ Container( width: 65, height: 65, child: Stack( children: <Widget>[ Container( width: 65, height: 65, decoration: BoxDecoration( shape: BoxShape.circle, image: DecorationImage( image: NetworkImage(profile), fit: BoxFit.cover)), ), Positioned( bottom: 0, right: 0, child: Container( width: 19, height: 19, decoration: BoxDecoration( shape: BoxShape.circle, color: white), child: Icon( Icons.add_circle, color: buttonFollowColor, size: 19, ), )) ], ), ), SizedBox( height: 8, ), SizedBox( width: 70, child: Text( name, overflow: TextOverflow.ellipsis, style: TextStyle(color: white), ), ) ], ), ), Row( children: List.generate(stories.length, (index) { return StoryItemWidget( img: stories[index]['img'], name: stories[index]['name'], ); })), ], ), ), Divider( color: white.withOpacity(0.3), ), Column( children: List.generate(posts.length, (index) { return PostItemWidget( postImg: posts[index]['postImg'], profileImg: posts[index]['profileImg'], name: posts[index]['name'], caption: posts[index]['caption'], isLoved: posts[index]['isLoved'], viewCount: posts[index]['commentCount'], likedBy: posts[index]['likedBy'], dayAgo: posts[index]['timeAgo'], ); }), ) ], ), ); } }
0
mirrored_repositories/flutter_instagram_clone_app/lib
mirrored_repositories/flutter_instagram_clone_app/lib/screens/search_screen.dart
import 'package:flutter/material.dart'; import 'package:flutter_instagram_clone_app/common/colors_constants.dart'; import 'package:flutter_instagram_clone_app/utils/constant/search_json.dart'; import 'package:flutter_instagram_clone_app/widget/category_story_item_widget.dart'; /* Title:SearchPageScreen Purpose:SearchPageScreen Created By:Kalpesh Khandla */ class SearchPageScreen extends StatefulWidget { @override _SearchPageState createState() => _SearchPageState(); } class _SearchPageState extends State<SearchPageScreen> { @override Widget build(BuildContext context) { return getBody(); } Widget getBody() { var size = MediaQuery.of(context).size; return SingleChildScrollView( child: Column( children: <Widget>[ SafeArea( child: Row( children: <Widget>[ SizedBox( width: 15, ), Container( width: size.width - 30, height: 45, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: textFieldBackground, ), child: TextField( decoration: InputDecoration( border: InputBorder.none, prefixIcon: Icon( Icons.search, color: white.withOpacity(0.3), ), ), style: TextStyle(color: white.withOpacity(0.3)), cursorColor: white.withOpacity(0.3), ), ), SizedBox( width: 15, ) ], ), ), SizedBox( height: 15, ), SingleChildScrollView( scrollDirection: Axis.horizontal, child: Padding( padding: const EdgeInsets.only(left: 15), child: Row( children: List.generate( searchCategories.length, (index) { return CategoryStoryItemWidget( name: searchCategories[index], ); }, ), ), ), ), SizedBox( height: 15, ), Wrap( spacing: 1, runSpacing: 1, children: List.generate(searchImages.length, (index) { return Container( width: (size.width - 3) / 3, height: (size.width - 3) / 3, decoration: BoxDecoration( image: DecorationImage( image: NetworkImage(searchImages[index]), fit: BoxFit.cover, ), ), ); }), ) ], )); } }
0
mirrored_repositories/flutter_instagram_clone_app
mirrored_repositories/flutter_instagram_clone_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:flutter_instagram_clone_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/movie-booking-ui
mirrored_repositories/movie-booking-ui/lib/app.dart
import 'package:flutter/material.dart'; import './core/constants/constants.dart'; import './features/movies/movies_page.dart'; class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: appName, theme: AppTheme.light, home: const MoviesPage(), ); } }
0
mirrored_repositories/movie-booking-ui
mirrored_repositories/movie-booking-ui/lib/main.dart
import 'package:flutter/material.dart'; import './app.dart'; void main() { runApp(const MyApp()); }
0
mirrored_repositories/movie-booking-ui/lib/features
mirrored_repositories/movie-booking-ui/lib/features/movie/movie_page.dart
import 'package:flutter/material.dart'; import './widgets/widgets.dart'; import './animations/animations.dart'; import '../../../core/data/models/movies.dart'; import '../../../core/constants/constants.dart'; class MoviePage extends StatelessWidget { const MoviePage({Key? key, required this.movie}) : super(key: key); final Movie movie; @override Widget build(BuildContext context) { return LayoutBuilder( builder: (context, constraints) { final w = constraints.maxWidth; final h = constraints.maxHeight; return Scaffold( body: Stack( alignment: Alignment.bottomCenter, children: [ Positioned( top: -h * .1, height: h * .6, width: w, child: Hero( tag: movie.image, child: MovieCard(image: movie.image), ), ), Positioned( width: w, height: h * .5, child: Column( children: [ const Spacer(), Hero( tag: movie.name, child: Material( type: MaterialType.transparency, child: Text( movie.name.toUpperCase(), style: AppTextStyles.movieNameTextStyle, ), ), ), OpacityTween( begin: 0.0, child: SlideUpTween( begin: const Offset(-30, 30), child: MovieStars(stars: movie.stars), ), ), const Spacer(), OpacityTween( child: SlideUpTween( begin: const Offset(0, 200), child: Padding( padding: EdgeInsets.symmetric(horizontal: w * .1), child: Text( movie.description, style: AppTextStyles.movieDescriptionStyle, textAlign: TextAlign.center, ), ), ), ), const Spacer(), OpacityTween( child: SlideUpTween( begin: const Offset(0, 200), duration: const Duration(milliseconds: 850), child: MovieInfoTable(movie: movie), ), ), const Spacer(flex: 5) ], ), ), Positioned( bottom: h * .03, height: h * .06, width: w * .7, child: OpacityTween( child: SlideUpTween( begin: const Offset(-30, 60), child: BookButton(movie: movie), ), ), ), Positioned( bottom: h * .05, child: const OpacityTween( child: SlideUpTween( begin: Offset(-10, 60), child: IgnorePointer( child: Text( 'Book Ticket', style: AppTextStyles.bookButtonTextStyle, ), ), ), ), ), ], ), ); }, ); } }
0
mirrored_repositories/movie-booking-ui/lib/features/movie
mirrored_repositories/movie-booking-ui/lib/features/movie/widgets/movie_card.dart
import 'package:flutter/material.dart'; class MovieCard extends StatelessWidget { const MovieCard({Key? key, required this.image}) : super(key: key); final String image; @override Widget build(BuildContext context) { return Container( decoration: BoxDecoration( borderRadius: const BorderRadius.all( Radius.circular(70), ), boxShadow: [ BoxShadow( blurRadius: 20, offset: const Offset(0, 20), color: Colors.black.withOpacity(.2), ), ], image: DecorationImage( fit: BoxFit.cover, image: AssetImage(image), ), ), ); } }
0
mirrored_repositories/movie-booking-ui/lib/features/movie
mirrored_repositories/movie-booking-ui/lib/features/movie/widgets/movie_starts.dart
import 'package:flutter/material.dart'; class MovieStars extends StatelessWidget { const MovieStars({Key? key, required this.stars}) : super(key: key); final int stars; @override Widget build(BuildContext context) { return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ for (int i = 0; i < stars; i++) const Icon(Icons.star, color: Colors.amber) ], ); } }
0
mirrored_repositories/movie-booking-ui/lib/features/movie
mirrored_repositories/movie-booking-ui/lib/features/movie/widgets/movie_info_table_item.dart
import 'package:flutter/material.dart'; import '../../../../core/constants/constants.dart'; class MovieInfoTableItem extends StatelessWidget { const MovieInfoTableItem( {Key? key, required this.title, required this.content}) : super(key: key); final String title; final String content; @override Widget build(BuildContext context) { return Column( children: [ Padding( padding: const EdgeInsets.only(bottom: 10), child: Text(title, style: AppTextStyles.infoTitleStyle), ), Text(content, style: AppTextStyles.infoContentStyle), ], ); } }
0
mirrored_repositories/movie-booking-ui/lib/features/movie
mirrored_repositories/movie-booking-ui/lib/features/movie/widgets/widgets.dart
export 'book_button.dart'; export 'movie_card.dart'; export 'movie_info_table.dart'; export 'movie_info_table_item.dart'; export 'movie_starts.dart';
0