├── lib ├── core │ ├── failure_modle.dart │ ├── opereation_enum.dart │ ├── core.dart │ ├── firebase_constants.dart │ ├── raw_data_model.dart │ └── firebase_erro_helper.dart ├── data │ ├── models │ │ ├── modles.dart │ │ ├── articles │ │ │ ├── article_modle.g.dart │ │ │ └── article_modle.dart │ │ └── user │ │ │ ├── user_modle.dart │ │ │ └── user_modle.g.dart │ └── repositories │ │ ├── pref_repository.dart │ │ ├── home_repository.dart │ │ ├── auth_repository.dart │ │ └── user_repository.dart ├── presentation │ ├── screens │ │ ├── screens.dart │ │ ├── global │ │ │ ├── colors │ │ │ │ └── solid_colors.dart │ │ │ └── widgets │ │ │ │ ├── button.dart │ │ │ │ └── feilds.dart │ │ ├── splash │ │ │ └── splash_screen.dart │ │ ├── articles │ │ │ ├── article_detail_screen.dart │ │ │ └── saved_articles_list.dart │ │ ├── auth │ │ │ ├── forgetpassword_screen.dart │ │ │ ├── signup.dart │ │ │ ├── login_screen.dart │ │ │ └── complete_userinfo_screen.dart │ │ ├── user_profile │ │ │ └── profile_screen.dart │ │ └── home │ │ │ └── home_screen.dart │ └── routes │ │ ├── app_route_names.dart │ │ └── app_pages.dart ├── Blocs │ ├── splash_cubit │ │ ├── splash_state.dart │ │ └── splash_cubit.dart │ ├── profile_cubit │ │ ├── profile_state.dart │ │ └── profile_cubit.dart │ ├── saved_article │ │ ├── saved_article_state.dart │ │ └── saved_article_cubit.dart │ ├── auth_bloc │ │ ├── auth_event.dart │ │ ├── auth_state.dart │ │ └── auth_bloc.dart │ └── home_bloc │ │ ├── home_state.dart │ │ ├── home_event.dart │ │ └── home_bloc.dart ├── gen │ ├── fonts.gen.dart │ └── assets.gen.dart └── main.dart ├── ui_ux └── loginUI.png ├── assets ├── images │ └── amataLogo.png ├── fonts │ ├── Roboto-Medium.ttf │ └── BebasNeue-Regular.ttf ├── icons │ ├── gmail.svg │ └── phone.svg └── lotties │ └── amta_loading.json ├── android ├── gradle.properties ├── app │ ├── src │ │ ├── main │ │ │ ├── res │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── drawable │ │ │ │ │ └── launch_background.xml │ │ │ │ ├── drawable-v21 │ │ │ │ │ └── launch_background.xml │ │ │ │ ├── values │ │ │ │ │ └── styles.xml │ │ │ │ └── values-night │ │ │ │ │ └── styles.xml │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── blog_app │ │ │ │ │ └── MainActivity.kt │ │ │ └── AndroidManifest.xml │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── google-services.json │ └── build.gradle ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── .gitignore ├── settings.gradle └── build.gradle ├── .gitignore ├── README.md ├── analysis_options.yaml ├── .metadata ├── pubspec.yaml └── pubspec.lock /lib/core/failure_modle.dart: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/core/opereation_enum.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | enum OperationResult{ 4 | success, 5 | fail 6 | } -------------------------------------------------------------------------------- /ui_ux/loginUI.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abolfazl-MI/amata_blog/HEAD/ui_ux/loginUI.png -------------------------------------------------------------------------------- /assets/images/amataLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abolfazl-MI/amata_blog/HEAD/assets/images/amataLogo.png -------------------------------------------------------------------------------- /assets/fonts/Roboto-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abolfazl-MI/amata_blog/HEAD/assets/fonts/Roboto-Medium.ttf -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /assets/fonts/BebasNeue-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abolfazl-MI/amata_blog/HEAD/assets/fonts/BebasNeue-Regular.ttf -------------------------------------------------------------------------------- /lib/data/models/modles.dart: -------------------------------------------------------------------------------- 1 | 2 | // barrell file 3 | 4 | export './user/user_modle.dart'; 5 | export './articles/article_modle.dart'; -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abolfazl-MI/amata_blog/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abolfazl-MI/amata_blog/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abolfazl-MI/amata_blog/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abolfazl-MI/amata_blog/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abolfazl-MI/amata_blog/HEAD/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /lib/core/core.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | // barell file 4 | 5 | export './failure_modle.dart'; 6 | export './opereation_enum.dart'; 7 | export './raw_data_model.dart'; 8 | export './firebase_constants.dart'; -------------------------------------------------------------------------------- /lib/presentation/screens/screens.dart: -------------------------------------------------------------------------------- 1 | // barell file to export path and make import easier 2 | 3 | export './home/home_screen.dart'; 4 | export './auth/login_screen.dart'; 5 | export './auth/signup.dart'; -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/example/blog_app/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.blog_app 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /lib/core/firebase_constants.dart: -------------------------------------------------------------------------------- 1 | abstract class FirebaseConstants { 2 | static String usersCollection = 'users'; 3 | static String articlesCollection = 'articles'; 4 | static String userProfile='profiles'; 5 | 6 | } -------------------------------------------------------------------------------- /lib/core/raw_data_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:blog_app/core/opereation_enum.dart'; 2 | 3 | class RawData { 4 | OperationResult? operationResult; 5 | dynamic data; 6 | RawData({this.data, this.operationResult}); 7 | } 8 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip 7 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /lib/Blocs/splash_cubit/splash_state.dart: -------------------------------------------------------------------------------- 1 | part of 'splash_cubit.dart'; 2 | 3 | abstract class SplashState extends Equatable { 4 | const SplashState(); 5 | 6 | @override 7 | List get props => []; 8 | } 9 | class UnknownState extends SplashState{} 10 | class UnRegisteredState extends SplashState {} 11 | class RegisteredState extends SplashState{} -------------------------------------------------------------------------------- /lib/presentation/screens/global/colors/solid_colors.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class SolidColors { 4 | static Color gray = const Color(0xff1E1F28); 5 | static Color red = const Color(0xffEF3651); 6 | static Color darkGrey = const Color(0xff2A2C36); 7 | static Color lightGrey = Color.fromARGB(255, 100, 106, 138); 8 | static Color kindGray = Color.fromARGB(255, 90, 94, 114); 9 | } 10 | // const Color(0xff2A2C36); -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /lib/Blocs/profile_cubit/profile_state.dart: -------------------------------------------------------------------------------- 1 | part of 'profile_cubit.dart'; 2 | 3 | abstract class ProfileState extends Equatable { 4 | const ProfileState(); 5 | 6 | @override 7 | List get props => []; 8 | } 9 | 10 | class ProfileLoadingState extends ProfileState {} 11 | 12 | class ProfileLoadedState extends ProfileState { 13 | final AmataUser amataUser; 14 | ProfileLoadedState(this.amataUser); 15 | } 16 | 17 | class ProfileErrorState extends ProfileState { 18 | final String error; 19 | ProfileErrorState(this.error); 20 | } 21 | -------------------------------------------------------------------------------- /lib/gen/fonts.gen.dart: -------------------------------------------------------------------------------- 1 | /// GENERATED CODE - DO NOT MODIFY BY HAND 2 | /// ***************************************************** 3 | /// FlutterGen 4 | /// ***************************************************** 5 | 6 | // coverage:ignore-file 7 | // ignore_for_file: type=lint 8 | // ignore_for_file: directives_ordering,unnecessary_import 9 | 10 | class FontFamily { 11 | FontFamily._(); 12 | 13 | /// Font family: bebas 14 | static const String bebas = 'bebas'; 15 | 16 | /// Font family: roboto 17 | static const String roboto = 'roboto'; 18 | } 19 | -------------------------------------------------------------------------------- /assets/icons/gmail.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/presentation/routes/app_route_names.dart: -------------------------------------------------------------------------------- 1 | abstract class AppRouteNames { 2 | static const String splashScreen = '/'; 3 | static const String homeScreen = '/home_screen'; 4 | static const String loginScreen = '/login_screen'; 5 | static const String signUpScreen = '/signup_screen'; 6 | static const String completeInfoScreen = '/complete_info_screen'; 7 | static const String forgetPassScreen = '/forget_password'; 8 | static const String savedArticleListScreen = '/savedArticleList'; 9 | static const String articleDetailScreen = '/articleDetailScreen'; 10 | static const String profileScreen = '/profileScreen'; 11 | } 12 | -------------------------------------------------------------------------------- /lib/Blocs/saved_article/saved_article_state.dart: -------------------------------------------------------------------------------- 1 | part of 'saved_article_cubit.dart'; 2 | 3 | abstract class SavedArticleState extends Equatable { 4 | const SavedArticleState(); 5 | 6 | @override 7 | List get props => []; 8 | } 9 | 10 | class SavedArticleLoadingState extends SavedArticleState {} 11 | 12 | class SavedArticleLoadedState extends SavedArticleState { 13 | final List
savedArticles; 14 | 15 | SavedArticleLoadedState(this.savedArticles); 16 | } 17 | 18 | class SavedArticleErrorState extends SavedArticleState { 19 | final String errorMsg; 20 | 21 | SavedArticleErrorState(this.errorMsg); 22 | } 23 | -------------------------------------------------------------------------------- /lib/data/models/articles/article_modle.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'article_modle.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | Article _$ArticleFromJson(Map json) => Article( 10 | body: json['body'] as String?, 11 | coverImageUrl: json['coverImageUrl'] as String?, 12 | title: json['title'] as String?, 13 | ); 14 | 15 | Map _$ArticleToJson(Article instance) => { 16 | 'title': instance.title, 17 | 'body': instance.body, 18 | 'coverImageUrl': instance.coverImageUrl, 19 | }; 20 | -------------------------------------------------------------------------------- /lib/data/models/user/user_modle.dart: -------------------------------------------------------------------------------- 1 | import 'package:blog_app/data/models/articles/article_modle.dart'; 2 | import 'package:json_annotation/json_annotation.dart'; 3 | 4 | part 'user_modle.g.dart'; 5 | 6 | @JsonSerializable() 7 | class AmataUser { 8 | String? userName; 9 | String? emailAddrress; 10 | String? uid; 11 | String? profileUrl; 12 | String? bio; 13 | List
? savedArticles; 14 | 15 | AmataUser( 16 | {this.emailAddrress, 17 | this.profileUrl, 18 | this.savedArticles, 19 | this.userName, 20 | this.uid, 21 | this.bio}); 22 | 23 | factory AmataUser.fromJson(Map json) => 24 | _$AmataUserFromJson(json); 25 | 26 | Map toJson() => _$AmataUserToJson(this); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.6.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.1.2' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | classpath 'com.google.gms:google-services:4.3.13' 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | google() 18 | mavenCentral() 19 | } 20 | } 21 | 22 | rootProject.buildDir = '../build' 23 | subprojects { 24 | project.buildDir = "${rootProject.buildDir}/${project.name}" 25 | } 26 | subprojects { 27 | project.evaluationDependsOn(':app') 28 | } 29 | 30 | task clean(type: Delete) { 31 | delete rootProject.buildDir 32 | } 33 | -------------------------------------------------------------------------------- /lib/Blocs/auth_bloc/auth_event.dart: -------------------------------------------------------------------------------- 1 | part of 'auth_bloc.dart'; 2 | 3 | abstract class AuthEvent extends Equatable { 4 | const AuthEvent(); 5 | 6 | @override 7 | List get props => []; 8 | } 9 | 10 | class LoginWithEmailEvent extends AuthEvent { 11 | final String emailAddress; 12 | final String password; 13 | const LoginWithEmailEvent( 14 | {required this.emailAddress, required this.password}); 15 | } 16 | 17 | class SignUpWithEmailEvent extends AuthEvent { 18 | final String emailAddress; 19 | final String password; 20 | const SignUpWithEmailEvent( 21 | {required this.emailAddress, required this.password}); 22 | } 23 | 24 | class ForgetPasswordEvent extends AuthEvent { 25 | final String emailAddress; 26 | const ForgetPasswordEvent({required this.emailAddress}); 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /lib/Blocs/home_bloc/home_state.dart: -------------------------------------------------------------------------------- 1 | part of 'home_bloc.dart'; 2 | 3 | abstract class HomeState extends Equatable { 4 | const HomeState(); 5 | 6 | @override 7 | List get props => []; 8 | } 9 | 10 | class HomeLoadingState extends HomeState {} 11 | 12 | class HomeLoadedState extends HomeState { 13 | final List
articles; 14 | final AmataUser? amataUser; 15 | const HomeLoadedState(this.articles, {this.amataUser}); 16 | } 17 | 18 | class HomeErrorState extends HomeState { 19 | final String error; 20 | const HomeErrorState(this.error); 21 | } 22 | 23 | class HomeArticleSavedState extends HomeState {} 24 | 25 | // class HomeArticleDeletedState extends HomeState {} 26 | 27 | class ArticleSaveErrorState extends HomeState { 28 | final String error; 29 | 30 | ArticleSaveErrorState(this.error); 31 | } 32 | -------------------------------------------------------------------------------- /lib/Blocs/home_bloc/home_event.dart: -------------------------------------------------------------------------------- 1 | part of 'home_bloc.dart'; 2 | 3 | abstract class HomeEvent extends Equatable { 4 | const HomeEvent(); 5 | 6 | @override 7 | List get props => []; 8 | } 9 | 10 | class LoadAllArticleEvent extends HomeEvent {} 11 | 12 | class LoadSavedArticlesEvent extends HomeEvent { 13 | final User currentUserUid; 14 | 15 | const LoadSavedArticlesEvent(this.currentUserUid); 16 | } 17 | 18 | class SaveArticleEvent extends HomeEvent { 19 | final Article selectedArticle; 20 | 21 | 22 | const SaveArticleEvent(this.selectedArticle, ); 23 | } 24 | 25 | // class RemoveSavedArticleEvent extends HomeEvent { 26 | // final Article selectedArticle; 27 | // final User currentUser; 28 | 29 | // const RemoveSavedArticleEvent(this.selectedArticle, this.currentUser); 30 | // } 31 | 32 | class GetProfileInfoEvent extends HomeEvent {} 33 | -------------------------------------------------------------------------------- /lib/Blocs/auth_bloc/auth_state.dart: -------------------------------------------------------------------------------- 1 | part of 'auth_bloc.dart'; 2 | 3 | enum AuthStatus { unknown, unAuthenticated, authenticated } 4 | 5 | abstract class AuthState extends Equatable { 6 | const AuthState(); 7 | 8 | @override 9 | List get props => []; 10 | } 11 | 12 | class UnknownState extends AuthState { 13 | final AuthStatus authStatus; 14 | 15 | const UnknownState(this.authStatus); 16 | } 17 | 18 | class UnAuthenticatedState extends AuthState { 19 | final AuthStatus authStatus; 20 | 21 | const UnAuthenticatedState(this.authStatus); 22 | } 23 | 24 | class AuthenticatedState extends AuthState { 25 | final User user; 26 | const AuthenticatedState(this.user); 27 | } 28 | 29 | class LoadingState extends AuthState {} 30 | 31 | class ErrorState extends AuthState { 32 | final String err; 33 | 34 | ErrorState(this.err); 35 | 36 | } 37 | 38 | class ForgetPasswordState extends AuthState{ 39 | 40 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | notes.md 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | **/doc/api/ 26 | **/ios/Flutter/.last_build_id 27 | .dart_tool/ 28 | .flutter-plugins 29 | .flutter-plugins-dependencies 30 | .packages 31 | .pub-cache/ 32 | .pub/ 33 | /build/ 34 | 35 | # Web related 36 | lib/generated_plugin_registrant.dart 37 | 38 | # Symbolication related 39 | app.*.symbols 40 | 41 | # Obfuscation related 42 | app.*.map.json 43 | 44 | # Android Studio will place build artifacts here 45 | /android/app/debug 46 | /android/app/profile 47 | /android/app/release 48 | -------------------------------------------------------------------------------- /lib/data/models/articles/article_modle.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:json_annotation/json_annotation.dart'; 4 | 5 | part 'article_modle.g.dart'; 6 | 7 | @JsonSerializable() 8 | @immutable 9 | class Article extends Equatable{ 10 | final String? title; 11 | final String? body; 12 | final String? coverImageUrl; 13 | Article({this.body, this.coverImageUrl, this.title}); 14 | 15 | factory Article.fromJson(Map json) => 16 | _$ArticleFromJson(json); 17 | 18 | Map toJson() => _$ArticleToJson(this); 19 | 20 | Article copyWith({String? title, String? body, String? coverImageUrl}) { 21 | return Article( 22 | title: title??this.title, 23 | body: body??this.body, 24 | coverImageUrl:coverImageUrl??this.coverImageUrl 25 | ); 26 | } 27 | 28 | @override 29 | List get props => [ 30 | body,title,coverImageUrl 31 | ]; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /lib/core/firebase_erro_helper.dart: -------------------------------------------------------------------------------- 1 | import 'package:firebase_auth/firebase_auth.dart'; 2 | 3 | extension AuthExceptionHandler on FirebaseAuthException { 4 | String getErrorMessage() { 5 | switch (this.code) { 6 | case "ERROR_INVALID_EMAIL": 7 | return "Your email address appears to be malformed."; 8 | 9 | case "ERROR_WRONG_PASSWORD": 10 | return "Your password is wrong."; 11 | 12 | case "ERROR_USER_NOT_FOUND": 13 | return "User with this email doesn't exist."; 14 | 15 | case "ERROR_USER_DISABLED": 16 | return "User with this email has been disabled."; 17 | 18 | case "ERROR_TOO_MANY_REQUESTS": 19 | return "Too many requests. Try again later."; 20 | 21 | case "ERROR_OPERATION_NOT_ALLOWED": 22 | return "Signing in with Email and Password is not enabled."; 23 | 24 | case "invalid-email": 25 | return "Provided Email is not valid"; 26 | 27 | 28 | default: 29 | return "An undefined Error happened."; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Amata Blog 2 | ## simple blog application with flutter and firebase 3 | ### screenshots 4 | 5 | 6 | 7 | ## what is Amata Blog? 8 | ### amata blog is a application witch enable its users to read and save article and in future will be able to write article into it. 9 | 10 | --- 11 | ## supported platforms 12 | 13 | 14 | --- 15 | ## TechStack 16 |

17 | 18 | 19 |

20 | 21 | --- 22 | ## Packages Used 23 | - flutter_bloc 24 | - beamer 25 | - firebase packages 26 | - flutter_svg 27 | - cached_network_image 28 | ## Architecture used: Bloc pattern 29 | --- 30 | ## How to contribute on this project? 31 | ### 1. create fork of project 32 | ### 2. clone project and open it by your own ide 33 | ### 3. make changes then push it to your copy repository 34 | ### 4. create pull request to our repository 35 | -------------------------------------------------------------------------------- /android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /lib/presentation/screens/global/widgets/button.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class AppButton extends StatelessWidget { 4 | final String hintText; 5 | final Color buttonColor; 6 | final VoidCallback onTap; 7 | final double width; 8 | final TextStyle? hintTextStyle; 9 | const AppButton( 10 | {Key? key, 11 | required this.hintText, 12 | required this.buttonColor, 13 | required this.onTap, 14 | required this.width, 15 | this.hintTextStyle}) 16 | : super(key: key); 17 | 18 | @override 19 | Widget build(BuildContext context) { 20 | return InkWell( 21 | onTap: onTap, 22 | child: Container( 23 | width: width, 24 | height: 50, 25 | decoration: BoxDecoration( 26 | borderRadius: BorderRadius.circular(25), color: buttonColor), 27 | child: Center( 28 | child: Text( 29 | hintText, 30 | style: 31 | hintTextStyle ?? TextStyle(color: Colors.white, fontSize: 20), 32 | ), 33 | ), 34 | ), 35 | ); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lib/data/repositories/pref_repository.dart: -------------------------------------------------------------------------------- 1 | import 'dart:developer'; 2 | 3 | import 'package:blog_app/core/core.dart'; 4 | import 'package:shared_preferences/shared_preferences.dart'; 5 | 6 | class PrefRepository { 7 | SharedPreferences? _appPref; 8 | static const _tokenKey = 'token'; 9 | 10 | PrefRepository() { 11 | _initPref(); 12 | } 13 | 14 | Future _initPref() async { 15 | _appPref = await SharedPreferences.getInstance(); 16 | } 17 | 18 | Future saveToken(String token) async { 19 | if (_appPref == null) { 20 | _appPref = await SharedPreferences.getInstance(); 21 | } 22 | try { 23 | var resulat = await _appPref!.setString(_tokenKey, token); 24 | } catch (e) { 25 | log(e.toString()); 26 | } 27 | } 28 | 29 | Future getToken() async { 30 | try { 31 | if (_appPref == null) { 32 | _appPref = await SharedPreferences.getInstance(); 33 | } 34 | String? token = _appPref?.getString(_tokenKey); 35 | return token; 36 | } catch (e) { 37 | return null; 38 | } 39 | } 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /lib/Blocs/splash_cubit/splash_cubit.dart: -------------------------------------------------------------------------------- 1 | import 'package:bloc/bloc.dart'; 2 | import 'package:blog_app/data/repositories/pref_repository.dart'; 3 | import 'package:equatable/equatable.dart'; 4 | import 'package:firebase_auth/firebase_auth.dart'; 5 | 6 | part 'splash_state.dart'; 7 | 8 | class SplashCubit extends Cubit { 9 | final PrefRepository _prefRepository = PrefRepository(); 10 | final FirebaseAuth _firebaseAuth = FirebaseAuth.instance; 11 | SplashCubit() : super(UnknownState()); 12 | // cheat's wheather user is login before or not 13 | cheackUserLogin() async { 14 | String? token = await _prefRepository.getToken(); 15 | if (token == null) { 16 | emit(UnRegisteredState()); 17 | } 18 | if (token != null) { 19 | User? user = _firebaseAuth.currentUser; 20 | String? userUid = await user?.uid; 21 | 22 | if (userUid != null) { 23 | if (token == userUid) { 24 | emit(RegisteredState()); 25 | } else { 26 | emit(UnRegisteredState()); 27 | } 28 | } else { 29 | emit(UnRegisteredState()); 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/data/models/user/user_modle.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'user_modle.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | AmataUser _$AmataUserFromJson(Map json) => AmataUser( 10 | emailAddrress: json['emailAddrress'] as String?, 11 | profileUrl: json['profileUrl'] as String?, 12 | savedArticles: (json['savedArticles'] as List?) 13 | ?.map((e) => Article.fromJson(e as Map)) 14 | .toList(), 15 | userName: json['userName'] as String?, 16 | uid: json['uid'] as String?, 17 | bio: json['bio'] as String?, 18 | ); 19 | 20 | Map _$AmataUserToJson(AmataUser instance) => { 21 | 'userName': instance.userName, 22 | 'emailAddrress': instance.emailAddrress, 23 | 'uid': instance.uid, 24 | 'profileUrl': instance.profileUrl, 25 | 'bio': instance.bio, 26 | 'savedArticles': instance.savedArticles, 27 | }; 28 | -------------------------------------------------------------------------------- /android/app/google-services.json: -------------------------------------------------------------------------------- 1 | { 2 | "project_info": { 3 | "project_number": "961655268214", 4 | "project_id": "amata-blog", 5 | "storage_bucket": "amata-blog.appspot.com" 6 | }, 7 | "client": [ 8 | { 9 | "client_info": { 10 | "mobilesdk_app_id": "1:961655268214:android:7f1a3e91b4f6c464af5057", 11 | "android_client_info": { 12 | "package_name": "com.example.amata_blog" 13 | } 14 | }, 15 | "oauth_client": [ 16 | { 17 | "client_id": "961655268214-armt7au9gl8o2ano32rltjq279ld1be5.apps.googleusercontent.com", 18 | "client_type": 1, 19 | "android_info": { 20 | "package_name": "com.example.amata_blog", 21 | "certificate_hash": "3df15ca132b58e43047d7b9650b7e462e6f9eb14" 22 | } 23 | }, 24 | { 25 | "client_id": "961655268214-jhtpohnvgfunh979redb27hisv9i118r.apps.googleusercontent.com", 26 | "client_type": 3 27 | } 28 | ], 29 | "api_key": [ 30 | { 31 | "current_key": "AIzaSyBDPhjtz-9mI1vgjggg2I_CZRcRk2sLFHw" 32 | } 33 | ], 34 | "services": { 35 | "appinvite_service": { 36 | "other_platform_oauth_client": [ 37 | { 38 | "client_id": "961655268214-jhtpohnvgfunh979redb27hisv9i118r.apps.googleusercontent.com", 39 | "client_type": 3 40 | } 41 | ] 42 | } 43 | } 44 | } 45 | ], 46 | "configuration_version": "1" 47 | } -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at 17 | # https://dart-lang.github.io/linter/lints/index.html. 18 | # 19 | # Instead of disabling a lint rule for the entire project in the 20 | # section below, it can also be suppressed for a single line of code 21 | # or a specific dart file by using the `// ignore: name_of_lint` and 22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 23 | # producing the lint. 24 | rules: 25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 27 | 28 | # Additional information about this file can be found at 29 | # https://dart.dev/guides/language/analysis-options 30 | -------------------------------------------------------------------------------- /lib/presentation/screens/splash/splash_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:beamer/beamer.dart'; 2 | import 'package:blog_app/Blocs/splash_cubit/splash_cubit.dart'; 3 | import 'package:blog_app/gen/assets.gen.dart'; 4 | import 'package:blog_app/presentation/routes/app_route_names.dart'; 5 | import 'package:flutter/material.dart'; 6 | import 'package:flutter_bloc/flutter_bloc.dart'; 7 | 8 | class SplashScreen extends StatelessWidget { 9 | Widget build(BuildContext context) { 10 | return Scaffold( 11 | body: BlocListener( 12 | listener: (context, state) async { 13 | if (state is UnRegisteredState) { 14 | await Future.delayed(Duration(seconds: 4)); 15 | 16 | Navigator.of(context) 17 | .pushReplacementNamed(AppRouteNames.signUpScreen); 18 | } 19 | if (state is RegisteredState) { 20 | await Future.delayed(Duration(seconds: 4)); 21 | Navigator.of(context) 22 | .pushReplacementNamed(AppRouteNames.homeScreen); 23 | } 24 | }, 25 | child: Column( 26 | mainAxisAlignment: MainAxisAlignment.center, 27 | children: [ 28 | Transform.scale( 29 | scale: 0.6, 30 | child: Image.asset( 31 | Assets.images.amataLogo.path, 32 | color: Colors.white, 33 | ), 34 | ), 35 | Text( 36 | 'Amata Blog', 37 | style: TextStyle(color: Colors.white, fontSize: 49), 38 | ) 39 | ], 40 | ), 41 | ), 42 | ); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 15 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled. 5 | 6 | version: 7 | revision: f1875d570e39de09040c8f79aa13cc56baab8db1 8 | channel: stable 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 17 | base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 18 | - platform: android 19 | create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 20 | base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 21 | - platform: ios 22 | create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 23 | base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 24 | - platform: linux 25 | create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 26 | base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 27 | - platform: macos 28 | create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 29 | base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 30 | - platform: web 31 | create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 32 | base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 33 | - platform: windows 34 | create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 35 | base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /lib/presentation/screens/global/widgets/feilds.dart: -------------------------------------------------------------------------------- 1 | import 'package:blog_app/gen/fonts.gen.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | class AppTextFormFeilds extends StatelessWidget { 5 | const AppTextFormFeilds({ 6 | Key? key, 7 | required this.hintText, 8 | required this.feildIcon, 9 | required this.isPasswordFeild, 10 | required this.controller, 11 | this.hintTextStyle, 12 | this.textStyle, 13 | this.isFilled, 14 | this.fillColor, 15 | this.borderDecoration, 16 | }) : super(key: key); 17 | final String hintText; 18 | final IconData feildIcon; 19 | final bool isPasswordFeild; 20 | final TextEditingController controller; 21 | final TextStyle? hintTextStyle; 22 | final TextStyle? textStyle; 23 | final bool? isFilled; 24 | final Color? fillColor; 25 | final InputBorder? borderDecoration; 26 | @override 27 | Widget build(BuildContext context) { 28 | // TODO: implement buildreturn 29 | return TextFormField( 30 | controller: controller, 31 | obscureText: isPasswordFeild, 32 | style: textStyle ?? 33 | TextStyle(color: Colors.white, fontFamily: FontFamily.roboto), 34 | decoration: InputDecoration( 35 | focusColor: Colors.white, 36 | fillColor: fillColor ?? Colors.grey, 37 | hintText: hintText, 38 | hintStyle: hintTextStyle ?? TextStyle(color: Colors.white), 39 | filled: isFilled ?? false, 40 | focusedBorder: borderDecoration ?? 41 | OutlineInputBorder( 42 | borderRadius: BorderRadius.circular(10), 43 | borderSide: BorderSide.none), 44 | enabledBorder: borderDecoration ?? 45 | OutlineInputBorder( 46 | borderRadius: BorderRadius.circular(10), 47 | borderSide: BorderSide.none), 48 | prefixIcon: Icon( 49 | feildIcon, 50 | color: Colors.white, 51 | ), 52 | ), 53 | ); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:beamer/beamer.dart'; 4 | import 'package:blog_app/gen/fonts.gen.dart'; 5 | import 'package:blog_app/presentation/routes/app_pages.dart'; 6 | import 'package:blog_app/presentation/screens/global/colors/solid_colors.dart'; 7 | import 'package:firebase_core/firebase_core.dart'; 8 | import 'package:flutter/material.dart'; 9 | 10 | Future main() async { 11 | WidgetsFlutterBinding.ensureInitialized(); 12 | await Firebase.initializeApp(); 13 | HttpOverrides.global = MyHttpOverrides(); 14 | runApp(const MyApp()); 15 | } 16 | 17 | class MyApp extends StatelessWidget { 18 | const MyApp({Key? key}) : super(key: key); 19 | // 1E1F28 20 | 21 | @override 22 | Widget build(BuildContext context) { 23 | return MaterialApp( 24 | 25 | darkTheme: ThemeData.dark(), 26 | themeMode: ThemeMode.system, 27 | 28 | theme: ThemeData( 29 | scaffoldBackgroundColor: SolidColors.gray, 30 | fontFamily: FontFamily.roboto, 31 | textTheme: TextTheme( 32 | headline1: TextStyle( 33 | fontSize: 35, 34 | fontFamily: FontFamily.bebas, 35 | color: Colors.white, 36 | fontWeight: FontWeight.bold), 37 | headline2: TextStyle( 38 | fontSize: 20, 39 | fontFamily: FontFamily.bebas, 40 | color: Colors.white, 41 | fontWeight: FontWeight.bold), 42 | caption: TextStyle( 43 | fontFamily: FontFamily.roboto, 44 | fontSize: 20, 45 | color: Colors.white))), 46 | debugShowCheckedModeBanner: false, 47 | routes: AppPages.routes, 48 | // home: const MyHomePage(title: 'Flutter Demo Home Page'), 49 | ); 50 | } 51 | } 52 | 53 | class MyHttpOverrides extends HttpOverrides { 54 | @override 55 | HttpClient createHttpClient(SecurityContext? context) { 56 | return super.createHttpClient(context) 57 | ..badCertificateCallback = 58 | (X509Certificate cert, String host, int port) => true; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /lib/data/repositories/home_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:blog_app/core/core.dart'; 2 | import 'package:blog_app/data/models/articles/article_modle.dart'; 3 | import 'package:blog_app/data/models/user/user_modle.dart'; 4 | import 'package:cloud_firestore/cloud_firestore.dart'; 5 | 6 | // handles hoem functions such fetching articles and fetching user profile and ... 7 | 8 | class HomeRepository { 9 | final CollectionReference _articleRef = FirebaseFirestore.instance 10 | .collection(FirebaseConstants.articlesCollection); 11 | final CollectionReference _userRef = 12 | FirebaseFirestore.instance.collection(FirebaseConstants.usersCollection); 13 | // fetch the all articles exists 14 | Future fetchAllPost() async { 15 | try { 16 | QuerySnapshot result = await _articleRef.get(); 17 | if (result.docs.isNotEmpty) { 18 | List> rawData = 19 | result.docs.map((e) => e.data() as Map).toList(); 20 | List
articles = 21 | rawData.map((e) => Article.fromJson(e)).toList(); 22 | return RawData( 23 | operationResult: OperationResult.success, data: articles); 24 | } else { 25 | return RawData( 26 | operationResult: OperationResult.fail, data: 'sth went wrong'); 27 | } 28 | } catch (e) { 29 | return RawData(operationResult: OperationResult.fail, data: e.toString()); 30 | } 31 | } 32 | 33 | Future fetchSavedArticle(String userUid) async { 34 | try { 35 | DocumentSnapshot result = await _userRef.doc(userUid).get(); 36 | if (result.exists) { 37 | Map rawData = result.data() as Map; 38 | List
savedArticle = rawData['savedArticles']; 39 | return RawData( 40 | operationResult: OperationResult.success, data: savedArticle); 41 | } else { 42 | return RawData( 43 | operationResult: OperationResult.fail, data: 'sth went wrong'); 44 | } 45 | } catch (e) { 46 | return RawData(operationResult: OperationResult.fail, data: e.toString()); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /lib/Blocs/saved_article/saved_article_cubit.dart: -------------------------------------------------------------------------------- 1 | import 'package:bloc/bloc.dart'; 2 | import 'package:blog_app/core/core.dart'; 3 | import 'package:blog_app/data/models/articles/article_modle.dart'; 4 | import 'package:blog_app/data/repositories/user_repository.dart'; 5 | import 'package:equatable/equatable.dart'; 6 | import 'package:firebase_auth/firebase_auth.dart'; 7 | 8 | part 'saved_article_state.dart'; 9 | 10 | class SavedArticleCubit extends Cubit { 11 | final UserRepositories _userRepository; 12 | SavedArticleCubit({UserRepositories? userRepository}) 13 | : _userRepository = userRepository ?? UserRepositories(), 14 | super(SavedArticleLoadingState()); 15 | 16 | Future getUserSavedArticles() async { 17 | RawData rawData = await UserRepositories().getUserSavedArticle(); 18 | if (rawData.operationResult == OperationResult.success) { 19 | emit(SavedArticleLoadedState(rawData.data)); 20 | } 21 | if (rawData.operationResult == OperationResult.fail) { 22 | emit(SavedArticleErrorState(rawData.data)); 23 | } 24 | } 25 | 26 | // removes article from reading list 27 | Future removeArticle(Article article) async { 28 | emit(SavedArticleLoadingState()); 29 | RawData rawData = 30 | await _userRepository.deleteArticleReadingList(article: article); 31 | 32 | if (rawData.operationResult == OperationResult.success) { 33 | await getUserSavedArticles(); 34 | } 35 | if (rawData.operationResult == OperationResult.fail) { 36 | emit(SavedArticleErrorState(rawData.data)); 37 | } 38 | } 39 | // FutureOr _removeArticle( 40 | // RemoveSavedArticleEvent event, Emitter emit) async { 41 | // emit(HomeLoadingState()); 42 | // RawData rawData = await _userRepository.deleteArticleReadingList( 43 | // user: event.currentUser, article: event.selectedArticle); 44 | // if (rawData.operationResult == OperationResult.success) { 45 | // emit(HomeLoadedState(_allArticles)); 46 | // } 47 | // if (rawData.operationResult == OperationResult.fail) { 48 | // emit(HomeErrorState(rawData.data)); 49 | // } 50 | // } 51 | } 52 | -------------------------------------------------------------------------------- /lib/Blocs/auth_bloc/auth_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:io'; 3 | 4 | import 'package:bloc/bloc.dart'; 5 | import 'package:equatable/equatable.dart'; 6 | import 'package:firebase_auth/firebase_auth.dart'; 7 | 8 | import 'package:blog_app/core/core.dart'; 9 | 10 | import 'package:blog_app/data/repositories/auth_repository.dart'; 11 | 12 | 13 | part 'auth_event.dart'; 14 | part 'auth_state.dart'; 15 | 16 | class AuthBloc extends Bloc { 17 | final AuthRepository _authRepository = AuthRepository(); 18 | AuthBloc() : super(const UnknownState(AuthStatus.unknown)) { 19 | on(_loginWithEmail); 20 | on(_signUpWithEmail); 21 | on(_forgetPassword); 22 | } 23 | 24 | Future _loginWithEmail( 25 | LoginWithEmailEvent event, Emitter emit) async { 26 | emit(LoadingState()); 27 | RawData result = await _authRepository.loginWithEmail( 28 | email: event.emailAddress, password: event.password); 29 | if (result.operationResult == OperationResult.success) { 30 | 31 | emit(AuthenticatedState(result.data)); 32 | } 33 | if (result.operationResult == OperationResult.fail) { 34 | emit(ErrorState(result.data.toString())); 35 | } 36 | } 37 | 38 | Future _signUpWithEmail( 39 | SignUpWithEmailEvent event, Emitter emit) async { 40 | emit(LoadingState()); 41 | 42 | RawData result = await _authRepository.signupWithEmail( 43 | email: event.emailAddress, password: event.password); 44 | if (result.operationResult == OperationResult.success) { 45 | emit(AuthenticatedState(result.data)); 46 | } 47 | if (result.operationResult == OperationResult.fail) { 48 | emit(ErrorState(result.data.toString())); 49 | } 50 | } 51 | 52 | Future _forgetPassword( 53 | ForgetPasswordEvent event, Emitter emit) async { 54 | try { 55 | emit(LoadingState()); 56 | 57 | RawData result = 58 | await _authRepository.forGetPassword(email: event.emailAddress); 59 | if (result.operationResult == OperationResult.success) { 60 | emit(ForgetPasswordState()); 61 | } 62 | if (result.operationResult == OperationResult.fail) { 63 | emit(ErrorState(result.data.toString())); 64 | } 65 | } catch (e) {} 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /lib/presentation/routes/app_pages.dart: -------------------------------------------------------------------------------- 1 | import 'package:beamer/beamer.dart'; 2 | import 'package:blog_app/Blocs/auth_bloc/auth_bloc.dart'; 3 | import 'package:blog_app/Blocs/home_bloc/home_bloc.dart'; 4 | import 'package:blog_app/Blocs/profile_cubit/profile_cubit.dart'; 5 | import 'package:blog_app/Blocs/saved_article/saved_article_cubit.dart'; 6 | import 'package:blog_app/Blocs/splash_cubit/splash_cubit.dart'; 7 | import 'package:blog_app/presentation/routes/app_route_names.dart'; 8 | import 'package:blog_app/presentation/screens/articles/article_detail_screen.dart'; 9 | import 'package:blog_app/presentation/screens/articles/saved_articles_list.dart'; 10 | import 'package:blog_app/presentation/screens/auth/forgetpassword_screen.dart'; 11 | import 'package:blog_app/presentation/screens/splash/splash_screen.dart'; 12 | import 'package:blog_app/presentation/screens/auth/complete_userinfo_screen.dart'; 13 | import 'package:blog_app/presentation/screens/user_profile/profile_screen.dart'; 14 | import 'package:flutter/material.dart'; 15 | import 'package:flutter_bloc/flutter_bloc.dart'; 16 | 17 | import '../screens/screens.dart'; 18 | 19 | class AppPages { 20 | static Map routes = { 21 | AppRouteNames.splashScreen: (context) => BlocProvider( 22 | create: (context) => SplashCubit()..cheackUserLogin(), 23 | child: SplashScreen(), 24 | ), 25 | AppRouteNames.homeScreen: (context) => BlocProvider( 26 | create: (context) => HomeBloc()..add(LoadAllArticleEvent()), 27 | child: HomeScreen()), 28 | AppRouteNames.loginScreen: (context) => 29 | BlocProvider(create: (context) => AuthBloc(), child: LoginScreen()), 30 | AppRouteNames.signUpScreen: (context) => 31 | BlocProvider(create: (context) => AuthBloc(), child: SignUpScreen()), 32 | AppRouteNames.completeInfoScreen: (context) => CompleteUserInformation(), 33 | AppRouteNames.forgetPassScreen: (context) => ForgetPasswordScreen(), 34 | AppRouteNames.savedArticleListScreen: (context) => BlocProvider( 35 | create: (context) => SavedArticleCubit()..getUserSavedArticles(), 36 | child: const SavedArticleScreen()), 37 | AppRouteNames.articleDetailScreen: (context) => const ArticleDetailScreen(), 38 | AppRouteNames.profileScreen:(context)=> BlocProvider( 39 | create: (context)=>ProfileCubit()..getUserInformation(), 40 | child: const ProfileScreen(), 41 | ) 42 | }; 43 | } 44 | -------------------------------------------------------------------------------- /assets/icons/phone.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/presentation/screens/articles/article_detail_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:beamer/beamer.dart'; 2 | import 'package:blog_app/data/models/articles/article_modle.dart'; 3 | import 'package:blog_app/presentation/screens/global/colors/solid_colors.dart'; 4 | import 'package:cached_network_image/cached_network_image.dart'; 5 | import 'package:flutter/material.dart'; 6 | import 'package:flutter_spinkit/flutter_spinkit.dart'; 7 | 8 | class ArticleDetailScreen extends StatelessWidget { 9 | const ArticleDetailScreen({ 10 | Key? key, 11 | }) : super(key: key); 12 | @override 13 | Widget build(BuildContext context) { 14 | Article article = ModalRoute.of(context)!.settings.arguments as Article; 15 | print(article.title); 16 | return WillPopScope( 17 | onWillPop: () async { 18 | Navigator.of(context).pop(); 19 | return true; 20 | }, 21 | child: Scaffold( 22 | appBar: AppBar( 23 | backgroundColor: SolidColors.kindGray, 24 | title: Text(article.title!), 25 | ), 26 | body: Column( 27 | crossAxisAlignment: CrossAxisAlignment.start, 28 | children: [ 29 | CachedNetworkImage( 30 | imageUrl: article.coverImageUrl!, 31 | placeholder: (context, url) => SpinKitDoubleBounce( 32 | color: SolidColors.red, 33 | ), 34 | errorWidget: ((context, url, error) => Container( 35 | width: MediaQuery.of(context).size.width, 36 | height: 200, 37 | child: Center( 38 | child: Icon( 39 | Icons.image_not_supported_outlined, 40 | size: 35, 41 | color: SolidColors.red, 42 | ), 43 | ), 44 | )), 45 | imageBuilder: (context, imageProvider) => Container( 46 | width: MediaQuery.of(context).size.width, 47 | height: 200, 48 | decoration: BoxDecoration( 49 | image: DecorationImage( 50 | image: imageProvider, fit: BoxFit.fill)), 51 | ), 52 | ), 53 | Padding( 54 | padding: EdgeInsets.all(12), 55 | child: Text( 56 | article.body!, 57 | style: TextStyle(color: Colors.white), 58 | ), 59 | ) 60 | ], 61 | ), 62 | )); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | // firebase config 28 | apply plugin: 'com.android.application' 29 | apply plugin: 'com.google.gms.google-services' 30 | android { 31 | compileSdkVersion flutter.compileSdkVersion 32 | ndkVersion flutter.ndkVersion 33 | compileOptions { 34 | sourceCompatibility JavaVersion.VERSION_1_8 35 | targetCompatibility JavaVersion.VERSION_1_8 36 | } 37 | 38 | kotlinOptions { 39 | jvmTarget = '1.8' 40 | } 41 | 42 | sourceSets { 43 | main.java.srcDirs += 'src/main/kotlin' 44 | } 45 | 46 | defaultConfig { 47 | 48 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 49 | applicationId "com.example.amata_blog" 50 | // You can update the following values to match your application needs. 51 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. 52 | minSdkVersion 20 53 | targetSdkVersion flutter.targetSdkVersion 54 | versionCode flutterVersionCode.toInteger() 55 | versionName flutterVersionName 56 | multiDexEnabled true 57 | 58 | } 59 | 60 | buildTypes { 61 | release { 62 | // TODO: Add your own signing config for the release build. 63 | // Signing with the debug keys for now, so `flutter run --release` works. 64 | signingConfig signingConfigs.debug 65 | } 66 | } 67 | } 68 | 69 | flutter { 70 | source '../..' 71 | } 72 | 73 | dependencies { 74 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 75 | // firebase depedncies 76 | implementation platform('com.google.firebase:firebase-bom:30.3.2') 77 | implementation 'com.google.firebase:firebase-analytics' 78 | implementation 'com.google.firebase:firebase-firestore:24.2.2' 79 | implementation 'com.google.firebase:firebase-auth:21.0.7' 80 | implementation 'com.google.firebase:firebase-storage:17.0.0' 81 | implementation 'com.google.firebase:firebase-auth' 82 | 83 | } 84 | -------------------------------------------------------------------------------- /lib/gen/assets.gen.dart: -------------------------------------------------------------------------------- 1 | /// GENERATED CODE - DO NOT MODIFY BY HAND 2 | /// ***************************************************** 3 | /// FlutterGen 4 | /// ***************************************************** 5 | 6 | // coverage:ignore-file 7 | // ignore_for_file: type=lint 8 | // ignore_for_file: directives_ordering,unnecessary_import 9 | 10 | import 'package:flutter/widgets.dart'; 11 | 12 | class $AssetsIconsGen { 13 | const $AssetsIconsGen(); 14 | 15 | /// File path: assets/icons/gmail.svg 16 | String get gmail => 'assets/icons/gmail.svg'; 17 | 18 | /// File path: assets/icons/phone.svg 19 | String get phone => 'assets/icons/phone.svg'; 20 | } 21 | 22 | class $AssetsImagesGen { 23 | const $AssetsImagesGen(); 24 | 25 | /// File path: assets/images/amataLogo.png 26 | AssetGenImage get amataLogo => 27 | const AssetGenImage('assets/images/amataLogo.png'); 28 | } 29 | 30 | class $AssetsLottiesGen { 31 | const $AssetsLottiesGen(); 32 | 33 | /// File path: assets/lotties/amta_loading.json 34 | String get amtaLoading => 'assets/lotties/amta_loading.json'; 35 | } 36 | 37 | class Assets { 38 | Assets._(); 39 | 40 | static const $AssetsIconsGen icons = $AssetsIconsGen(); 41 | static const $AssetsImagesGen images = $AssetsImagesGen(); 42 | static const $AssetsLottiesGen lotties = $AssetsLottiesGen(); 43 | } 44 | 45 | class AssetGenImage { 46 | const AssetGenImage(this._assetName); 47 | 48 | final String _assetName; 49 | 50 | Image image({ 51 | Key? key, 52 | AssetBundle? bundle, 53 | ImageFrameBuilder? frameBuilder, 54 | ImageErrorWidgetBuilder? errorBuilder, 55 | String? semanticLabel, 56 | bool excludeFromSemantics = false, 57 | double? scale, 58 | double? width, 59 | double? height, 60 | Color? color, 61 | Animation? opacity, 62 | BlendMode? colorBlendMode, 63 | BoxFit? fit, 64 | AlignmentGeometry alignment = Alignment.center, 65 | ImageRepeat repeat = ImageRepeat.noRepeat, 66 | Rect? centerSlice, 67 | bool matchTextDirection = false, 68 | bool gaplessPlayback = false, 69 | bool isAntiAlias = false, 70 | String? package, 71 | FilterQuality filterQuality = FilterQuality.low, 72 | int? cacheWidth, 73 | int? cacheHeight, 74 | }) { 75 | return Image.asset( 76 | _assetName, 77 | key: key, 78 | bundle: bundle, 79 | frameBuilder: frameBuilder, 80 | errorBuilder: errorBuilder, 81 | semanticLabel: semanticLabel, 82 | excludeFromSemantics: excludeFromSemantics, 83 | scale: scale, 84 | width: width, 85 | height: height, 86 | color: color, 87 | opacity: opacity, 88 | colorBlendMode: colorBlendMode, 89 | fit: fit, 90 | alignment: alignment, 91 | repeat: repeat, 92 | centerSlice: centerSlice, 93 | matchTextDirection: matchTextDirection, 94 | gaplessPlayback: gaplessPlayback, 95 | isAntiAlias: isAntiAlias, 96 | package: package, 97 | filterQuality: filterQuality, 98 | cacheWidth: cacheWidth, 99 | cacheHeight: cacheHeight, 100 | ); 101 | } 102 | 103 | String get path => _assetName; 104 | 105 | String get keyName => _assetName; 106 | } 107 | -------------------------------------------------------------------------------- /lib/Blocs/profile_cubit/profile_cubit.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:bloc/bloc.dart'; 4 | import 'package:blog_app/Blocs/auth_bloc/auth_bloc.dart'; 5 | import 'package:blog_app/core/core.dart'; 6 | import 'package:blog_app/data/models/user/user_modle.dart'; 7 | import 'package:blog_app/data/repositories/user_repository.dart'; 8 | import 'package:equatable/equatable.dart'; 9 | 10 | part 'profile_state.dart'; 11 | 12 | class ProfileCubit extends Cubit { 13 | final UserRepositories _userRepository; 14 | ProfileCubit({UserRepositories? userRepository}) 15 | : _userRepository = userRepository ?? UserRepositories(), 16 | super(ProfileLoadingState()); 17 | // gets last changes from server 18 | Future getUserInformation() async { 19 | RawData rawData = await _userRepository.getProfileInfo(); 20 | switch (rawData.operationResult) { 21 | case OperationResult.success: 22 | emit(ProfileLoadedState(rawData.data)); 23 | break; 24 | case OperationResult.fail: 25 | emit(ProfileErrorState(rawData.data)); 26 | break; 27 | 28 | case null: 29 | throw Exception('null check operator used on null value'); 30 | } 31 | } 32 | 33 | // updates user Email 34 | Future updateUserEmailAddress({required String emailAddress}) async { 35 | emit(ProfileLoadingState()); 36 | RawData rawData = await _userRepository.updateUserEmailAddress( 37 | newEmailAddres: emailAddress); 38 | 39 | switch (rawData.operationResult) { 40 | case (OperationResult.success): 41 | emit(ProfileLoadedState(rawData.data)); 42 | break; 43 | 44 | case (OperationResult.fail): 45 | emit(ProfileErrorState(rawData.data)); 46 | break; 47 | 48 | case (null): 49 | emit(ProfileErrorState('Some thing bad happened')); 50 | break; 51 | } 52 | } 53 | 54 | // updates user Name 55 | Future updateUserName({required String newUserName}) async { 56 | emit(ProfileLoadingState()); 57 | 58 | RawData rawData = 59 | await _userRepository.updateUserName(userName: newUserName); 60 | switch (rawData.operationResult) { 61 | case OperationResult.success: 62 | emit(ProfileLoadedState(rawData.data)); 63 | break; 64 | case OperationResult.fail: 65 | emit(ProfileErrorState(rawData.data)); 66 | break; 67 | case null: 68 | emit(ProfileErrorState('Some thing bad happened')); 69 | break; 70 | } 71 | } 72 | 73 | // updates user bio 74 | Future updateAddBio({required String bio}) async { 75 | emit(ProfileLoadingState()); 76 | 77 | RawData rawData = await _userRepository.updateOrAddBioForUser(bioText: bio); 78 | switch (rawData.operationResult) { 79 | case OperationResult.success: 80 | emit(ProfileLoadedState(rawData.data)); 81 | break; 82 | case OperationResult.fail: 83 | emit(ProfileErrorState(rawData.data)); 84 | break; 85 | case null: 86 | emit(ProfileErrorState('Some Thing went wrong')); 87 | break; 88 | } 89 | } 90 | 91 | // updates user profile 92 | Future updateProfilePhoto({required File profileImage}) async { 93 | emit(ProfileLoadingState()); 94 | RawData rawData = 95 | await _userRepository.updateUserProfile(profileImage: profileImage); 96 | switch (rawData.operationResult) { 97 | case OperationResult.success: 98 | emit(ProfileLoadedState(rawData.data)); 99 | break; 100 | case OperationResult.fail: 101 | emit(ProfileErrorState(rawData.data)); 102 | break; 103 | case null: 104 | emit(ProfileErrorState('Some Thing went wrong')); 105 | break; 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /lib/Blocs/home_bloc/home_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:bloc/bloc.dart'; 4 | import 'package:blog_app/core/core.dart'; 5 | import 'package:blog_app/data/models/articles/article_modle.dart'; 6 | import 'package:blog_app/data/models/user/user_modle.dart'; 7 | import 'package:blog_app/data/repositories/home_repository.dart'; 8 | import 'package:blog_app/data/repositories/user_repository.dart'; 9 | import 'package:equatable/equatable.dart'; 10 | import 'package:firebase_auth/firebase_auth.dart'; 11 | 12 | part 'home_event.dart'; 13 | part 'home_state.dart'; 14 | 15 | class HomeBloc extends Bloc { 16 | final HomeRepository _homeRepository; 17 | final UserRepositories _userRepository; 18 | HomeBloc({HomeRepository? homeRepository, UserRepositories? userRepository}) 19 | : _homeRepository = homeRepository ?? HomeRepository(), 20 | _userRepository = userRepository ?? UserRepositories(), 21 | super(HomeLoadingState()) { 22 | on(_loadAllArticle); 23 | on(_loadSavedArticles); 24 | on(_saveArticle); 25 | // on(_removeArticle); 26 | on(_getProfileInfo); 27 | } 28 | List
_allArticles = []; 29 | 30 | FutureOr _loadAllArticle( 31 | LoadAllArticleEvent event, Emitter emit) async { 32 | emit(HomeLoadingState()); 33 | print('called'); 34 | RawData rawData = await _homeRepository.fetchAllPost(); 35 | RawData rawProfileData = await _userRepository.getProfileInfo(); 36 | if (rawData.operationResult == OperationResult.success && 37 | rawProfileData.operationResult == OperationResult.success) { 38 | _allArticles = rawData.data; 39 | emit(HomeLoadedState(rawData.data, amataUser: rawProfileData.data)); 40 | } 41 | if (rawData.operationResult == OperationResult.fail) { 42 | emit(HomeErrorState(rawData.data)); 43 | } 44 | } 45 | 46 | FutureOr _loadSavedArticles( 47 | LoadSavedArticlesEvent event, Emitter emit) async { 48 | emit(HomeLoadingState()); 49 | RawData rawData = 50 | await _homeRepository.fetchSavedArticle(event.currentUserUid.uid); 51 | if (rawData.operationResult == OperationResult.success) { 52 | emit(HomeLoadedState(rawData.data)); 53 | } 54 | if (rawData.operationResult == OperationResult.fail) { 55 | emit(HomeErrorState(rawData.data)); 56 | } 57 | } 58 | 59 | FutureOr _saveArticle( 60 | SaveArticleEvent event, Emitter emit) async { 61 | emit(HomeLoadingState()); 62 | RawData rawData = await _userRepository.saveArticleToReadingList( 63 | article: event.selectedArticle); 64 | if (rawData.operationResult == OperationResult.success) { 65 | emit(HomeArticleSavedState()); 66 | emit(HomeLoadedState(_allArticles)); 67 | } 68 | if (rawData.operationResult == OperationResult.fail) { 69 | emit(ArticleSaveErrorState(rawData.data)); 70 | emit(HomeLoadedState(_allArticles)); 71 | 72 | // add(LoadAllArticleEvent()); 73 | } 74 | } 75 | 76 | // FutureOr _removeArticle( 77 | // RemoveSavedArticleEvent event, Emitter emit) async { 78 | // emit(HomeLoadingState()); 79 | // RawData rawData = await _userRepository.deleteArticleReadingList( 80 | // user: event.currentUser, article: event.selectedArticle); 81 | // if (rawData.operationResult == OperationResult.success) { 82 | // emit(HomeLoadedState(_allArticles)); 83 | // } 84 | // if (rawData.operationResult == OperationResult.fail) { 85 | // emit(HomeErrorState(rawData.data)); 86 | // } 87 | // } 88 | 89 | FutureOr _getProfileInfo( 90 | GetProfileInfoEvent event, Emitter emit) async { 91 | RawData rawData = await _userRepository.getProfileInfo(); 92 | if (rawData.operationResult == OperationResult.success) {} 93 | if (rawData.operationResult == OperationResult.fail) { 94 | emit(HomeErrorState(rawData.data)); 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /lib/presentation/screens/articles/saved_articles_list.dart: -------------------------------------------------------------------------------- 1 | import 'package:blog_app/Blocs/saved_article/saved_article_cubit.dart'; 2 | import 'package:blog_app/presentation/routes/app_route_names.dart'; 3 | import 'package:blog_app/presentation/screens/global/colors/solid_colors.dart'; 4 | import 'package:cached_network_image/cached_network_image.dart'; 5 | import 'package:flutter/material.dart'; 6 | import 'package:flutter_bloc/flutter_bloc.dart'; 7 | import 'package:flutter_spinkit/flutter_spinkit.dart'; 8 | 9 | class SavedArticleScreen extends StatelessWidget { 10 | const SavedArticleScreen({Key? key}) : super(key: key); 11 | 12 | @override 13 | Widget build(BuildContext context) { 14 | return Scaffold( 15 | appBar: AppBar( 16 | backgroundColor: SolidColors.kindGray, 17 | title: Text('Saved Article'), 18 | centerTitle: true, 19 | ), 20 | body: BlocBuilder( 21 | builder: (context, state) { 22 | if (state is SavedArticleLoadingState) { 23 | return Center( 24 | child: SpinKitDoubleBounce( 25 | color: SolidColors.red, 26 | ), 27 | ); 28 | } 29 | if (state is SavedArticleErrorState) { 30 | WidgetsBinding.instance.addPostFrameCallback((timeStamp) { 31 | showDialog( 32 | context: context, builder: (context) => AlertDialog()); 33 | }); 34 | } 35 | if (state is SavedArticleLoadedState) { 36 | print('loaded article'); 37 | return ListView.builder( 38 | physics: BouncingScrollPhysics(), 39 | itemCount: state.savedArticles.length, 40 | itemBuilder: (context, index) { 41 | return Padding( 42 | padding: const EdgeInsets.all(8.0), 43 | child: Card( 44 | color: SolidColors.kindGray, 45 | child: Padding( 46 | padding: EdgeInsets.all(8.0), 47 | child: ListTile( 48 | onTap: () { 49 | Navigator.of(context).pushNamed( 50 | AppRouteNames.articleDetailScreen, 51 | arguments: state.savedArticles[index]); 52 | }, 53 | trailing: IconButton( 54 | icon: const Icon( 55 | Icons.delete_outline, 56 | color: Colors.white, 57 | ), 58 | onPressed: () { 59 | BlocProvider.of(context) 60 | .removeArticle(state.savedArticles[index]); 61 | }, 62 | ), 63 | title: Text( 64 | state.savedArticles[index].title!, 65 | style: TextStyle(color: Colors.white), 66 | ), 67 | leading: CachedNetworkImage( 68 | imageUrl: state.savedArticles[index].coverImageUrl!, 69 | placeholder: ((context, url) => SpinKitDoubleBounce( 70 | color: SolidColors.red, 71 | )), 72 | errorWidget: ((context, url, error) => Icon( 73 | Icons.image_not_supported_outlined, 74 | size: 20, 75 | color: SolidColors.red, 76 | )), 77 | ), 78 | ), 79 | ), 80 | ), 81 | ); 82 | }, 83 | ); 84 | } 85 | return Container(); 86 | }, 87 | )); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /lib/data/repositories/auth_repository.dart: -------------------------------------------------------------------------------- 1 | import 'dart:developer'; 2 | import 'dart:io'; 3 | 4 | import 'package:blog_app/core/core.dart'; 5 | import 'package:blog_app/data/models/user/user_modle.dart'; 6 | import 'package:blog_app/data/repositories/pref_repository.dart'; 7 | import 'package:cloud_firestore/cloud_firestore.dart'; 8 | 9 | import 'package:firebase_auth/firebase_auth.dart'; 10 | import 'package:firebase_storage/firebase_storage.dart'; 11 | 12 | import 'package:blog_app/core/firebase_erro_helper.dart'; 13 | 14 | class AuthRepository { 15 | final PrefRepository _prefRepository; 16 | final FirebaseAuth _firebaseAuth; 17 | // FirebaseFirestore.instance.collection('users') 18 | AuthRepository( 19 | {FirebaseAuth? firebaseAuth, 20 | PrefRepository? prefRepository, 21 | FirebaseFirestore? userCollectionRef}) 22 | : _prefRepository = prefRepository ?? PrefRepository(), 23 | _firebaseAuth = firebaseAuth ?? FirebaseAuth.instance; 24 | // loges out user from firebase auth 25 | Future logOut() async { 26 | try { 27 | log('**********Loging out user**********', name: 'Auth_Repository'); 28 | var resualt = await _firebaseAuth.signOut(); 29 | return RawData(operationResult: OperationResult.success, data: true); 30 | } on FirebaseAuthException catch (e) { 31 | String message = e.getErrorMessage(); 32 | 33 | return RawData(operationResult: OperationResult.fail, data: message); 34 | } catch (e) { 35 | return RawData(operationResult: OperationResult.fail, data: e.toString()); 36 | } 37 | } 38 | 39 | // log in user with email and password 40 | Future loginWithEmail( 41 | {required String email, required String password}) async { 42 | try { 43 | log('**********Login user with {email:$email, password:$password }**********', 44 | name: 'Auth_Repository'); 45 | 46 | UserCredential user = await _firebaseAuth.signInWithEmailAndPassword( 47 | email: email, password: password); 48 | await _prefRepository.saveToken(user.credential!.token.toString()); 49 | String userUid = user.user!.uid; 50 | await _prefRepository.saveToken(userUid); 51 | return RawData(operationResult: OperationResult.success, data: user.user); 52 | } on FirebaseAuthException catch (e) { 53 | String message = e.getErrorMessage(); 54 | return RawData(operationResult: OperationResult.fail, data: message); 55 | } catch (e) { 56 | return RawData(operationResult: OperationResult.fail, data: e.toString()); 57 | } 58 | } 59 | 60 | Future signupWithEmail( 61 | {required String email, required String password}) async { 62 | try { 63 | log('**********sign in user with {email:$email, password:$password }**********', 64 | name: 'Auth_Repository'); 65 | 66 | UserCredential user = await _firebaseAuth.createUserWithEmailAndPassword( 67 | email: email, password: password); 68 | 69 | String userUid = user.user!.uid; 70 | await _prefRepository.saveToken(userUid); 71 | return RawData(operationResult: OperationResult.success, data: user.user); 72 | } on FirebaseAuthException catch (e) { 73 | String message = e.getErrorMessage(); 74 | 75 | return RawData(operationResult: OperationResult.fail, data: message); 76 | } catch (e) { 77 | return RawData(operationResult: OperationResult.fail, data: e.toString()); 78 | } 79 | } 80 | 81 | Future forGetPassword({required String email}) async { 82 | try { 83 | log('**********user forget password with {email:$email}**********', 84 | name: 'Auth_Repository'); 85 | 86 | await _firebaseAuth.sendPasswordResetEmail(email: email); 87 | return RawData(operationResult: OperationResult.success, data: true); 88 | } on FirebaseAuthException catch (e) { 89 | String message = e.getErrorMessage(); 90 | 91 | return RawData(operationResult: OperationResult.fail, data: message); 92 | } catch (e) { 93 | return RawData(operationResult: OperationResult.fail, data: e.toString()); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /lib/presentation/screens/auth/forgetpassword_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:blog_app/core/core.dart'; 2 | import 'package:blog_app/data/repositories/auth_repository.dart'; 3 | import 'package:blog_app/data/repositories/user_repository.dart'; 4 | import 'package:blog_app/gen/assets.gen.dart'; 5 | import 'package:blog_app/presentation/routes/app_route_names.dart'; 6 | import 'package:blog_app/presentation/screens/global/colors/solid_colors.dart'; 7 | import 'package:blog_app/presentation/screens/global/widgets/button.dart'; 8 | import 'package:blog_app/presentation/screens/global/widgets/feilds.dart'; 9 | 10 | import 'package:flutter/material.dart'; 11 | 12 | class ForgetPasswordScreen extends StatelessWidget { 13 | final TextEditingController emailController = TextEditingController(); 14 | @override 15 | Widget build(BuildContext context) { 16 | // TODO: implement build 17 | // throw UnimplementedError(); 18 | return Scaffold( 19 | body: SingleChildScrollView( 20 | physics: BouncingScrollPhysics(), 21 | child: Container( 22 | width: MediaQuery.of(context).size.width, 23 | height: MediaQuery.of(context).size.height, 24 | child: Column( 25 | mainAxisAlignment: MainAxisAlignment.center, 26 | children: [ 27 | Transform.scale( 28 | scale: 0.5, 29 | child: Image.asset( 30 | Assets.images.amataLogo.path, 31 | color: Colors.white, 32 | ), 33 | ), 34 | Text( 35 | 'Reset password link would send to your email', 36 | style: TextStyle(color: Colors.white, fontSize: 18), 37 | ), 38 | Padding( 39 | padding: const EdgeInsets.all(18.0), 40 | child: AppTextFormFeilds( 41 | hintText: 'Email', 42 | feildIcon: Icons.email_outlined, 43 | isPasswordFeild: false, 44 | controller: emailController, 45 | isFilled: true, 46 | fillColor: SolidColors.darkGrey, 47 | ), 48 | ), 49 | AppButton( 50 | hintText: 'Reset password', 51 | buttonColor: SolidColors.red, 52 | onTap: () { 53 | if (emailController.text.isNotEmpty) { 54 | showDialog( 55 | context: context, 56 | builder: (context) => AlertDialog( 57 | actions: [ 58 | Center( 59 | child: Card( 60 | color: SolidColors.lightGrey, 61 | child: TextButton( 62 | onPressed: () { 63 | AuthRepository().forGetPassword( 64 | email: emailController.text); 65 | 66 | Navigator.of(context).pushReplacementNamed( 67 | AppRouteNames.loginScreen); 68 | }, 69 | child: Text( 70 | 'Ok', 71 | style: TextStyle(color: Colors.white), 72 | )), 73 | )) 74 | ], 75 | content: Text( 76 | 'Reset Password link sent to your sandbox', 77 | style: TextStyle(color: Colors.white), 78 | ), 79 | backgroundColor: SolidColors.darkGrey, 80 | ), 81 | ); 82 | } else { 83 | ScaffoldMessenger.of(context).showSnackBar( 84 | SnackBar(content: Text('Feild couldn\'t be empty'))); 85 | } 86 | // .then((value) { 87 | // showDialog( 88 | // context: context, 89 | // builder: (context) => AlertDialog( 90 | // title: Text('Alert'), 91 | // content: Text('Reset Password link sent to your email,cheack spam folder'), 92 | // )); 93 | // }); 94 | // } 95 | }, 96 | width: MediaQuery.of(context).size.width * .5) 97 | ], 98 | ), 99 | ), 100 | ), 101 | ); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: blog_app 2 | description: A new Flutter project. 3 | 4 | # The following line prevents the package from being accidentally published to 5 | # pub.dev using `flutter pub publish`. This is preferred for private packages. 6 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev 7 | 8 | # The following defines the version and build number for your application. 9 | # A version number is three numbers separated by dots, like 1.2.43 10 | # followed by an optional build number separated by a +. 11 | # Both the version and the builder number may be overridden in flutter 12 | # build by specifying --build-name and --build-number, respectively. 13 | # In Android, build-name is used as versionName while build-number used as versionCode. 14 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 15 | # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. 16 | # Read more about iOS versioning at 17 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 18 | version: 1.0.0+1 19 | 20 | environment: 21 | sdk: ">=2.17.6 <3.0.0" 22 | 23 | # Dependencies specify other packages that your package needs in order to work. 24 | # To automatically upgrade your package dependencies to the latest versions 25 | # consider running `flutter pub upgrade --major-versions`. Alternatively, 26 | # dependencies can be manually updated by changing the version numbers below to 27 | # the latest version available on pub.dev. To see which dependencies have newer 28 | # versions available, run `flutter pub outdated`. 29 | dependencies: 30 | flutter: 31 | sdk: flutter 32 | 33 | 34 | # The following adds the Cupertino Icons font to your application. 35 | # Use with the CupertinoIcons class for iOS style icons. 36 | # cupertino icons 37 | cupertino_icons: ^1.0.2 38 | # firebase integrations plugin 39 | cloud_firestore: ^3.4.5 40 | firebase_core: ^1.21.0 41 | firebase_auth: ^3.6.4 42 | # state management 43 | flutter_bloc: ^8.1.1 44 | # value quality 45 | equatable: ^2.0.5 46 | # data serlizer 47 | json_annotation: ^4.6.0 48 | # navigation staff 49 | beamer: ^1.5.2 50 | # for using svg in project 51 | flutter_svg: ^1.1.4 52 | # firbase database 53 | firebase_storage: ^10.3.7 54 | shared_preferences: ^2.0.15 55 | image_picker: ^0.8.5+3 56 | cached_network_image: ^3.2.1 57 | flutter_spinkit: ^5.1.0 58 | lottie: ^1.4.2 59 | # for storing user information 60 | # sharedpreference: ^0.0.1 61 | # firebase_auth_mocks: ^0.8.5+1 62 | dev_dependencies: 63 | flutter_test: 64 | sdk: flutter 65 | 66 | # The "flutter_lints" package below contains a set of recommended lints to 67 | # encourage good coding practices. The lint set provided by the package is 68 | # activated in the `analysis_options.yaml` file located at the root of your 69 | # package. See that file for information about deactivating specific lint 70 | # rules and activating additional ones. 71 | flutter_lints: ^2.0.0 72 | build_runner: ^2.2.0 73 | json_serializable: ^6.3.1 74 | mockito: ^5.3.0 75 | rxdart: ^0.27.5 76 | 77 | # For information on the generic Dart part of this file, see the 78 | # following page: https://dart.dev/tools/pub/pubspec 79 | 80 | # The following section is specific to Flutter packages. 81 | flutter: 82 | 83 | # The following line ensures that the Material Icons font is 84 | # included with your application, so that you can use the icons in 85 | # the material Icons class. 86 | uses-material-design: true 87 | 88 | # To add assets to your application, add an assets section, like this: 89 | assets: 90 | - assets/images/ 91 | - assets/icons/ 92 | - assets/lotties/ 93 | # - images/a_dot_burr.jpeg 94 | # - images/a_dot_burr.jpeg 95 | # - images/a_dot_ham.jpeg 96 | 97 | # An image asset can refer to one or more resolution-specific "variants", see 98 | # https://flutter.dev/assets-and-images/#resolution-aware 99 | 100 | # For details regarding adding assets from package dependencies, see 101 | # https://flutter.dev/assets-and-images/#from-packages 102 | 103 | # To add custom fonts to your application, add a fonts section here, 104 | # in this "flutter" section. Each entry in this list should have a 105 | # "family" key with the font family name, and a "fonts" key with a 106 | # list giving the asset and other descriptors for the font. For 107 | # example: 108 | fonts: 109 | - family: bebas 110 | fonts: 111 | - asset: assets/fonts/BebasNeue-Regular.ttf 112 | # - asset: fonts/Schyler-Italic.ttf 113 | # style: italic 114 | - family: roboto 115 | fonts: 116 | - asset: assets/fonts/Roboto-Medium.ttf 117 | # - asset: fonts/TrajanPro_Bold.ttf 118 | # weight: 700 119 | 120 | # 121 | # For details regarding fonts from package dependencies, 122 | # see https://flutter.dev/custom-fonts/#from-packages 123 | -------------------------------------------------------------------------------- /lib/presentation/screens/auth/signup.dart: -------------------------------------------------------------------------------- 1 | import 'package:blog_app/gen/assets.gen.dart'; 2 | import 'package:blog_app/gen/fonts.gen.dart'; 3 | import 'package:blog_app/Blocs/auth_bloc/auth_bloc.dart'; 4 | import 'package:blog_app/presentation/routes/app_route_names.dart'; 5 | import 'package:blog_app/presentation/screens/global/colors/solid_colors.dart'; 6 | import 'package:blog_app/presentation/screens/global/widgets/button.dart'; 7 | import 'package:blog_app/presentation/screens/global/widgets/feilds.dart'; 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_bloc/flutter_bloc.dart'; 10 | import 'package:flutter_svg/flutter_svg.dart'; 11 | import 'package:lottie/lottie.dart'; 12 | 13 | class SignUpScreen extends StatelessWidget { 14 | SignUpScreen({Key? key}) : super(key: key); 15 | TextEditingController emailTextcontroller = TextEditingController(); 16 | TextEditingController passwordTextcontroller = TextEditingController(); 17 | // TextEditingController userNameTextcontroller = TextEditingController(); 18 | 19 | @override 20 | Widget build(BuildContext context) { 21 | return Scaffold( 22 | body: _builBody(context), 23 | ); 24 | } 25 | 26 | _builBody(BuildContext context) { 27 | double width = MediaQuery.of(context).size.width; 28 | double height = MediaQuery.of(context).size.height; 29 | return BlocListener( 30 | listener: ((context, state) { 31 | if (state is AuthenticatedState) { 32 | print('authenticated'); 33 | 34 | Navigator.of(context).pushReplacementNamed( 35 | AppRouteNames.completeInfoScreen, 36 | arguments: {'user': state.user}); 37 | } 38 | 39 | if(state is LoadingState){ 40 | WidgetsBinding.instance.addPostFrameCallback((timeStamp) { 41 | showDialog(context: context, builder: (context)=>Dialog( 42 | child: Container( 43 | height: MediaQuery.of(context).size.height/4, 44 | width: MediaQuery.of(context).size.width, 45 | color: SolidColors.darkGrey, 46 | padding: EdgeInsets.all(10), 47 | 48 | child: Center( 49 | child: Lottie.asset(Assets.lotties.amtaLoading ), 50 | ), 51 | ), 52 | )); 53 | }); 54 | } 55 | 56 | if (state is ErrorState) { 57 | WidgetsBinding.instance.addPostFrameCallback((timeStamp) { 58 | ScaffoldMessenger.of(context) 59 | .showSnackBar(SnackBar(content: Text(state.err))); 60 | }); 61 | 62 | } 63 | }), 64 | child: SingleChildScrollView( 65 | physics: BouncingScrollPhysics(), 66 | child: Container( 67 | width: width, 68 | height: height, 69 | padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10), 70 | child: Column( 71 | mainAxisAlignment: MainAxisAlignment.spaceEvenly, 72 | children: [ 73 | Transform.scale( 74 | scale: 0.4, 75 | child: Image.asset( 76 | Assets.images.amataLogo.path, 77 | color: Colors.white, 78 | ), 79 | ), 80 | Text( 81 | 'Amata Blog', 82 | style: Theme.of(context).textTheme.displaySmall!.copyWith( 83 | color: Colors.white, fontFamily: FontFamily.bebas), 84 | ), 85 | AppTextFormFeilds( 86 | hintText: 'Enter Your Email here', 87 | isFilled: true, 88 | fillColor: SolidColors.darkGrey, 89 | feildIcon: Icons.email_outlined, 90 | isPasswordFeild: false, 91 | controller: emailTextcontroller), 92 | AppTextFormFeilds( 93 | isFilled: true, 94 | fillColor: SolidColors.darkGrey, 95 | hintText: 'Enter Your Password here', 96 | feildIcon: Icons.lock_open_rounded, 97 | isPasswordFeild: true, 98 | controller: passwordTextcontroller, 99 | ), 100 | AppButton( 101 | onTap: () { 102 | BlocProvider.of(context).add(SignUpWithEmailEvent( 103 | emailAddress: emailTextcontroller.text, 104 | password: passwordTextcontroller.text)); 105 | }, 106 | buttonColor: SolidColors.red, 107 | width: width, 108 | hintText: 'Signup', 109 | ), 110 | // Row( 111 | // mainAxisAlignment: MainAxisAlignment.spaceEvenly, 112 | // children: [ 113 | // Container( 114 | // width: 70, 115 | // height: 70, 116 | // padding: EdgeInsets.all(12), 117 | // decoration: BoxDecoration( 118 | // color: SolidColors.darkGrey, 119 | // borderRadius: BorderRadius.circular(12)), 120 | // child: Center( 121 | // child: SvgPicture.asset(Assets.icons.gmail), 122 | // ), 123 | // ), 124 | // Container( 125 | // width: 70, 126 | // height: 70, 127 | // padding: EdgeInsets.all(12), 128 | // decoration: BoxDecoration( 129 | // color: SolidColors.darkGrey, 130 | // borderRadius: BorderRadius.circular(12)), 131 | // child: Center( 132 | // child: Transform.scale( 133 | // scale: 0.7, 134 | // child: SvgPicture.asset( 135 | // Assets.icons.phone, 136 | // )), 137 | // ), 138 | // ) 139 | // ], 140 | // ), 141 | TextButton( 142 | onPressed: () { 143 | Navigator.of(context) 144 | .pushReplacementNamed(AppRouteNames.loginScreen); 145 | }, 146 | child: RichText( 147 | text: TextSpan(text: 'Have an account?', children: [ 148 | TextSpan( 149 | text: 'Login', style: TextStyle(color: SolidColors.red)) 150 | ]))), 151 | ], 152 | ), 153 | ), 154 | ), 155 | ); 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /lib/presentation/screens/auth/login_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:blog_app/gen/assets.gen.dart'; 2 | import 'package:blog_app/gen/fonts.gen.dart'; 3 | import 'package:blog_app/Blocs/auth_bloc/auth_bloc.dart'; 4 | 5 | import 'package:blog_app/presentation/routes/app_route_names.dart'; 6 | import 'package:blog_app/presentation/screens/global/colors/solid_colors.dart'; 7 | import 'package:blog_app/presentation/screens/global/widgets/button.dart'; 8 | import 'package:blog_app/presentation/screens/global/widgets/feilds.dart'; 9 | import 'package:flutter/cupertino.dart'; 10 | import 'package:flutter/material.dart'; 11 | import 'package:flutter_bloc/flutter_bloc.dart'; 12 | import 'package:flutter_spinkit/flutter_spinkit.dart'; 13 | import 'package:flutter_svg/flutter_svg.dart'; 14 | import 'package:lottie/lottie.dart'; 15 | 16 | class LoginScreen extends StatelessWidget { 17 | LoginScreen({Key? key}) : super(key: key); 18 | TextEditingController emailController = TextEditingController(); 19 | TextEditingController passwordController = TextEditingController(); 20 | @override 21 | Widget build(BuildContext context) { 22 | return Scaffold( 23 | body: _builtBody(context), 24 | ); 25 | } 26 | 27 | _builtBody(BuildContext context) { 28 | double width = MediaQuery.of(context).size.width; 29 | double height = MediaQuery.of(context).size.height; 30 | return BlocListener( 31 | child: SingleChildScrollView( 32 | physics: BouncingScrollPhysics(), 33 | child: Container( 34 | width: width, 35 | height: height, 36 | padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10), 37 | child: Column( 38 | mainAxisAlignment: MainAxisAlignment.spaceEvenly, 39 | children: [ 40 | Transform.scale( 41 | scale: 0.4, 42 | child: Image.asset( 43 | Assets.images.amataLogo.path, 44 | color: Colors.white, 45 | ), 46 | ), 47 | Text( 48 | 'Amata Blog', 49 | style: Theme.of(context).textTheme.displaySmall!.copyWith( 50 | color: Colors.white, fontFamily: FontFamily.bebas), 51 | ), 52 | AppTextFormFeilds( 53 | hintText: 'Enter Your Email here', 54 | isFilled: true, 55 | fillColor: SolidColors.darkGrey, 56 | feildIcon: Icons.email_outlined, 57 | isPasswordFeild: false, 58 | controller: emailController), 59 | AppTextFormFeilds( 60 | isFilled: true, 61 | fillColor: SolidColors.darkGrey, 62 | hintText: 'Enter Your Password here', 63 | feildIcon: Icons.lock_open_rounded, 64 | isPasswordFeild: true, 65 | controller: passwordController, 66 | ), 67 | AppButton( 68 | onTap: () { 69 | BlocProvider.of(context).add(LoginWithEmailEvent( 70 | emailAddress: emailController.text, 71 | password: passwordController.text)); 72 | }, 73 | buttonColor: SolidColors.red, 74 | hintText: 'Login', 75 | width: width, 76 | ), 77 | // Row( 78 | // mainAxisAlignment: MainAxisAlignment.spaceEvenly, 79 | // children: [ 80 | // Container( 81 | // width: 70, 82 | // height: 70, 83 | // padding: EdgeInsets.all(12), 84 | // decoration: BoxDecoration( 85 | // color: SolidColors.darkGrey, 86 | // borderRadius: BorderRadius.circular(12)), 87 | // child: Center( 88 | // child: SvgPicture.asset(Assets.icons.gmail), 89 | // ), 90 | // ), 91 | // Container( 92 | // width: 70, 93 | // height: 70, 94 | // padding: EdgeInsets.all(12), 95 | // decoration: BoxDecoration( 96 | // color: SolidColors.darkGrey, 97 | // borderRadius: BorderRadius.circular(12)), 98 | // child: Center( 99 | // child: Transform.scale( 100 | // scale: 0.7, 101 | // child: SvgPicture.asset( 102 | // Assets.icons.phone, 103 | // )), 104 | // ), 105 | // ) 106 | // ], 107 | // ), 108 | TextButton( 109 | onPressed: () { 110 | Navigator.of(context) 111 | .pushReplacementNamed(AppRouteNames.signUpScreen); 112 | }, 113 | child: RichText( 114 | text: TextSpan(text: 'Don\'t have account?', children: [ 115 | TextSpan( 116 | text: 'SignUp', 117 | style: TextStyle(color: SolidColors.red)) 118 | ]))), 119 | TextButton( 120 | onPressed: () { 121 | //TODO: navigate to forgot password page 122 | 123 | Navigator.of(context).pushReplacementNamed( 124 | AppRouteNames.forgetPassScreen, 125 | arguments: emailController.text); 126 | }, 127 | child: RichText( 128 | text: TextSpan(text: 'Forgot password?', children: [ 129 | TextSpan( 130 | text: 'reset Password', 131 | style: TextStyle(color: SolidColors.red)) 132 | ]))), 133 | ], 134 | ), 135 | ), 136 | ), 137 | listener: (context, state) { 138 | if (state is LoadingState) { 139 | WidgetsBinding.instance.addPostFrameCallback((timeStamp) { 140 | showDialog( 141 | context: context, 142 | builder: (context) => AlertDialog( 143 | content: SpinKitDoubleBounce( 144 | color: SolidColors.red, 145 | ), 146 | )); 147 | }); 148 | } 149 | if(state is LoadingState){ 150 | WidgetsBinding.instance.addPostFrameCallback((timeStamp) { 151 | showDialog(context: context, builder: (context)=>Dialog( 152 | child: Container( 153 | width: MediaQuery.of(context).size.width, 154 | height: MediaQuery.of(context).size.height/4, 155 | color: SolidColors.darkGrey, 156 | 157 | 158 | child: Center( 159 | child: Lottie.asset(Assets.lotties.amtaLoading ), 160 | ), 161 | ), 162 | )); 163 | }); 164 | } 165 | if (state is AuthenticatedState) { 166 | print('authenticated'); 167 | 168 | Navigator.of(context).pushReplacementNamed(AppRouteNames.homeScreen, 169 | arguments: {'user': state.user}); 170 | } 171 | if (state is ErrorState) { 172 | WidgetsBinding.instance.addPostFrameCallback((timeStamp) { 173 | ScaffoldMessenger.of(context) 174 | .showSnackBar(SnackBar(content: Text(state.err))); 175 | }); 176 | } 177 | }); 178 | } 179 | } 180 | /* return */ 181 | -------------------------------------------------------------------------------- /assets/lotties/amta_loading.json: -------------------------------------------------------------------------------- 1 | {"v":"4.8.0","meta":{"g":"LottieFiles AE 1.0.0","a":"","k":"","d":"","tc":"none"},"fr":60,"ip":9,"op":40,"w":300,"h":300,"nm":"Comp 1","ddd":0,"assets":[{"id":"comp_0","layers":[{"ddd":0,"ind":1,"ty":4,"nm":"ball4","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"s":true,"x":{"a":0,"k":223,"ix":3},"y":{"a":1,"k":[{"i":{"x":[0.465],"y":[1]},"o":{"x":[0.534],"y":[0]},"t":25,"s":[169.5]},{"i":{"x":[0.424],"y":[1]},"o":{"x":[0.514],"y":[0]},"t":40,"s":[129.5]},{"i":{"x":[0.465],"y":[1]},"o":{"x":[0.054],"y":[0]},"t":55,"s":[169.5]},{"t":70,"s":[129.5]}],"ix":4}},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,-14.359],[14.359,0],[0,14.359],[-14.359,0]],"o":[[0,14.359],[-14.359,0],[0,-14.359],[14.359,0]],"v":[[26,0],[0,26],[-26,0],[0,-26]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.9372549019607843,0.21176470588235294,0.3176470588235294,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":40,"op":71,"st":25,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"ball 4","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"s":true,"x":{"a":0,"k":150,"ix":3},"y":{"a":1,"k":[{"i":{"x":[0.465],"y":[1]},"o":{"x":[0.534],"y":[0]},"t":20,"s":[169.5]},{"i":{"x":[0.424],"y":[1]},"o":{"x":[0.514],"y":[0]},"t":35,"s":[129.5]},{"i":{"x":[0.465],"y":[1]},"o":{"x":[0.054],"y":[0]},"t":50,"s":[169.5]},{"t":65,"s":[129.5]}],"ix":4}},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,-14.359],[14.359,0],[0,14.359],[-14.359,0]],"o":[[0,14.359],[-14.359,0],[0,-14.359],[14.359,0]],"v":[[26,0],[0,26],[-26,0],[0,-26]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.9372549019607843,0.21176470588235294,0.3176470588235294,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":35,"op":66,"st":20,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"ball 3","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"s":true,"x":{"a":0,"k":77,"ix":3},"y":{"a":1,"k":[{"i":{"x":[0.465],"y":[1]},"o":{"x":[0.534],"y":[0]},"t":15,"s":[169.5]},{"i":{"x":[0.424],"y":[1]},"o":{"x":[0.514],"y":[0]},"t":30,"s":[129.5]},{"i":{"x":[0.465],"y":[1]},"o":{"x":[0.054],"y":[0]},"t":45,"s":[169.5]},{"t":60,"s":[129.5]}],"ix":4}},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,-14.359],[14.359,0],[0,14.359],[-14.359,0]],"o":[[0,14.359],[-14.359,0],[0,-14.359],[14.359,0]],"v":[[26,0],[0,26],[-26,0],[0,-26]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.9372549019607843,0.21176470588235294,0.3176470588235294,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":30,"op":61,"st":15,"bm":0},{"ddd":0,"ind":4,"ty":4,"nm":"ball3","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"s":true,"x":{"a":0,"k":223,"ix":3},"y":{"a":1,"k":[{"i":{"x":[0.465],"y":[1]},"o":{"x":[0.534],"y":[0]},"t":-6,"s":[169.5]},{"i":{"x":[0.424],"y":[1]},"o":{"x":[0.514],"y":[0]},"t":9,"s":[129.5]},{"i":{"x":[0.465],"y":[1]},"o":{"x":[0.054],"y":[0]},"t":24,"s":[169.5]},{"t":39,"s":[129.5]}],"ix":4}},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,-14.359],[14.359,0],[0,14.359],[-14.359,0]],"o":[[0,14.359],[-14.359,0],[0,-14.359],[14.359,0]],"v":[[26,0],[0,26],[-26,0],[0,-26]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.9372549019607843,0.21176470588235294,0.3176470588235294,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":9,"op":40,"st":-6,"bm":0},{"ddd":0,"ind":5,"ty":4,"nm":"ball 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"s":true,"x":{"a":0,"k":150,"ix":3},"y":{"a":1,"k":[{"i":{"x":[0.465],"y":[1]},"o":{"x":[0.534],"y":[0]},"t":-11,"s":[169.5]},{"i":{"x":[0.424],"y":[1]},"o":{"x":[0.514],"y":[0]},"t":4,"s":[129.5]},{"i":{"x":[0.465],"y":[1]},"o":{"x":[0.054],"y":[0]},"t":19,"s":[169.5]},{"t":34,"s":[129.5]}],"ix":4}},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,-14.359],[14.359,0],[0,14.359],[-14.359,0]],"o":[[0,14.359],[-14.359,0],[0,-14.359],[14.359,0]],"v":[[26,0],[0,26],[-26,0],[0,-26]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.9372549019607843,0.21176470588235294,0.3176470588235294,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":4,"op":35,"st":-11,"bm":0},{"ddd":0,"ind":6,"ty":4,"nm":"ball 1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"s":true,"x":{"a":0,"k":77,"ix":3},"y":{"a":1,"k":[{"i":{"x":[0.465],"y":[1]},"o":{"x":[0.534],"y":[0]},"t":-16,"s":[169.5]},{"i":{"x":[0.424],"y":[1]},"o":{"x":[0.514],"y":[0]},"t":-1,"s":[129.5]},{"i":{"x":[0.465],"y":[1]},"o":{"x":[0.054],"y":[0]},"t":14,"s":[169.5]},{"t":29,"s":[129.5]}],"ix":4}},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,-14.359],[14.359,0],[0,14.359],[-14.359,0]],"o":[[0,14.359],[-14.359,0],[0,-14.359],[14.359,0]],"v":[[26,0],[0,26],[-26,0],[0,-26]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.9372549019607843,0.21176470588235294,0.3176470588235294,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":-1,"op":30,"st":-16,"bm":0}]}],"layers":[{"ddd":0,"ind":1,"ty":0,"nm":"Pre-comp 1","refId":"comp_0","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[150,150,0],"ix":2},"a":{"a":0,"k":[150,150,0],"ix":1},"s":{"a":0,"k":[41,41,100],"ix":6}},"ao":0,"w":300,"h":300,"ip":0,"op":211,"st":0,"bm":0}],"markers":[]} -------------------------------------------------------------------------------- /lib/presentation/screens/auth/complete_userinfo_screen.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:blog_app/core/core.dart'; 4 | import 'package:blog_app/data/repositories/user_repository.dart'; 5 | import 'package:blog_app/gen/assets.gen.dart'; 6 | import 'package:blog_app/gen/fonts.gen.dart'; 7 | import 'package:blog_app/presentation/routes/app_route_names.dart'; 8 | import 'package:blog_app/presentation/screens/global/colors/solid_colors.dart'; 9 | import 'package:blog_app/presentation/screens/global/widgets/button.dart'; 10 | import 'package:blog_app/presentation/screens/global/widgets/feilds.dart'; 11 | import 'package:firebase_auth/firebase_auth.dart'; 12 | import 'package:flutter/cupertino.dart'; 13 | import 'package:flutter/material.dart'; 14 | import 'package:image_picker/image_picker.dart'; 15 | import 'package:lottie/lottie.dart'; 16 | 17 | class CompleteUserInformation extends StatefulWidget { 18 | @override 19 | State createState() => 20 | _CompleteUserInformationState(); 21 | } 22 | 23 | class _CompleteUserInformationState extends State { 24 | TextEditingController userNameController = TextEditingController(); 25 | bool isLoading = false; 26 | File? finalImage; 27 | ImagePicker _picker = ImagePicker(); 28 | 29 | pickImage(ImageSource imagesource) async { 30 | XFile? pickedImage = await _picker.pickImage(source: imagesource); 31 | 32 | if (pickedImage != null) { 33 | setState(() { 34 | finalImage = File(pickedImage.path); 35 | }); 36 | } 37 | } 38 | 39 | @override 40 | Widget build(BuildContext context) { 41 | double width = MediaQuery.of(context).size.width; 42 | 43 | // TODO: implement build 44 | // throw UnimplementedError();' 45 | if (isLoading) { 46 | WidgetsBinding.instance.addPostFrameCallback((timeStamp) { 47 | showDialog( 48 | context: context, 49 | builder: (context) => Dialog( 50 | child: Container( 51 | width: MediaQuery.of(context).size.width, 52 | height: MediaQuery.of(context).size.height / 4, 53 | color: SolidColors.darkGrey, 54 | padding: EdgeInsets.all(10), 55 | child: Center( 56 | child: Lottie.asset(Assets.lotties.amtaLoading), 57 | ), 58 | ), 59 | )); 60 | }); 61 | } 62 | return Scaffold( 63 | body: Center( 64 | child: Column( 65 | mainAxisAlignment: MainAxisAlignment.center, 66 | children: [ 67 | CircleAvatar( 68 | radius: MediaQuery.of(context).size.width * 0.21, 69 | backgroundColor: 70 | finalImage != null ? SolidColors.red : Colors.transparent, 71 | child: InkWell( 72 | onTap: () { 73 | showDialog( 74 | context: context, 75 | builder: (context) => AlertDialog( 76 | backgroundColor: SolidColors.gray, 77 | title: Text( 78 | 'select where to get photo from', 79 | style: TextStyle(color: Colors.white), 80 | ), 81 | content: Container( 82 | width: width, 83 | height: 100, 84 | child: Column( 85 | mainAxisAlignment: 86 | MainAxisAlignment.spaceEvenly, 87 | children: [ 88 | InkWell( 89 | onTap: () async { 90 | await pickImage(ImageSource.camera); 91 | Navigator.of(context).pop(); 92 | }, 93 | child: Row( 94 | children: [ 95 | Icon( 96 | Icons.camera_alt_outlined, 97 | color: Colors.white, 98 | ), 99 | SizedBox( 100 | width: 20, 101 | ), 102 | Text( 103 | 'Camera', 104 | style: TextStyle(color: Colors.white), 105 | ) 106 | ], 107 | ), 108 | ), 109 | InkWell( 110 | onTap: () async { 111 | await pickImage(ImageSource.gallery); 112 | Navigator.of(context).pop(); 113 | }, 114 | child: Row( 115 | children: [ 116 | Icon(Icons.photo_outlined, 117 | color: Colors.white), 118 | SizedBox( 119 | width: 20, 120 | ), 121 | Text( 122 | 'Gallery', 123 | style: TextStyle(color: Colors.white), 124 | ) 125 | ], 126 | ), 127 | ) 128 | ], 129 | ), 130 | ), 131 | )); 132 | }, 133 | child: CircleAvatar( 134 | backgroundImage: 135 | finalImage != null ? FileImage(finalImage!) : null, 136 | backgroundColor: SolidColors.lightGrey, 137 | radius: MediaQuery.of(context).size.width * 0.2, 138 | child: finalImage == null 139 | ? Center( 140 | child: Icon( 141 | Icons.add_a_photo_outlined, 142 | size: 40, 143 | ), 144 | ) 145 | : null), 146 | ), 147 | ), 148 | Padding( 149 | padding: const EdgeInsets.all(18.0), 150 | child: AppTextFormFeilds( 151 | hintText: 'User Name', 152 | feildIcon: Icons.person_outline, 153 | isPasswordFeild: false, 154 | controller: userNameController, 155 | isFilled: true, 156 | fillColor: SolidColors.darkGrey, 157 | ), 158 | ), 159 | AppButton( 160 | hintText: 'Complete Singing ', 161 | buttonColor: SolidColors.red, 162 | onTap: () { 163 | if (finalImage != null && userNameController.text != null) { 164 | setState(() { 165 | isLoading = true; 166 | }); 167 | Map passedData = ModalRoute.of(context)! 168 | .settings 169 | .arguments as Map; 170 | User currentUser = passedData['user']!; 171 | 172 | UserRepositories() 173 | .updateCredentials( 174 | user: currentUser, 175 | userName: userNameController.text, 176 | profileImage: finalImage!) 177 | .then((value) { 178 | if (value.operationResult == OperationResult.success) { 179 | Navigator.of(context) 180 | .pushReplacementNamed(AppRouteNames.homeScreen); 181 | } 182 | if (value.operationResult == OperationResult.fail) { 183 | ScaffoldMessenger.of(context) 184 | .showSnackBar(SnackBar(content: Text(value.data))); 185 | } 186 | }); 187 | } 188 | }, 189 | width: width * 0.5, 190 | hintTextStyle: TextStyle( 191 | fontWeight: FontWeight.normal, 192 | color: Colors.white, 193 | fontFamily: FontFamily.roboto, 194 | fontSize: 18), 195 | ) 196 | ], 197 | ), 198 | ), 199 | ); 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /lib/presentation/screens/user_profile/profile_screen.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ffi'; 2 | import 'dart:io'; 3 | 4 | import 'package:blog_app/Blocs/profile_cubit/profile_cubit.dart'; 5 | import 'package:blog_app/data/models/user/user_modle.dart'; 6 | import 'package:blog_app/gen/assets.gen.dart'; 7 | import 'package:blog_app/presentation/screens/global/colors/solid_colors.dart'; 8 | import 'package:blog_app/presentation/screens/global/widgets/button.dart'; 9 | import 'package:blog_app/presentation/screens/global/widgets/feilds.dart'; 10 | import 'package:cached_network_image/cached_network_image.dart'; 11 | import 'package:flutter/material.dart'; 12 | import 'package:flutter_bloc/flutter_bloc.dart'; 13 | import 'package:flutter_spinkit/flutter_spinkit.dart'; 14 | import 'package:image_picker/image_picker.dart'; 15 | 16 | class ProfileScreen extends StatelessWidget { 17 | const ProfileScreen({Key? key}) : super(key: key); 18 | 19 | @override 20 | Widget build(BuildContext context) { 21 | double width = MediaQuery.of(context).size.width; 22 | double height = MediaQuery.of(context).size.height; 23 | return Scaffold( 24 | body: Container( 25 | width: width, 26 | height: height, 27 | // color: Colors.green, 28 | child: BlocConsumer( 29 | listener: ((context, state) { 30 | if (state is ProfileErrorState) { 31 | WidgetsBinding.instance.addPostFrameCallback((timeStamp) { 32 | showDialog( 33 | context: context, 34 | builder: (context) => AlertDialog( 35 | title: Text('Error'), 36 | content: Text(state.error), 37 | )); 38 | }); 39 | } 40 | }), builder: (context, state) { 41 | if (state is ProfileLoadedState) { 42 | return Stack( 43 | children: [ 44 | // profile image section 45 | CachedNetworkImage( 46 | placeholder: ((context, url) => Container( 47 | width: width, 48 | height: height / 3, 49 | child: Center( 50 | child: SpinKitDoubleBounce( 51 | color: SolidColors.red, 52 | ), 53 | ))), 54 | errorWidget: ((context, url, error) => Container( 55 | width: width, 56 | height: height / 3, 57 | child: Center( 58 | child: Icon( 59 | Icons.image_not_supported_outlined, 60 | size: 30, 61 | color: SolidColors.red, 62 | ), 63 | ), 64 | )), 65 | imageUrl: state.amataUser.profileUrl!, 66 | imageBuilder: ((context, imageProvider) => Container( 67 | width: width, 68 | height: height / 3, 69 | decoration: BoxDecoration( 70 | image: DecorationImage( 71 | image: imageProvider, fit: BoxFit.fill)), 72 | )), 73 | ), 74 | Positioned( 75 | top: 20, 76 | left: 10, 77 | child: IconButton( 78 | onPressed: () { 79 | Navigator.of(context).pop(); 80 | }, 81 | icon: Icon( 82 | Icons.arrow_back_rounded, 83 | color: SolidColors.red, 84 | size: 30, 85 | ), 86 | ), 87 | ), 88 | 89 | // user info section 90 | _userInfosection(height, width, context, 91 | amataUser: state.amataUser), 92 | Positioned( 93 | left: width / 1.25, 94 | top: height / 3.4, 95 | child: FloatingActionButton( 96 | backgroundColor: Colors.lightBlue, 97 | onPressed: () async { 98 | ImagePicker picker = ImagePicker(); 99 | XFile? result = await picker 100 | .pickImage(source: ImageSource.gallery) 101 | .then((value) { 102 | if (value != null) { 103 | context.read().updateProfilePhoto( 104 | profileImage: File(value.path)); 105 | } 106 | }); 107 | }, 108 | child: Icon(Icons.camera_alt_outlined), 109 | )), 110 | ], 111 | ); 112 | } 113 | if (state is ProfileLoadingState) { 114 | return Center( 115 | child: SpinKitDoubleBounce( 116 | color: SolidColors.red, 117 | ), 118 | ); 119 | } 120 | if (state is ProfileErrorState) { 121 | WidgetsBinding.instance.addPostFrameCallback((timeStamp) { 122 | showDialog( 123 | context: context, 124 | builder: (context) => AlertDialog( 125 | title: Text('Error'), 126 | content: Text(state.error), 127 | )); 128 | }); 129 | } 130 | return Container(); 131 | }), 132 | ), 133 | ); 134 | } 135 | 136 | _userInfosection(double height, double width, BuildContext context, 137 | {required AmataUser amataUser}) { 138 | TextEditingController controller = TextEditingController(); 139 | return Positioned( 140 | top: height / 3.1, 141 | child: Container( 142 | width: width, 143 | height: height / 3.38, 144 | color: SolidColors.darkGrey, 145 | child: Padding( 146 | padding: const EdgeInsets.all(18.0), 147 | child: Column( 148 | crossAxisAlignment: CrossAxisAlignment.start, 149 | children: [ 150 | Text( 151 | 'Account', 152 | style: TextStyle(color: Colors.white, fontSize: 20), 153 | ), 154 | SizedBox( 155 | height: 10, 156 | ), 157 | // email section 158 | _bordIteam(width, 159 | usageStr: amataUser.emailAddrress!, 160 | ontap: () {}, 161 | usageTip: 'You can\'t change your email address unless now'), 162 | Divider( 163 | color: SolidColors.lightGrey, 164 | ), 165 | // userName section 166 | _bordIteam(width, 167 | usageStr: amataUser.userName!, 168 | ontap: () => showEditDialog( 169 | context: context, 170 | title: 'Edit your User Name', 171 | controller: controller, 172 | hintText: 'Update your userName', 173 | onTap: () { 174 | Navigator.of(context).pop(); 175 | 176 | context 177 | .read() 178 | .updateUserName(newUserName: controller.text); 179 | }), 180 | usageTip: 'Tap to change user name'), 181 | Divider( 182 | color: SolidColors.lightGrey, 183 | ), 184 | // bio section 185 | _bordIteam(width, 186 | usageStr: amataUser.bio ?? 'sapmple bio you can have', 187 | ontap: () => showEditDialog( 188 | context: context, 189 | title: 'Edit or add your bio', 190 | controller: controller, 191 | hintText: 'Update your bio', 192 | onTap: () { 193 | Navigator.of(context).pop(); 194 | context 195 | .read() 196 | .updateAddBio(bio: controller.text); 197 | }), 198 | usageTip: 'Tap to change bio'), 199 | Divider( 200 | color: SolidColors.lightGrey, 201 | ) 202 | ], 203 | ), 204 | ), 205 | ), 206 | ); 207 | } 208 | 209 | showEditDialog( 210 | {required String title, 211 | required Function() onTap, 212 | required String hintText, 213 | required BuildContext context, 214 | required TextEditingController controller}) { 215 | return showDialog( 216 | context: context, 217 | builder: (context) => Dialog( 218 | backgroundColor: SolidColors.kindGray, 219 | child: Container( 220 | padding: EdgeInsets.symmetric(horizontal: 20), 221 | width: MediaQuery.of(context).size.width, 222 | height: 250, 223 | child: Column( 224 | mainAxisAlignment: MainAxisAlignment.spaceEvenly, 225 | children: [ 226 | Text( 227 | title, 228 | style: TextStyle( 229 | color: Colors.white, fontWeight: FontWeight.bold), 230 | ), 231 | TextFormField( 232 | controller: controller, 233 | style: TextStyle(color: SolidColors.red), 234 | decoration: InputDecoration( 235 | hintText: hintText, 236 | hintStyle: TextStyle( 237 | color: Colors.white, 238 | ), 239 | enabledBorder: const OutlineInputBorder( 240 | borderSide: BorderSide(color: Colors.white)), 241 | disabledBorder: const OutlineInputBorder( 242 | borderSide: BorderSide(color: Colors.white)), 243 | focusedBorder: const OutlineInputBorder( 244 | borderSide: BorderSide(color: Colors.white))), 245 | ), 246 | AppButton( 247 | hintText: 'confirm', 248 | buttonColor: SolidColors.red, 249 | onTap: onTap, 250 | width: MediaQuery.of(context).size.width) 251 | ], 252 | ), 253 | ), 254 | )); 255 | } 256 | 257 | InkWell _bordIteam(double width, 258 | {required String usageStr, 259 | required String usageTip, 260 | required Function() ontap}) { 261 | return InkWell( 262 | onTap: ontap, 263 | child: Container( 264 | width: width, 265 | // color: Colors.red, 266 | child: Column( 267 | crossAxisAlignment: CrossAxisAlignment.start, 268 | children: [ 269 | Text( 270 | usageStr, 271 | style: TextStyle( 272 | color: Colors.white, 273 | fontSize: 15, 274 | ), 275 | ), 276 | SizedBox( 277 | height: 8, 278 | ), 279 | Text( 280 | usageTip, 281 | style: TextStyle( 282 | color: Colors.white, 283 | fontSize: 12, 284 | fontWeight: FontWeight.w300), 285 | ) 286 | ], 287 | ), 288 | ), 289 | ); 290 | } 291 | } 292 | -------------------------------------------------------------------------------- /lib/data/repositories/user_repository.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:developer'; 3 | import 'dart:io'; 4 | 5 | import 'package:blog_app/core/core.dart'; 6 | import 'package:blog_app/data/models/articles/article_modle.dart'; 7 | import 'package:blog_app/data/models/user/user_modle.dart'; 8 | import 'package:cloud_firestore/cloud_firestore.dart'; 9 | import 'package:firebase_auth/firebase_auth.dart'; 10 | import 'package:firebase_storage/firebase_storage.dart'; 11 | import 'package:flutter/cupertino.dart'; 12 | import 'package:flutter/material.dart'; 13 | 14 | class UserRepositories { 15 | final FirebaseAuth _firebaseAuth; 16 | final CollectionReference _userRef; 17 | 18 | final FirebaseStorage _userStorageRef; 19 | 20 | UserRepositories( 21 | {FirebaseAuth? firebaseAuth, 22 | CollectionReference? userRef, 23 | FirebaseStorage? userStorageRef}) 24 | : _firebaseAuth = firebaseAuth ?? FirebaseAuth.instance, 25 | _userRef = userRef ?? 26 | FirebaseFirestore.instance 27 | .collection(FirebaseConstants.usersCollection), 28 | _userStorageRef = userStorageRef ?? FirebaseStorage.instance; 29 | 30 | Future updateCredentials({ 31 | required User user, 32 | required String userName, 33 | required File profileImage, 34 | }) async { 35 | try { 36 | String fileName = profileImage.path.split('/').last; 37 | Reference profileBucket = _userStorageRef 38 | .ref() 39 | .child(FirebaseConstants.userProfile) 40 | .child(_firebaseAuth.currentUser!.uid) 41 | .child(fileName); 42 | TaskSnapshot uploadTask = await profileBucket.putFile(profileImage); 43 | // TaskSnapshot taskSnapshot= await _userStorageRef.ref().child(path).putFile(profileImage); 44 | String? profileLink; 45 | if (uploadTask.state == TaskState.success) { 46 | profileLink = await profileBucket.getDownloadURL(); 47 | } 48 | 49 | print(profileLink); 50 | AmataUser amtaUser = AmataUser( 51 | emailAddrress: user.email, 52 | userName: userName, 53 | profileUrl: profileLink, 54 | uid: user.uid, 55 | savedArticles: []); 56 | print(amtaUser.uid); 57 | await _userRef.doc(user.uid).set(amtaUser.toJson()); 58 | 59 | return RawData(operationResult: OperationResult.success, data: true); 60 | } catch (e) { 61 | return RawData(operationResult: OperationResult.fail, data: e.toString()); 62 | } 63 | } 64 | 65 | Future saveArticleToReadingList({required Article article}) async { 66 | try { 67 | log('saving ${article.title} to user list'); 68 | var curentUserRawData = 69 | await _userRef.doc(_firebaseAuth.currentUser!.uid).get(); 70 | AmataUser user = 71 | AmataUser.fromJson(curentUserRawData.data() as Map); 72 | 73 | if (user.savedArticles!.isEmpty) { 74 | user.savedArticles!.add(article); 75 | await _userRef.doc(user.uid).update({ 76 | 'savedArticles': user.savedArticles!.map((e) => e.toJson()).toList() 77 | }); 78 | return RawData( 79 | operationResult: OperationResult.success, 80 | data: 'article saved succesfullu'); 81 | } 82 | if (user.savedArticles!.isNotEmpty) { 83 | bool contains = _contains(user.savedArticles!, article); 84 | print(contains); 85 | if (contains) { 86 | return RawData( 87 | operationResult: OperationResult.fail, 88 | data: 'article had saved before'); 89 | } else { 90 | user.savedArticles!.add(article); 91 | await _userRef.doc(user.uid).update({ 92 | 'savedArticles': user.savedArticles!.map((e) => e.toJson()).toList() 93 | }); 94 | return RawData( 95 | operationResult: OperationResult.success, 96 | data: 'article saved succesfull'); 97 | } 98 | } 99 | return RawData( 100 | operationResult: OperationResult.fail, data: 'something went wrong'); 101 | } catch (e) { 102 | return RawData(operationResult: OperationResult.fail, data: e.toString()); 103 | } 104 | } 105 | 106 | Future deleteArticleReadingList({required Article article}) async { 107 | try { 108 | log('*******delteing article from reading list******'); 109 | User? user = await _firebaseAuth.currentUser; 110 | var documnet = await _userRef.doc(user!.uid).get(); 111 | if (documnet.exists) { 112 | Map data = documnet.data() as Map; 113 | AmataUser amataUser = AmataUser.fromJson(data); 114 | if (amataUser.savedArticles!.isNotEmpty) { 115 | print( 116 | 'before remove object from list lengh is ${amataUser.savedArticles!.length}'); 117 | await amataUser.savedArticles!.remove(article); 118 | print(amataUser.savedArticles!.length); 119 | await _userRef.doc(user.uid).update({ 120 | 'savedArticles': 121 | amataUser.savedArticles!.map((e) => e.toJson()).toList() 122 | }); 123 | return RawData( 124 | operationResult: OperationResult.success, 125 | data: 'Article successfully removed'); 126 | } else { 127 | return RawData( 128 | operationResult: OperationResult.fail, 129 | data: 'there is no article to remove'); 130 | } 131 | } else { 132 | return RawData( 133 | operationResult: OperationResult.fail, data: 'sth went wrong'); 134 | } 135 | } catch (e) { 136 | return RawData(operationResult: OperationResult.fail, data: e.toString()); 137 | } 138 | } 139 | 140 | Future getProfileInfo() async { 141 | try { 142 | var result = await _userRef.doc(_firebaseAuth.currentUser!.uid).get(); 143 | if (result.exists) { 144 | AmataUser amataUser = 145 | AmataUser.fromJson(result.data() as Map); 146 | return RawData( 147 | operationResult: OperationResult.success, data: amataUser); 148 | } else { 149 | return RawData( 150 | operationResult: OperationResult.fail, 151 | data: 'The use info didnt find'); 152 | } 153 | } catch (e) { 154 | return RawData(operationResult: OperationResult.fail, data: e.toString()); 155 | } 156 | } 157 | 158 | Future getCurrentUser() async { 159 | try { 160 | var doc = await _userRef.doc(_firebaseAuth.currentUser!.uid).get(); 161 | if (doc.exists) { 162 | AmataUser user = AmataUser.fromJson(doc.data() as Map); 163 | return user; 164 | } else { 165 | throw Exception('user cant find'); 166 | } 167 | } catch (e) { 168 | throw e; 169 | } 170 | } 171 | 172 | Future getUserSavedArticle() async { 173 | try { 174 | log('*******getting user saved articles*******'); 175 | var curentUserRawData = 176 | await _userRef.doc(_firebaseAuth.currentUser!.uid).get(); 177 | if (curentUserRawData.exists) { 178 | AmataUser amataUser = AmataUser.fromJson( 179 | curentUserRawData.data() as Map); 180 | if (amataUser.savedArticles!.isNotEmpty) { 181 | return RawData( 182 | operationResult: OperationResult.success, 183 | data: amataUser.savedArticles); 184 | } else { 185 | return RawData(operationResult: OperationResult.success, data: []); 186 | } 187 | } else { 188 | return RawData( 189 | operationResult: OperationResult.fail, 190 | data: 'cannot find user saved article'); 191 | } 192 | } catch (e) { 193 | return RawData(operationResult: OperationResult.fail, data: e.toString()); 194 | } 195 | } 196 | 197 | // updates user email Adress 198 | Future updateUserEmailAddress({ 199 | required String newEmailAddres, 200 | }) async { 201 | try { 202 | log('Updating user Email Address '); 203 | 204 | /// updates user from auth section in firebase 205 | var result = await _firebaseAuth.currentUser!.updateEmail(newEmailAddres); 206 | 207 | ///[updates user email address in firebaseFireStore] 208 | await _userRef 209 | .doc(await _firebaseAuth.currentUser!.uid) 210 | .update({'emailAddrress': newEmailAddres}); 211 | // gets last changes from fireStore 212 | var doc = await _userRef.doc(await _firebaseAuth.currentUser!.uid).get(); 213 | // check if docs are exists and not's null 214 | if (doc.exists) { 215 | // converts user from json to User Model 216 | AmataUser user = AmataUser.fromJson(doc.data() as Map); 217 | return RawData(operationResult: OperationResult.success, data: user); 218 | } 219 | // returns unknown error because sth bad happens 220 | return RawData( 221 | operationResult: OperationResult.fail, data: 'some thing went wrong'); 222 | } catch (e) { 223 | return RawData(operationResult: OperationResult.fail, data: e.toString()); 224 | } 225 | } 226 | 227 | // add or update bio section for user 228 | 229 | Future updateOrAddBioForUser({required String bioText}) async { 230 | try { 231 | // updates value in firestore 232 | await _userRef 233 | .doc(_firebaseAuth.currentUser!.uid) 234 | .update({'bio': bioText}); 235 | // gets last changes 236 | var res = await _userRef.doc(_firebaseAuth.currentUser!.uid).get(); 237 | // user raw Data 238 | Map userRawData = res.data() as Map; 239 | // last user changes 240 | AmataUser user = AmataUser.fromJson(userRawData); 241 | return RawData(operationResult: OperationResult.success, data: user); 242 | } catch (e) { 243 | return RawData(operationResult: OperationResult.fail, data: e.toString()); 244 | } 245 | } 246 | 247 | // updates userName in firestore 248 | Future updateUserName({required String userName}) async { 249 | try { 250 | //updates username into fireStore 251 | var resualt = await _userRef 252 | .doc(_firebaseAuth.currentUser!.uid) 253 | .update({'userName': userName}); 254 | // gets last changes from fireStore 255 | var rawData = await _userRef.doc(_firebaseAuth.currentUser!.uid).get(); 256 | Map rawUser = rawData.data() as Map; 257 | // converts rawData to userProfile 258 | AmataUser amataUser = AmataUser.fromJson(rawUser); 259 | return RawData(operationResult: OperationResult.success, data: amataUser); 260 | } catch (e) { 261 | return RawData(operationResult: OperationResult.fail, data: e.toString()); 262 | } 263 | } 264 | 265 | // update profile picture 266 | Future updateUserProfile({required File profileImage}) async { 267 | try { 268 | // deletes last image 269 | Reference reference=_userStorageRef.ref().child(FirebaseConstants.userProfile).child(_firebaseAuth.currentUser!.uid); 270 | // var pervImage=reference.listAll().then((value) => value.items.first); 271 | reference.delete(); 272 | /// gets file name from path picked file 273 | String fileName = profileImage.path.split('/').last; 274 | // firebase storage path 275 | Reference profileBucket = _userStorageRef 276 | .ref() 277 | .child(FirebaseConstants.userProfile) 278 | .child(_firebaseAuth.currentUser!.uid) 279 | .child(fileName); 280 | // // uploads image to storage 281 | TaskSnapshot uploadTask = await profileBucket.putFile(profileImage); 282 | //geting download link of uploaded image 283 | String downloadLink=await profileBucket.getDownloadURL(); 284 | // updating user profileLink with last changes 285 | await _userRef.doc(_firebaseAuth.currentUser!.uid).update( 286 | {'profileUrl': downloadLink}); 287 | // // gets last user changes from server 288 | var resualt = await _userRef.doc(_firebaseAuth.currentUser!.uid).get(); 289 | // user raw data json type 290 | Map rawUser = resualt.data() as Map; 291 | // create instance of user to upda 292 | AmataUser user = AmataUser.fromJson(rawUser); 293 | return RawData(operationResult: OperationResult.success, data: user); 294 | } catch (e) { 295 | return RawData(operationResult: OperationResult.fail, data: e.toString()); 296 | } 297 | } 298 | } 299 | 300 | bool _contains(List
articles, Article articleMatcher) { 301 | for (int i = 0; i < articles.length; i++) { 302 | if (articles[i].title == articleMatcher.title) { 303 | return true; 304 | } else { 305 | return false; 306 | } 307 | } 308 | return false; 309 | } 310 | -------------------------------------------------------------------------------- /lib/presentation/screens/home/home_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:blog_app/Blocs/home_bloc/home_bloc.dart'; 2 | import 'package:blog_app/core/core.dart'; 3 | import 'package:blog_app/data/repositories/auth_repository.dart'; 4 | import 'package:blog_app/data/repositories/user_repository.dart'; 5 | import 'package:blog_app/gen/assets.gen.dart'; 6 | import 'package:blog_app/presentation/routes/app_route_names.dart'; 7 | import 'package:blog_app/presentation/screens/global/colors/solid_colors.dart'; 8 | import 'package:cached_network_image/cached_network_image.dart'; 9 | import 'package:firebase_auth/firebase_auth.dart'; 10 | import 'package:flutter/cupertino.dart'; 11 | import 'package:flutter/material.dart'; 12 | import 'package:flutter_bloc/flutter_bloc.dart'; 13 | import 'package:flutter_spinkit/flutter_spinkit.dart'; 14 | 15 | class HomeScreen extends StatelessWidget { 16 | const HomeScreen({Key? key}) : super(key: key); 17 | 18 | @override 19 | Widget build(BuildContext context) { 20 | return Scaffold( 21 | appBar: AppBar( 22 | title: Text('Amata Blog'), 23 | // automaticallyImplyLeading: false, 24 | backgroundColor: SolidColors.darkGrey, 25 | ), 26 | drawer: Drawer( 27 | backgroundColor: SolidColors.darkGrey, 28 | child: Column( 29 | children: [ 30 | BlocBuilder(builder: (context, state) { 31 | /* UserAccountsDrawerHeader( 32 | margin: EdgeInsets.zero, 33 | decoration: BoxDecoration(color: SolidColors.gray), 34 | accountEmail: Text('test'), 35 | accountName: Text('test'), 36 | currentAccountPicture: CircleAvatar( 37 | child: Center( 38 | child: Icon(Icons.person), 39 | ), 40 | ), 41 | ), */ 42 | if (state is HomeLoadedState) { 43 | print(state.amataUser?.profileUrl); 44 | return InkWell( 45 | onTap: () { 46 | Navigator.of(context) 47 | .pushNamed(AppRouteNames.profileScreen); 48 | }, 49 | child: UserAccountsDrawerHeader( 50 | margin: EdgeInsets.zero, 51 | decoration: BoxDecoration(color: SolidColors.gray), 52 | accountEmail: Text(state.amataUser!.emailAddrress!), 53 | accountName: state.amataUser!.userName != null 54 | ? Text(state.amataUser!.userName!) 55 | : null, 56 | currentAccountPicture: state.amataUser?.profileUrl != 57 | null 58 | ? CachedNetworkImage( 59 | imageUrl: state.amataUser!.profileUrl!, 60 | placeholder: (context, url) => 61 | SpinKitDoubleBounce( 62 | color: SolidColors.red, 63 | ), 64 | errorWidget: (context, url, error) => 65 | CircleAvatar( 66 | backgroundColor: SolidColors.kindGray, 67 | child: Center( 68 | child: Icon(Icons.person_outline_outlined), 69 | ), 70 | ), 71 | imageBuilder: ((context, imageProvider) => 72 | Container( 73 | width: 80, 74 | height: 80, 75 | decoration: BoxDecoration( 76 | shape: BoxShape.circle, 77 | image: DecorationImage( 78 | image: imageProvider, 79 | )), 80 | )), 81 | ) 82 | : Icon(Icons.person)), 83 | ); 84 | } 85 | return Text(''); 86 | }), 87 | // UserAccountsDrawerHeader( 88 | // margin: EdgeInsets.zero, 89 | // decoration: BoxDecoration(color: SolidColors.gray), 90 | // accountEmail: Text('test'), 91 | // accountName: Text('test'), 92 | // currentAccountPicture: CircleAvatar( 93 | // child: Center( 94 | // child: Icon(Icons.person), 95 | // ), 96 | // ), 97 | // ), 98 | Card( 99 | color: SolidColors.gray, 100 | child: ListTile( 101 | onTap: () { 102 | Navigator.of(context) 103 | .pushNamed(AppRouteNames.savedArticleListScreen); 104 | }, 105 | leading: Icon( 106 | Icons.save_outlined, 107 | color: Colors.white, 108 | ), 109 | title: Text( 110 | 'Saved Articles', 111 | style: TextStyle(color: Colors.white), 112 | ), 113 | ), 114 | ), 115 | // Card( 116 | // color: SolidColors.gray, 117 | // child: ListTile( 118 | // leading: Icon( 119 | // Icons.settings_outlined, 120 | // color: Colors.white, 121 | // ), 122 | // title: Text( 123 | // 'Settings', 124 | // style: TextStyle(color: Colors.white), 125 | // ), 126 | // ), 127 | // ), 128 | Card( 129 | color: SolidColors.gray, 130 | child: ListTile( 131 | onTap: (){ 132 | Navigator.of(context).pushNamed(AppRouteNames.profileScreen); 133 | }, 134 | leading: Icon( 135 | Icons.person, 136 | color: Colors.white, 137 | ), 138 | title: Text( 139 | 'Profile', 140 | style: TextStyle(color: Colors.white), 141 | ), 142 | ), 143 | ), 144 | InkWell( 145 | onTap: () { 146 | AuthRepository().logOut().then((value) { 147 | if (value.operationResult == OperationResult.success) { 148 | Navigator.of(context) 149 | .pushReplacementNamed(AppRouteNames.signUpScreen); 150 | } 151 | }); 152 | }, 153 | child: Card( 154 | color: SolidColors.gray, 155 | child: ListTile( 156 | leading: Icon( 157 | Icons.logout_rounded, 158 | color: Colors.white, 159 | ), 160 | title: Text( 161 | 'Logout', 162 | style: TextStyle(color: Colors.white), 163 | ), 164 | ), 165 | ), 166 | ), 167 | ], 168 | ), 169 | ), 170 | body: _bultBody(context)); 171 | } 172 | 173 | _bultBody(BuildContext context) { 174 | double width = MediaQuery.of(context).size.width; 175 | double height = MediaQuery.of(context).size.height; 176 | List fakeCategories = [ 177 | 'all', 178 | 'It', 179 | 'Technology', 180 | 'comercial', 181 | 'education' 182 | ]; 183 | return BlocConsumer( 184 | listener: ((context, state) async { 185 | if (state is HomeArticleSavedState) { 186 | WidgetsBinding.instance.addPostFrameCallback((timeStamp) { 187 | ScaffoldMessenger.of(context).showSnackBar( 188 | SnackBar(content: Text('Article saved to your reading list'))); 189 | }); 190 | } 191 | if (state is ArticleSaveErrorState) { 192 | WidgetsBinding.instance.addPostFrameCallback((timeStamp) { 193 | ScaffoldMessenger.of(context) 194 | .showSnackBar(SnackBar(content: Text('${state.error}}'))); 195 | }); 196 | } 197 | }), 198 | builder: (context, state) { 199 | if (state is HomeLoadingState) { 200 | return Center( 201 | child: SpinKitDoubleBounce( 202 | color: SolidColors.red, 203 | ), 204 | ); 205 | } 206 | 207 | if (state is HomeLoadedState) { 208 | return Padding( 209 | padding: EdgeInsets.symmetric( 210 | horizontal: state.articles.length.toDouble(), 211 | ), 212 | child: Column( 213 | crossAxisAlignment: CrossAxisAlignment.start, 214 | mainAxisAlignment: MainAxisAlignment.spaceEvenly, 215 | children: [ 216 | Padding( 217 | padding: const EdgeInsets.all(18.0), 218 | child: Text('Your Lists', 219 | style: Theme.of(context).textTheme.headline1), 220 | ), 221 | Container( 222 | width: width, 223 | height: height * 0.8, 224 | // color: Colors.green, 225 | child: ListView.builder( 226 | itemCount: state.articles.length, 227 | physics: BouncingScrollPhysics(), 228 | itemBuilder: (context, index) { 229 | return Padding( 230 | padding: const EdgeInsets.symmetric( 231 | horizontal: 10, vertical: 14), 232 | child: SizedBox( 233 | width: width, 234 | height: 120, 235 | child: InkWell( 236 | onTap: () { 237 | Navigator.of(context).pushNamed( 238 | AppRouteNames.articleDetailScreen, 239 | arguments: state.articles[index]); 240 | }, 241 | child: Card( 242 | color: SolidColors.kindGray, 243 | child: Row( 244 | mainAxisAlignment: 245 | MainAxisAlignment.spaceEvenly, 246 | children: [ 247 | Column( 248 | mainAxisAlignment: 249 | MainAxisAlignment.spaceEvenly, 250 | children: [ 251 | Text( 252 | state.articles[index].title!, 253 | style: Theme.of(context) 254 | .textTheme 255 | .bodySmall, 256 | ), 257 | Row( 258 | children: [ 259 | IconButton( 260 | onPressed: () async { 261 | // UserRepository().updateCredentials(user: await FirebaseAuth.instance.currentUser!, userName: 'abolfazl', profileImage: 'https://files.virgool.io/upload/users/10548/posts/hagwlg7mwqq4/nsve5akdotnh.jpeg',) 262 | BlocProvider.of( 263 | context) 264 | .add(SaveArticleEvent( 265 | state.articles[index], 266 | )); 267 | }, 268 | icon: Icon( 269 | Icons.post_add_outlined, 270 | color: Colors.white, 271 | )), 272 | IconButton( 273 | onPressed: () {}, 274 | icon: Icon( 275 | Icons.share_outlined, 276 | color: Colors.white, 277 | )) 278 | ], 279 | ) 280 | ], 281 | ), 282 | Container( 283 | width: 100, 284 | height: 100, 285 | child: CachedNetworkImage( 286 | placeholder: (context, url) => 287 | SpinKitDoubleBounce( 288 | color: SolidColors.red, 289 | ), 290 | imageUrl: state 291 | .articles[index].coverImageUrl!, 292 | errorWidget: ((context, url, error) => 293 | Icon( 294 | Icons 295 | .image_not_supported_outlined, 296 | size: 20, 297 | color: SolidColors.red, 298 | )), 299 | imageBuilder: 300 | (context, imageProvider) { 301 | return Container( 302 | decoration: BoxDecoration( 303 | image: DecorationImage( 304 | image: imageProvider, 305 | fit: BoxFit.fill, 306 | )), 307 | ); 308 | }, 309 | ), 310 | // child: Image.network( 311 | // state.articles[index].coverImageUrl!), 312 | ) 313 | ]), 314 | ), 315 | ), 316 | ), 317 | ); 318 | }, 319 | ), 320 | ) 321 | ], 322 | )); 323 | } 324 | if (state is HomeErrorState) { 325 | WidgetsBinding.instance.addPostFrameCallback((timeStamp) { 326 | showDialog( 327 | context: context, 328 | builder: (context) => CupertinoAlertDialog( 329 | content: Text(state.error), 330 | ), 331 | ); 332 | }); 333 | } 334 | return Container(); 335 | }, 336 | ); 337 | } 338 | 339 | /* Padding( 340 | padding: EdgeInsets.symmetric( 341 | horizontal: 20, 342 | ), 343 | child: Column( 344 | crossAxisAlignment: CrossAxisAlignment.start, 345 | mainAxisAlignment: MainAxisAlignment.spaceEvenly, 346 | children: [ 347 | Text('Your Lists', style: Theme.of(context).textTheme.headline2), 348 | Container( 349 | width: width, 350 | height: 50, 351 | // color: Colors.red, 352 | child: _filterBar(fakeCategories), 353 | ), 354 | _articleListView(width: width, height: height) 355 | ], 356 | )), */ 357 | 358 | } 359 | 360 | // class _articleListView extends StatelessWidget { 361 | // const _articleListView({ 362 | // Key? key, 363 | // required this.width, 364 | // required this.height, 365 | // }) : super(key: key); 366 | 367 | // final double width; 368 | // final double height; 369 | 370 | // @override 371 | // Widget build(BuildContext context) { 372 | // return 373 | // } 374 | // } 375 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | _fe_analyzer_shared: 5 | dependency: transitive 6 | description: 7 | name: _fe_analyzer_shared 8 | url: "https://pub.dartlang.org" 9 | source: hosted 10 | version: "46.0.0" 11 | analyzer: 12 | dependency: transitive 13 | description: 14 | name: analyzer 15 | url: "https://pub.dartlang.org" 16 | source: hosted 17 | version: "4.6.0" 18 | archive: 19 | dependency: transitive 20 | description: 21 | name: archive 22 | url: "https://pub.dartlang.org" 23 | source: hosted 24 | version: "3.3.1" 25 | args: 26 | dependency: transitive 27 | description: 28 | name: args 29 | url: "https://pub.dartlang.org" 30 | source: hosted 31 | version: "2.3.1" 32 | async: 33 | dependency: transitive 34 | description: 35 | name: async 36 | url: "https://pub.dartlang.org" 37 | source: hosted 38 | version: "2.8.2" 39 | beamer: 40 | dependency: "direct main" 41 | description: 42 | name: beamer 43 | url: "https://pub.dartlang.org" 44 | source: hosted 45 | version: "1.5.2" 46 | bloc: 47 | dependency: transitive 48 | description: 49 | name: bloc 50 | url: "https://pub.dartlang.org" 51 | source: hosted 52 | version: "8.1.0" 53 | boolean_selector: 54 | dependency: transitive 55 | description: 56 | name: boolean_selector 57 | url: "https://pub.dartlang.org" 58 | source: hosted 59 | version: "2.1.0" 60 | build: 61 | dependency: transitive 62 | description: 63 | name: build 64 | url: "https://pub.dartlang.org" 65 | source: hosted 66 | version: "2.3.0" 67 | build_config: 68 | dependency: transitive 69 | description: 70 | name: build_config 71 | url: "https://pub.dartlang.org" 72 | source: hosted 73 | version: "1.1.0" 74 | build_daemon: 75 | dependency: transitive 76 | description: 77 | name: build_daemon 78 | url: "https://pub.dartlang.org" 79 | source: hosted 80 | version: "3.1.0" 81 | build_resolvers: 82 | dependency: transitive 83 | description: 84 | name: build_resolvers 85 | url: "https://pub.dartlang.org" 86 | source: hosted 87 | version: "2.0.9" 88 | build_runner: 89 | dependency: "direct dev" 90 | description: 91 | name: build_runner 92 | url: "https://pub.dartlang.org" 93 | source: hosted 94 | version: "2.2.0" 95 | build_runner_core: 96 | dependency: transitive 97 | description: 98 | name: build_runner_core 99 | url: "https://pub.dartlang.org" 100 | source: hosted 101 | version: "7.2.3" 102 | built_collection: 103 | dependency: transitive 104 | description: 105 | name: built_collection 106 | url: "https://pub.dartlang.org" 107 | source: hosted 108 | version: "5.1.1" 109 | built_value: 110 | dependency: transitive 111 | description: 112 | name: built_value 113 | url: "https://pub.dartlang.org" 114 | source: hosted 115 | version: "8.4.1" 116 | cached_network_image: 117 | dependency: "direct main" 118 | description: 119 | name: cached_network_image 120 | url: "https://pub.dartlang.org" 121 | source: hosted 122 | version: "3.2.1" 123 | cached_network_image_platform_interface: 124 | dependency: transitive 125 | description: 126 | name: cached_network_image_platform_interface 127 | url: "https://pub.dartlang.org" 128 | source: hosted 129 | version: "1.0.0" 130 | cached_network_image_web: 131 | dependency: transitive 132 | description: 133 | name: cached_network_image_web 134 | url: "https://pub.dartlang.org" 135 | source: hosted 136 | version: "1.0.1" 137 | characters: 138 | dependency: transitive 139 | description: 140 | name: characters 141 | url: "https://pub.dartlang.org" 142 | source: hosted 143 | version: "1.2.0" 144 | charcode: 145 | dependency: transitive 146 | description: 147 | name: charcode 148 | url: "https://pub.dartlang.org" 149 | source: hosted 150 | version: "1.3.1" 151 | checked_yaml: 152 | dependency: transitive 153 | description: 154 | name: checked_yaml 155 | url: "https://pub.dartlang.org" 156 | source: hosted 157 | version: "2.0.1" 158 | clock: 159 | dependency: transitive 160 | description: 161 | name: clock 162 | url: "https://pub.dartlang.org" 163 | source: hosted 164 | version: "1.1.0" 165 | cloud_firestore: 166 | dependency: "direct main" 167 | description: 168 | name: cloud_firestore 169 | url: "https://pub.dartlang.org" 170 | source: hosted 171 | version: "3.4.5" 172 | cloud_firestore_platform_interface: 173 | dependency: transitive 174 | description: 175 | name: cloud_firestore_platform_interface 176 | url: "https://pub.dartlang.org" 177 | source: hosted 178 | version: "5.7.2" 179 | cloud_firestore_web: 180 | dependency: transitive 181 | description: 182 | name: cloud_firestore_web 183 | url: "https://pub.dartlang.org" 184 | source: hosted 185 | version: "2.8.5" 186 | code_builder: 187 | dependency: transitive 188 | description: 189 | name: code_builder 190 | url: "https://pub.dartlang.org" 191 | source: hosted 192 | version: "4.2.0" 193 | collection: 194 | dependency: transitive 195 | description: 196 | name: collection 197 | url: "https://pub.dartlang.org" 198 | source: hosted 199 | version: "1.16.0" 200 | convert: 201 | dependency: transitive 202 | description: 203 | name: convert 204 | url: "https://pub.dartlang.org" 205 | source: hosted 206 | version: "3.0.2" 207 | cross_file: 208 | dependency: transitive 209 | description: 210 | name: cross_file 211 | url: "https://pub.dartlang.org" 212 | source: hosted 213 | version: "0.3.3+1" 214 | crypto: 215 | dependency: transitive 216 | description: 217 | name: crypto 218 | url: "https://pub.dartlang.org" 219 | source: hosted 220 | version: "3.0.2" 221 | cupertino_icons: 222 | dependency: "direct main" 223 | description: 224 | name: cupertino_icons 225 | url: "https://pub.dartlang.org" 226 | source: hosted 227 | version: "1.0.5" 228 | dart_style: 229 | dependency: transitive 230 | description: 231 | name: dart_style 232 | url: "https://pub.dartlang.org" 233 | source: hosted 234 | version: "2.2.3" 235 | equatable: 236 | dependency: "direct main" 237 | description: 238 | name: equatable 239 | url: "https://pub.dartlang.org" 240 | source: hosted 241 | version: "2.0.5" 242 | fake_async: 243 | dependency: transitive 244 | description: 245 | name: fake_async 246 | url: "https://pub.dartlang.org" 247 | source: hosted 248 | version: "1.3.0" 249 | ffi: 250 | dependency: transitive 251 | description: 252 | name: ffi 253 | url: "https://pub.dartlang.org" 254 | source: hosted 255 | version: "2.0.1" 256 | file: 257 | dependency: transitive 258 | description: 259 | name: file 260 | url: "https://pub.dartlang.org" 261 | source: hosted 262 | version: "6.1.4" 263 | firebase_auth: 264 | dependency: "direct main" 265 | description: 266 | name: firebase_auth 267 | url: "https://pub.dartlang.org" 268 | source: hosted 269 | version: "3.6.4" 270 | firebase_auth_platform_interface: 271 | dependency: transitive 272 | description: 273 | name: firebase_auth_platform_interface 274 | url: "https://pub.dartlang.org" 275 | source: hosted 276 | version: "6.5.4" 277 | firebase_auth_web: 278 | dependency: transitive 279 | description: 280 | name: firebase_auth_web 281 | url: "https://pub.dartlang.org" 282 | source: hosted 283 | version: "4.2.4" 284 | firebase_core: 285 | dependency: "direct main" 286 | description: 287 | name: firebase_core 288 | url: "https://pub.dartlang.org" 289 | source: hosted 290 | version: "1.21.0" 291 | firebase_core_platform_interface: 292 | dependency: transitive 293 | description: 294 | name: firebase_core_platform_interface 295 | url: "https://pub.dartlang.org" 296 | source: hosted 297 | version: "4.5.1" 298 | firebase_core_web: 299 | dependency: transitive 300 | description: 301 | name: firebase_core_web 302 | url: "https://pub.dartlang.org" 303 | source: hosted 304 | version: "1.7.2" 305 | firebase_storage: 306 | dependency: "direct main" 307 | description: 308 | name: firebase_storage 309 | url: "https://pub.dartlang.org" 310 | source: hosted 311 | version: "10.3.7" 312 | firebase_storage_platform_interface: 313 | dependency: transitive 314 | description: 315 | name: firebase_storage_platform_interface 316 | url: "https://pub.dartlang.org" 317 | source: hosted 318 | version: "4.1.15" 319 | firebase_storage_web: 320 | dependency: transitive 321 | description: 322 | name: firebase_storage_web 323 | url: "https://pub.dartlang.org" 324 | source: hosted 325 | version: "3.3.5" 326 | fixnum: 327 | dependency: transitive 328 | description: 329 | name: fixnum 330 | url: "https://pub.dartlang.org" 331 | source: hosted 332 | version: "1.0.1" 333 | flutter: 334 | dependency: "direct main" 335 | description: flutter 336 | source: sdk 337 | version: "0.0.0" 338 | flutter_bloc: 339 | dependency: "direct main" 340 | description: 341 | name: flutter_bloc 342 | url: "https://pub.dartlang.org" 343 | source: hosted 344 | version: "8.1.1" 345 | flutter_blurhash: 346 | dependency: transitive 347 | description: 348 | name: flutter_blurhash 349 | url: "https://pub.dartlang.org" 350 | source: hosted 351 | version: "0.7.0" 352 | flutter_cache_manager: 353 | dependency: transitive 354 | description: 355 | name: flutter_cache_manager 356 | url: "https://pub.dartlang.org" 357 | source: hosted 358 | version: "3.3.0" 359 | flutter_lints: 360 | dependency: "direct dev" 361 | description: 362 | name: flutter_lints 363 | url: "https://pub.dartlang.org" 364 | source: hosted 365 | version: "2.0.1" 366 | flutter_plugin_android_lifecycle: 367 | dependency: transitive 368 | description: 369 | name: flutter_plugin_android_lifecycle 370 | url: "https://pub.dartlang.org" 371 | source: hosted 372 | version: "2.0.7" 373 | flutter_spinkit: 374 | dependency: "direct main" 375 | description: 376 | name: flutter_spinkit 377 | url: "https://pub.dartlang.org" 378 | source: hosted 379 | version: "5.1.0" 380 | flutter_svg: 381 | dependency: "direct main" 382 | description: 383 | name: flutter_svg 384 | url: "https://pub.dartlang.org" 385 | source: hosted 386 | version: "1.1.4" 387 | flutter_test: 388 | dependency: "direct dev" 389 | description: flutter 390 | source: sdk 391 | version: "0.0.0" 392 | flutter_web_plugins: 393 | dependency: transitive 394 | description: flutter 395 | source: sdk 396 | version: "0.0.0" 397 | frontend_server_client: 398 | dependency: transitive 399 | description: 400 | name: frontend_server_client 401 | url: "https://pub.dartlang.org" 402 | source: hosted 403 | version: "2.1.3" 404 | glob: 405 | dependency: transitive 406 | description: 407 | name: glob 408 | url: "https://pub.dartlang.org" 409 | source: hosted 410 | version: "2.1.0" 411 | graphs: 412 | dependency: transitive 413 | description: 414 | name: graphs 415 | url: "https://pub.dartlang.org" 416 | source: hosted 417 | version: "2.1.0" 418 | http: 419 | dependency: transitive 420 | description: 421 | name: http 422 | url: "https://pub.dartlang.org" 423 | source: hosted 424 | version: "0.13.5" 425 | http_multi_server: 426 | dependency: transitive 427 | description: 428 | name: http_multi_server 429 | url: "https://pub.dartlang.org" 430 | source: hosted 431 | version: "3.2.1" 432 | http_parser: 433 | dependency: transitive 434 | description: 435 | name: http_parser 436 | url: "https://pub.dartlang.org" 437 | source: hosted 438 | version: "4.0.1" 439 | image_picker: 440 | dependency: "direct main" 441 | description: 442 | name: image_picker 443 | url: "https://pub.dartlang.org" 444 | source: hosted 445 | version: "0.8.5+3" 446 | image_picker_android: 447 | dependency: transitive 448 | description: 449 | name: image_picker_android 450 | url: "https://pub.dartlang.org" 451 | source: hosted 452 | version: "0.8.5+2" 453 | image_picker_for_web: 454 | dependency: transitive 455 | description: 456 | name: image_picker_for_web 457 | url: "https://pub.dartlang.org" 458 | source: hosted 459 | version: "2.1.8" 460 | image_picker_ios: 461 | dependency: transitive 462 | description: 463 | name: image_picker_ios 464 | url: "https://pub.dartlang.org" 465 | source: hosted 466 | version: "0.8.5+6" 467 | image_picker_platform_interface: 468 | dependency: transitive 469 | description: 470 | name: image_picker_platform_interface 471 | url: "https://pub.dartlang.org" 472 | source: hosted 473 | version: "2.6.1" 474 | intl: 475 | dependency: transitive 476 | description: 477 | name: intl 478 | url: "https://pub.dartlang.org" 479 | source: hosted 480 | version: "0.17.0" 481 | io: 482 | dependency: transitive 483 | description: 484 | name: io 485 | url: "https://pub.dartlang.org" 486 | source: hosted 487 | version: "1.0.3" 488 | js: 489 | dependency: transitive 490 | description: 491 | name: js 492 | url: "https://pub.dartlang.org" 493 | source: hosted 494 | version: "0.6.4" 495 | json_annotation: 496 | dependency: "direct main" 497 | description: 498 | name: json_annotation 499 | url: "https://pub.dartlang.org" 500 | source: hosted 501 | version: "4.6.0" 502 | json_serializable: 503 | dependency: "direct dev" 504 | description: 505 | name: json_serializable 506 | url: "https://pub.dartlang.org" 507 | source: hosted 508 | version: "6.3.1" 509 | lints: 510 | dependency: transitive 511 | description: 512 | name: lints 513 | url: "https://pub.dartlang.org" 514 | source: hosted 515 | version: "2.0.0" 516 | logging: 517 | dependency: transitive 518 | description: 519 | name: logging 520 | url: "https://pub.dartlang.org" 521 | source: hosted 522 | version: "1.0.2" 523 | lottie: 524 | dependency: "direct main" 525 | description: 526 | name: lottie 527 | url: "https://pub.dartlang.org" 528 | source: hosted 529 | version: "1.4.2" 530 | matcher: 531 | dependency: transitive 532 | description: 533 | name: matcher 534 | url: "https://pub.dartlang.org" 535 | source: hosted 536 | version: "0.12.11" 537 | material_color_utilities: 538 | dependency: transitive 539 | description: 540 | name: material_color_utilities 541 | url: "https://pub.dartlang.org" 542 | source: hosted 543 | version: "0.1.4" 544 | meta: 545 | dependency: transitive 546 | description: 547 | name: meta 548 | url: "https://pub.dartlang.org" 549 | source: hosted 550 | version: "1.7.0" 551 | mime: 552 | dependency: transitive 553 | description: 554 | name: mime 555 | url: "https://pub.dartlang.org" 556 | source: hosted 557 | version: "1.0.2" 558 | mockito: 559 | dependency: "direct dev" 560 | description: 561 | name: mockito 562 | url: "https://pub.dartlang.org" 563 | source: hosted 564 | version: "5.3.0" 565 | nested: 566 | dependency: transitive 567 | description: 568 | name: nested 569 | url: "https://pub.dartlang.org" 570 | source: hosted 571 | version: "1.0.0" 572 | octo_image: 573 | dependency: transitive 574 | description: 575 | name: octo_image 576 | url: "https://pub.dartlang.org" 577 | source: hosted 578 | version: "1.0.2" 579 | package_config: 580 | dependency: transitive 581 | description: 582 | name: package_config 583 | url: "https://pub.dartlang.org" 584 | source: hosted 585 | version: "2.1.0" 586 | path: 587 | dependency: transitive 588 | description: 589 | name: path 590 | url: "https://pub.dartlang.org" 591 | source: hosted 592 | version: "1.8.1" 593 | path_drawing: 594 | dependency: transitive 595 | description: 596 | name: path_drawing 597 | url: "https://pub.dartlang.org" 598 | source: hosted 599 | version: "1.0.1" 600 | path_parsing: 601 | dependency: transitive 602 | description: 603 | name: path_parsing 604 | url: "https://pub.dartlang.org" 605 | source: hosted 606 | version: "1.0.1" 607 | path_provider: 608 | dependency: transitive 609 | description: 610 | name: path_provider 611 | url: "https://pub.dartlang.org" 612 | source: hosted 613 | version: "2.0.11" 614 | path_provider_android: 615 | dependency: transitive 616 | description: 617 | name: path_provider_android 618 | url: "https://pub.dartlang.org" 619 | source: hosted 620 | version: "2.0.20" 621 | path_provider_ios: 622 | dependency: transitive 623 | description: 624 | name: path_provider_ios 625 | url: "https://pub.dartlang.org" 626 | source: hosted 627 | version: "2.0.11" 628 | path_provider_linux: 629 | dependency: transitive 630 | description: 631 | name: path_provider_linux 632 | url: "https://pub.dartlang.org" 633 | source: hosted 634 | version: "2.1.7" 635 | path_provider_macos: 636 | dependency: transitive 637 | description: 638 | name: path_provider_macos 639 | url: "https://pub.dartlang.org" 640 | source: hosted 641 | version: "2.0.6" 642 | path_provider_platform_interface: 643 | dependency: transitive 644 | description: 645 | name: path_provider_platform_interface 646 | url: "https://pub.dartlang.org" 647 | source: hosted 648 | version: "2.0.4" 649 | path_provider_windows: 650 | dependency: transitive 651 | description: 652 | name: path_provider_windows 653 | url: "https://pub.dartlang.org" 654 | source: hosted 655 | version: "2.1.2" 656 | pedantic: 657 | dependency: transitive 658 | description: 659 | name: pedantic 660 | url: "https://pub.dartlang.org" 661 | source: hosted 662 | version: "1.11.1" 663 | petitparser: 664 | dependency: transitive 665 | description: 666 | name: petitparser 667 | url: "https://pub.dartlang.org" 668 | source: hosted 669 | version: "5.0.0" 670 | platform: 671 | dependency: transitive 672 | description: 673 | name: platform 674 | url: "https://pub.dartlang.org" 675 | source: hosted 676 | version: "3.1.0" 677 | plugin_platform_interface: 678 | dependency: transitive 679 | description: 680 | name: plugin_platform_interface 681 | url: "https://pub.dartlang.org" 682 | source: hosted 683 | version: "2.1.2" 684 | pool: 685 | dependency: transitive 686 | description: 687 | name: pool 688 | url: "https://pub.dartlang.org" 689 | source: hosted 690 | version: "1.5.1" 691 | process: 692 | dependency: transitive 693 | description: 694 | name: process 695 | url: "https://pub.dartlang.org" 696 | source: hosted 697 | version: "4.2.4" 698 | provider: 699 | dependency: transitive 700 | description: 701 | name: provider 702 | url: "https://pub.dartlang.org" 703 | source: hosted 704 | version: "6.0.3" 705 | pub_semver: 706 | dependency: transitive 707 | description: 708 | name: pub_semver 709 | url: "https://pub.dartlang.org" 710 | source: hosted 711 | version: "2.1.1" 712 | pubspec_parse: 713 | dependency: transitive 714 | description: 715 | name: pubspec_parse 716 | url: "https://pub.dartlang.org" 717 | source: hosted 718 | version: "1.2.1" 719 | rxdart: 720 | dependency: "direct dev" 721 | description: 722 | name: rxdart 723 | url: "https://pub.dartlang.org" 724 | source: hosted 725 | version: "0.27.5" 726 | shared_preferences: 727 | dependency: "direct main" 728 | description: 729 | name: shared_preferences 730 | url: "https://pub.dartlang.org" 731 | source: hosted 732 | version: "2.0.15" 733 | shared_preferences_android: 734 | dependency: transitive 735 | description: 736 | name: shared_preferences_android 737 | url: "https://pub.dartlang.org" 738 | source: hosted 739 | version: "2.0.12" 740 | shared_preferences_ios: 741 | dependency: transitive 742 | description: 743 | name: shared_preferences_ios 744 | url: "https://pub.dartlang.org" 745 | source: hosted 746 | version: "2.1.1" 747 | shared_preferences_linux: 748 | dependency: transitive 749 | description: 750 | name: shared_preferences_linux 751 | url: "https://pub.dartlang.org" 752 | source: hosted 753 | version: "2.1.1" 754 | shared_preferences_macos: 755 | dependency: transitive 756 | description: 757 | name: shared_preferences_macos 758 | url: "https://pub.dartlang.org" 759 | source: hosted 760 | version: "2.0.4" 761 | shared_preferences_platform_interface: 762 | dependency: transitive 763 | description: 764 | name: shared_preferences_platform_interface 765 | url: "https://pub.dartlang.org" 766 | source: hosted 767 | version: "2.1.0" 768 | shared_preferences_web: 769 | dependency: transitive 770 | description: 771 | name: shared_preferences_web 772 | url: "https://pub.dartlang.org" 773 | source: hosted 774 | version: "2.0.4" 775 | shared_preferences_windows: 776 | dependency: transitive 777 | description: 778 | name: shared_preferences_windows 779 | url: "https://pub.dartlang.org" 780 | source: hosted 781 | version: "2.1.1" 782 | shelf: 783 | dependency: transitive 784 | description: 785 | name: shelf 786 | url: "https://pub.dartlang.org" 787 | source: hosted 788 | version: "1.3.2" 789 | shelf_web_socket: 790 | dependency: transitive 791 | description: 792 | name: shelf_web_socket 793 | url: "https://pub.dartlang.org" 794 | source: hosted 795 | version: "1.0.2" 796 | sky_engine: 797 | dependency: transitive 798 | description: flutter 799 | source: sdk 800 | version: "0.0.99" 801 | source_gen: 802 | dependency: transitive 803 | description: 804 | name: source_gen 805 | url: "https://pub.dartlang.org" 806 | source: hosted 807 | version: "1.2.2" 808 | source_helper: 809 | dependency: transitive 810 | description: 811 | name: source_helper 812 | url: "https://pub.dartlang.org" 813 | source: hosted 814 | version: "1.3.2" 815 | source_span: 816 | dependency: transitive 817 | description: 818 | name: source_span 819 | url: "https://pub.dartlang.org" 820 | source: hosted 821 | version: "1.8.2" 822 | sqflite: 823 | dependency: transitive 824 | description: 825 | name: sqflite 826 | url: "https://pub.dartlang.org" 827 | source: hosted 828 | version: "2.0.3+1" 829 | sqflite_common: 830 | dependency: transitive 831 | description: 832 | name: sqflite_common 833 | url: "https://pub.dartlang.org" 834 | source: hosted 835 | version: "2.2.1+1" 836 | stack_trace: 837 | dependency: transitive 838 | description: 839 | name: stack_trace 840 | url: "https://pub.dartlang.org" 841 | source: hosted 842 | version: "1.10.0" 843 | stream_channel: 844 | dependency: transitive 845 | description: 846 | name: stream_channel 847 | url: "https://pub.dartlang.org" 848 | source: hosted 849 | version: "2.1.0" 850 | stream_transform: 851 | dependency: transitive 852 | description: 853 | name: stream_transform 854 | url: "https://pub.dartlang.org" 855 | source: hosted 856 | version: "2.0.0" 857 | string_scanner: 858 | dependency: transitive 859 | description: 860 | name: string_scanner 861 | url: "https://pub.dartlang.org" 862 | source: hosted 863 | version: "1.1.0" 864 | synchronized: 865 | dependency: transitive 866 | description: 867 | name: synchronized 868 | url: "https://pub.dartlang.org" 869 | source: hosted 870 | version: "3.0.0+3" 871 | term_glyph: 872 | dependency: transitive 873 | description: 874 | name: term_glyph 875 | url: "https://pub.dartlang.org" 876 | source: hosted 877 | version: "1.2.0" 878 | test_api: 879 | dependency: transitive 880 | description: 881 | name: test_api 882 | url: "https://pub.dartlang.org" 883 | source: hosted 884 | version: "0.4.9" 885 | timing: 886 | dependency: transitive 887 | description: 888 | name: timing 889 | url: "https://pub.dartlang.org" 890 | source: hosted 891 | version: "1.0.0" 892 | typed_data: 893 | dependency: transitive 894 | description: 895 | name: typed_data 896 | url: "https://pub.dartlang.org" 897 | source: hosted 898 | version: "1.3.1" 899 | uuid: 900 | dependency: transitive 901 | description: 902 | name: uuid 903 | url: "https://pub.dartlang.org" 904 | source: hosted 905 | version: "3.0.6" 906 | vector_math: 907 | dependency: transitive 908 | description: 909 | name: vector_math 910 | url: "https://pub.dartlang.org" 911 | source: hosted 912 | version: "2.1.2" 913 | watcher: 914 | dependency: transitive 915 | description: 916 | name: watcher 917 | url: "https://pub.dartlang.org" 918 | source: hosted 919 | version: "1.0.1" 920 | web_socket_channel: 921 | dependency: transitive 922 | description: 923 | name: web_socket_channel 924 | url: "https://pub.dartlang.org" 925 | source: hosted 926 | version: "2.2.0" 927 | win32: 928 | dependency: transitive 929 | description: 930 | name: win32 931 | url: "https://pub.dartlang.org" 932 | source: hosted 933 | version: "2.7.0" 934 | xdg_directories: 935 | dependency: transitive 936 | description: 937 | name: xdg_directories 938 | url: "https://pub.dartlang.org" 939 | source: hosted 940 | version: "0.2.0+2" 941 | xml: 942 | dependency: transitive 943 | description: 944 | name: xml 945 | url: "https://pub.dartlang.org" 946 | source: hosted 947 | version: "6.1.0" 948 | yaml: 949 | dependency: transitive 950 | description: 951 | name: yaml 952 | url: "https://pub.dartlang.org" 953 | source: hosted 954 | version: "3.1.1" 955 | sdks: 956 | dart: ">=2.17.6 <3.0.0" 957 | flutter: ">=3.0.0" 958 | --------------------------------------------------------------------------------