Skip to content

Commit 146ed32

Browse files
committed
feat: Replace Toasts with SnackBars.
1 parent 0438027 commit 146ed32

9 files changed

Lines changed: 97 additions & 51 deletions

File tree

README.md

Lines changed: 63 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Codephile
22

3-
Codephile is an application specially made for all the competitive coders out there. With features
4-
like submission feed, contest reminders, user search, and many more, this app is a perfect companion
5-
for stalking your fellow coders and learning from them.
3+
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.
64

75
## Screenshots
86

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

1614
```
17-
|-lib
18-
| |-models {contains object models | used for communication with the back-end}
19-
| |-screens {contains code for the UI}
20-
| |-services {contains code for the buisness logic}
21-
| |-resources {common resources like assets addresses}
22-
| |-main.dart {entry point}
23-
|-assets {contains icons, logos...}
24-
|-android
25-
|-ios
26-
|-test
15+
|- assets { contains icons, images, illustrations }
16+
|- lib
17+
| |- data
18+
| | |- config { contains configuration variables passed at compile-time }
19+
| | |- constants { contains app wide constants like asset strings, colors, routes }
20+
| | |- services { contains ApiService and StorageService }
21+
| |- domain
22+
| | |- models { contains object models }
23+
| | |- repositories { contains repositories according to BLoC architecture pattern }
24+
| |- presentation { contains UI and BLoC code arranged in folders according to app flow }
25+
| | |- components { contains component widgets used throughout the app }
26+
| | |- core { contains important classes including the router and the main_app }
27+
| |- utils { contains utility methods and classes }
28+
| |-main_development.dart { development entrypoint }
29+
| |-main_production.dart { production entrypoint }
30+
|- test { contains widget and unit tests arranged in suites }
31+
```
32+
33+
## Setup for development
34+
35+
#### 0. Clone this repo
36+
```
37+
$ git clone https://github.com/mdgspace/codephile-mobile.git
38+
$ cd codephile-mobile
39+
```
40+
41+
#### 1. Get dependencies
42+
43+
Fetch pub dependencies required by the app.
44+
45+
```
46+
$ flutter pub get
47+
```
48+
49+
#### 2. Generate Freezed models
50+
51+
Some of the code in this app is generate by pub tools.
52+
53+
```
54+
$ flutter pub run build_runner build --delete-conflicting-outputs
55+
```
56+
57+
#### 3. Run the app
58+
59+
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.
60+
61+
```
62+
$ flutter build apk --flavor development --target lib/main_development.dart
2763
```
2864

2965
## How to Contribute
3066

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

34-
- When contributing to this repository, please first discuss the change you wish to make via the
35-
issues section before starting any major work.
36-
- Once you have started work on any issue open a WIP pull request addressing that issue so that we
37-
know that someone is working on it.
38-
- While writing any code for this project ensure that it is well formatted and consistent with the
39-
architecture of the rest of the project.
40-
- Please make sure that you use the
41-
standard [dart nomenclature](https://dart.dev/guides/language/effective-dart/style).
70+
- When contributing to this repository, please first discuss the change you wish to make via the issues section before starting any major work.
71+
- 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.
72+
- While writing any code for this project ensure that it is well formatted and consistent with the architecture of the rest of the project.
73+
- Please make sure that you use the standard [dart nomenclature](https://dart.dev/guides/language/effective-dart/style).
4274
- Before committing any change make sure their is no compilation warning or error.
4375

44-
### For commit messages
76+
## Commit messages
4577

46-
Please start your commits with these prefixes for better understanding among collaborators, based on
47-
the type of commit:
78+
Please start your commits with these prefixes for better understanding among collaborators, based on the type of commit:
4879

49-
feat: (addition of a new feature)
50-
rfac: (refactoring the code: optimization/ different logic of existing code - output doesn't change, just the way of execution changes)
51-
docs: (documenting the code, be it readme, or extra comments)
52-
bfix: (bug fixing)
53-
chor: (chore - beautifying code, indents, spaces, camelcasing, changing variable names to have an appropriate meaning)
54-
ptch: (patches - small changes in code, mainly UI, for example color of a button, incrasing size of tet, etc etc)
55-
conf: (configurational settings - changing directory structure, updating gitignore, add libraries, changing manifest etc)
80+
- feat: (addition of a new feature)
81+
- rfac: (refactoring the code: optimization/ different logic of existing code - output doesn't change, just the way of execution changes)
82+
- docs: (documenting the code, be it readme, or extra comments)
83+
- bfix: (bug fixing)
84+
- chor: (chore - beautifying code, indents, spaces, camelcasing, changing variable names to have an appropriate meaning)
85+
- ptch: (patches - small changes in code, mainly UI, for example color of a button, incrasing size of tet, etc etc)
86+
- conf: (configurational settings - changing directory structure, updating gitignore, add libraries, changing manifest etc)
87+
- test: (adding or editting tests)

android/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
2626
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2727

2828
android {
29-
compileSdkVersion 31
29+
compileSdkVersion 32
3030

3131
compileOptions {
3232
sourceCompatibility JavaVersion.VERSION_1_8
@@ -45,7 +45,7 @@ android {
4545
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
4646
applicationId "in.ac.iitr.mdg.codephile"
4747
minSdkVersion 21
48-
targetSdkVersion 30
48+
targetSdkVersion 32
4949
versionCode flutterVersionCode.toInteger()
5050
versionName flutterVersionName
5151
}

lib/presentation/core/main_app.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class Codephile extends StatelessWidget {
2626
);
2727
},
2828
debugShowCheckedModeBanner: false,
29+
// TODO(developers): Update this with the screen you're testing.
2930
initialRoute: AppRoutes.splash,
3031
navigatorObservers: <NavigatorObserver>[
3132
SentryNavigatorObserver(),

lib/presentation/login/login_screen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class LoginScreen extends StatelessWidget {
1515
Widget build(BuildContext context) {
1616
return BlocProvider<LoginBloc>(
1717
create: (_) => LoginBloc(),
18-
child: DialogAndToastWrapper(
18+
child: DialogAndSnackBarWrapper(
1919
child: BackgroundDecoration(
2020
child: SingleChildScrollView(
2121
padding: EdgeInsets.symmetric(horizontal: 16.r),

lib/presentation/login/widgets/dialog_and_toast_wrapper.dart renamed to lib/presentation/login/widgets/dialog_and_snackbar_wrapper.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
part of 'login_widgets.dart';
22

3-
/// Wrapper that listens to the [LoginBloc] provided and reacts with dialogs and toasts.
4-
class DialogAndToastWrapper extends StatelessWidget {
5-
/// Wrapper that listens to the [LoginBloc] provided and reacts with dialogs and toasts.
6-
const DialogAndToastWrapper({
3+
/// Wrapper that listens to the [LoginBloc] provided and reacts with dialogs and snackbars.
4+
class DialogAndSnackBarWrapper extends StatelessWidget {
5+
/// Wrapper that listens to the [LoginBloc] provided and reacts with dialogs and snackbars.
6+
const DialogAndSnackBarWrapper({
77
required this.child,
88
Key? key,
99
}) : super(key: key);
@@ -19,16 +19,16 @@ class DialogAndToastWrapper extends StatelessWidget {
1919
showForgotPasswordDialog(context);
2020
}
2121

22-
// Toast
22+
// SnackBar
2323
if (state.status is Error) {
2424
final message = (state.status as Error).errorMessage;
2525
if (message.isNotEmpty) {
26-
Fluttertoast.showToast(msg: message);
26+
showSnackBar(message: message);
2727
}
2828
} else if (state.status is Idle) {
2929
final message = (state.status as Idle).message;
3030
if (message != null && message.isNotEmpty) {
31-
Fluttertoast.showToast(msg: message);
31+
showSnackBar(message: message);
3232
}
3333
}
3434
},

lib/presentation/login/widgets/login_widgets.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ import 'package:flutter/material.dart';
33
import 'package:flutter_bloc/flutter_bloc.dart';
44
import 'package:flutter_screenutil/flutter_screenutil.dart';
55
import 'package:flutter_svg/flutter_svg.dart';
6-
import 'package:fluttertoast/fluttertoast.dart';
76
import 'package:get/get.dart';
87

98
import '../../../data/constants/assets.dart';
109
import '../../../data/constants/colors.dart';
1110
import '../../../data/constants/routes.dart';
1211
import '../../../data/constants/styles.dart';
1312
import '../../../domain/models/status.dart';
13+
import '../../../utils/snackbar.dart';
1414
import '../../components/inputs/text_input.dart';
1515
import '../bloc/login_bloc.dart';
1616

1717
part 'background_decoration.dart';
18-
part 'dialog_and_toast_wrapper.dart';
18+
part 'dialog_and_snackbar_wrapper.dart';
1919
part 'forgot_password_button.dart';
2020
part 'login_button.dart';
2121
part 'remember_me_button.dart';

lib/utils/snackbar.dart

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_screenutil/flutter_screenutil.dart';
3+
import 'package:get/get.dart';
4+
5+
import '../data/constants/colors.dart';
6+
import '../data/constants/styles.dart';
7+
8+
void showSnackBar({required String message}) {
9+
ScaffoldMessenger.of(Get.context!).showSnackBar(
10+
SnackBar(
11+
content: Text(
12+
message,
13+
style: AppStyles.h6.copyWith(
14+
color: AppColors.white,
15+
fontSize: 16.sp,
16+
),
17+
),
18+
backgroundColor: AppColors.grey3,
19+
),
20+
);
21+
}

pubspec.lock

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -352,13 +352,6 @@ packages:
352352
description: flutter
353353
source: sdk
354354
version: "0.0.0"
355-
fluttertoast:
356-
dependency: "direct main"
357-
description:
358-
name: fluttertoast
359-
url: "https://pub.dartlang.org"
360-
source: hosted
361-
version: "8.0.8"
362355
freezed:
363356
dependency: "direct dev"
364357
description:

pubspec.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ dependencies:
2020
flutter_bloc: ^8.0.1
2121
flutter_screenutil: 5.0.4
2222
flutter_svg: ^1.0.3
23-
fluttertoast: ^8.0.8
2423
freezed_annotation: ^1.1.0
2524
get: ^4.6.1
2625
hive_flutter: ^1.1.0

0 commit comments

Comments
 (0)