Skip to content

Commit

Permalink
feat: Replace Toasts with SnackBars.
Browse files Browse the repository at this point in the history
  • Loading branch information
BURG3R5 committed Feb 11, 2022
1 parent 0438027 commit 146ed32
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 51 deletions.
94 changes: 63 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Codephile

Codephile is an application specially made for all the competitive coders out there. With features
like submission feed, contest reminders, user search, and many more, this app is a perfect companion
for stalking your fellow coders and learning from them.
Codephile is an application specially made for all the competitive coders out there. With features like submission feed, contest reminders, user search, and many more, this app is a perfect companion for stalking your fellow coders and learning from them.

## Screenshots

Expand All @@ -14,42 +12,76 @@ for stalking your fellow coders and learning from them.
Project structure:-

```
|-lib
| |-models {contains object models | used for communication with the back-end}
| |-screens {contains code for the UI}
| |-services {contains code for the buisness logic}
| |-resources {common resources like assets addresses}
| |-main.dart {entry point}
|-assets {contains icons, logos...}
|-android
|-ios
|-test
|- assets { contains icons, images, illustrations }
|- lib
| |- data
| | |- config { contains configuration variables passed at compile-time }
| | |- constants { contains app wide constants like asset strings, colors, routes }
| | |- services { contains ApiService and StorageService }
| |- domain
| | |- models { contains object models }
| | |- repositories { contains repositories according to BLoC architecture pattern }
| |- presentation { contains UI and BLoC code arranged in folders according to app flow }
| | |- components { contains component widgets used throughout the app }
| | |- core { contains important classes including the router and the main_app }
| |- utils { contains utility methods and classes }
| |-main_development.dart { development entrypoint }
| |-main_production.dart { production entrypoint }
|- test { contains widget and unit tests arranged in suites }
```

## Setup for development

#### 0. Clone this repo
```
$ git clone https://github.com/mdgspace/codephile-mobile.git
$ cd codephile-mobile
```

#### 1. Get dependencies

Fetch pub dependencies required by the app.

```
$ flutter pub get
```

#### 2. Generate Freezed models

Some of the code in this app is generate by pub tools.

```
$ flutter pub run build_runner build --delete-conflicting-outputs
```

#### 3. Run the app

We've added two `.idea` and `.vscode` folders to help you run the app in your IDE of choice. If those aren't working properly, use the following command.

```
$ flutter build apk --flavor development --target lib/main_development.dart
```

## How to Contribute

We'd love to accept your patches and contributions to this project. There are just a few small
guidelines you need to follow.

- When contributing to this repository, please first discuss the change you wish to make via the
issues section before starting any major work.
- Once you have started work on any issue open a WIP pull request addressing that issue so that we
know that someone is working on it.
- While writing any code for this project ensure that it is well formatted and consistent with the
architecture of the rest of the project.
- Please make sure that you use the
standard [dart nomenclature](https://dart.dev/guides/language/effective-dart/style).
- When contributing to this repository, please first discuss the change you wish to make via the issues section before starting any major work.
- Once you have started work on any issue open a WIP pull request addressing that issue so that we know that someone is working on it.
- While writing any code for this project ensure that it is well formatted and consistent with the architecture of the rest of the project.
- Please make sure that you use the standard [dart nomenclature](https://dart.dev/guides/language/effective-dart/style).
- Before committing any change make sure their is no compilation warning or error.

### For commit messages
## Commit messages

Please start your commits with these prefixes for better understanding among collaborators, based on
the type of commit:
Please start your commits with these prefixes for better understanding among collaborators, based on the type of commit:

feat: (addition of a new feature)
rfac: (refactoring the code: optimization/ different logic of existing code - output doesn't change, just the way of execution changes)
docs: (documenting the code, be it readme, or extra comments)
bfix: (bug fixing)
chor: (chore - beautifying code, indents, spaces, camelcasing, changing variable names to have an appropriate meaning)
ptch: (patches - small changes in code, mainly UI, for example color of a button, incrasing size of tet, etc etc)
conf: (configurational settings - changing directory structure, updating gitignore, add libraries, changing manifest etc)
- feat: (addition of a new feature)
- rfac: (refactoring the code: optimization/ different logic of existing code - output doesn't change, just the way of execution changes)
- docs: (documenting the code, be it readme, or extra comments)
- bfix: (bug fixing)
- chor: (chore - beautifying code, indents, spaces, camelcasing, changing variable names to have an appropriate meaning)
- ptch: (patches - small changes in code, mainly UI, for example color of a button, incrasing size of tet, etc etc)
- conf: (configurational settings - changing directory structure, updating gitignore, add libraries, changing manifest etc)
- test: (adding or editting tests)
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 31
compileSdkVersion 32

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -45,7 +45,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "in.ac.iitr.mdg.codephile"
minSdkVersion 21
targetSdkVersion 30
targetSdkVersion 32
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand Down
1 change: 1 addition & 0 deletions lib/presentation/core/main_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Codephile extends StatelessWidget {
);
},
debugShowCheckedModeBanner: false,
// TODO(developers): Update this with the screen you're testing.
initialRoute: AppRoutes.splash,
navigatorObservers: <NavigatorObserver>[
SentryNavigatorObserver(),
Expand Down
2 changes: 1 addition & 1 deletion lib/presentation/login/login_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class LoginScreen extends StatelessWidget {
Widget build(BuildContext context) {
return BlocProvider<LoginBloc>(
create: (_) => LoginBloc(),
child: DialogAndToastWrapper(
child: DialogAndSnackBarWrapper(
child: BackgroundDecoration(
child: SingleChildScrollView(
padding: EdgeInsets.symmetric(horizontal: 16.r),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
part of 'login_widgets.dart';

/// Wrapper that listens to the [LoginBloc] provided and reacts with dialogs and toasts.
class DialogAndToastWrapper extends StatelessWidget {
/// Wrapper that listens to the [LoginBloc] provided and reacts with dialogs and toasts.
const DialogAndToastWrapper({
/// Wrapper that listens to the [LoginBloc] provided and reacts with dialogs and snackbars.
class DialogAndSnackBarWrapper extends StatelessWidget {
/// Wrapper that listens to the [LoginBloc] provided and reacts with dialogs and snackbars.
const DialogAndSnackBarWrapper({
required this.child,
Key? key,
}) : super(key: key);
Expand All @@ -19,16 +19,16 @@ class DialogAndToastWrapper extends StatelessWidget {
showForgotPasswordDialog(context);
}

// Toast
// SnackBar
if (state.status is Error) {
final message = (state.status as Error).errorMessage;
if (message.isNotEmpty) {
Fluttertoast.showToast(msg: message);
showSnackBar(message: message);
}
} else if (state.status is Idle) {
final message = (state.status as Idle).message;
if (message != null && message.isNotEmpty) {
Fluttertoast.showToast(msg: message);
showSnackBar(message: message);
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions lib/presentation/login/widgets/login_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:get/get.dart';

import '../../../data/constants/assets.dart';
import '../../../data/constants/colors.dart';
import '../../../data/constants/routes.dart';
import '../../../data/constants/styles.dart';
import '../../../domain/models/status.dart';
import '../../../utils/snackbar.dart';
import '../../components/inputs/text_input.dart';
import '../bloc/login_bloc.dart';

part 'background_decoration.dart';
part 'dialog_and_toast_wrapper.dart';
part 'dialog_and_snackbar_wrapper.dart';
part 'forgot_password_button.dart';
part 'login_button.dart';
part 'remember_me_button.dart';
Expand Down
21 changes: 21 additions & 0 deletions lib/utils/snackbar.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import '../data/constants/colors.dart';
import '../data/constants/styles.dart';

void showSnackBar({required String message}) {
ScaffoldMessenger.of(Get.context!).showSnackBar(
SnackBar(
content: Text(
message,
style: AppStyles.h6.copyWith(
color: AppColors.white,
fontSize: 16.sp,
),
),
backgroundColor: AppColors.grey3,
),
);
}
7 changes: 0 additions & 7 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -352,13 +352,6 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
fluttertoast:
dependency: "direct main"
description:
name: fluttertoast
url: "https://pub.dartlang.org"
source: hosted
version: "8.0.8"
freezed:
dependency: "direct dev"
description:
Expand Down
1 change: 0 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ dependencies:
flutter_bloc: ^8.0.1
flutter_screenutil: 5.0.4
flutter_svg: ^1.0.3
fluttertoast: ^8.0.8
freezed_annotation: ^1.1.0
get: ^4.6.1
hive_flutter: ^1.1.0
Expand Down

0 comments on commit 146ed32

Please sign in to comment.