Skip to content

Commit

Permalink
Merge pull request #299 from CollActionteam/fix/spotlight-bloc-usage
Browse files Browse the repository at this point in the history
fix: app fixes
  • Loading branch information
Xazin authored Oct 21, 2022
2 parents 35efec7 + 5420584 commit 8745836
Show file tree
Hide file tree
Showing 13 changed files with 405 additions and 600 deletions.
18 changes: 11 additions & 7 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ command to run when you need to build or re-build these files:
_The watch command keeps re-building generated files. It is generally not recommended to use._

```bash
flutter pub run build_runner watch --delete-conflicting-outputs
flutter pub run build_runner watch -d
```

_If you want to build generated files once run this command, it's preferred._

```bash
flutter pub run build_runner build --delete-conflicting-outputs
flutter pub run build_runner build -d
```

Note: The argument `-d` is shorthand for `--delete-conflicting-outputs` introduced in build_runner 2.3.0

## Imutable app settings

We use an environment file called `.env` to define secrets used in the application. `
Expand Down Expand Up @@ -70,14 +72,15 @@ To update the icons font with a new svg, go to [FlutterIcons](https://www.flutte

To generate the OpenSource licenses dart file via [flutter_oss_licenses](https://pub.dev/packages/flutter_oss_licenses), run the command `flutter pub run flutter_oss_licenses:generate.dart lib/presentation/licenses/oss_licenses.dart` from the project root.

>Note: Run `flutter format .` once [oss_licenses.dart](../lib/presentation/licenses/oss_licenses.dart) is created.
> Note: Run `flutter format .` once [oss_licenses.dart](../lib/presentation/licenses/oss_licenses.dart) is created.
## Running tests and generating Test Report

- Step 1: Just for the 1st time, to make sure that all files are included, run ```./.github/scripts/coverage_gen.sh``` to generate a report for the whole project.
- Step 2: Run ```flutter test --coverage```. This will generate the report locally.
- Step 3: Run ```genhtml coverage/lcov.info -o coverage```.
- Step 4: Run ``` firefox coverage/index.html``` (or run ```coverage/index.html``` to any of your web browser).
- Step 1: Just for the 1st time, to make sure that all files are included, run `./.github/scripts/coverage_gen.sh` to generate a report for the whole project.
- Step 2: Run `flutter test --coverage`. This will generate the report locally.
- Step 3: Run `genhtml coverage/lcov.info -o coverage`.
- Step 4: Run ` firefox coverage/index.html` (or run `coverage/index.html` to any of your web browser).

#### You should see the coverage of your tests line-wise in Codecov.

## Getting Started with Flutter
Expand All @@ -94,6 +97,7 @@ mobile development, and a full API reference.
## Pre-push checks

We have set up Git hooks to prevent extra whitespace and other possible mistakes before pushing the code to your branch. Run the below command in the project root directory to copy the pre-push hooks to your local `.git` directory.

```bash
cp ./hooks/* ./.git/hooks/
```
80 changes: 0 additions & 80 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
PODS:
- country_codes (0.0.1):
- Flutter
- Firebase/Analytics (9.6.0):
- Firebase/Core
- Firebase/Auth (9.6.0):
- Firebase/CoreOnly
- FirebaseAuth (~> 9.6.0)
- Firebase/Core (9.6.0):
- Firebase/CoreOnly
- FirebaseAnalytics (~> 9.6.0)
- Firebase/CoreOnly (9.6.0):
- FirebaseCore (= 9.6.0)
- Firebase/Crashlytics (9.6.0):
- Firebase/CoreOnly
- FirebaseCrashlytics (~> 9.6.0)
- Firebase/RemoteConfig (9.6.0):
- Firebase/CoreOnly
- FirebaseRemoteConfig (~> 9.6.0)
- firebase_analytics (9.3.8):
- Firebase/Analytics (= 9.6.0)
- firebase_core
- Flutter
- firebase_auth (3.11.2):
- Firebase/Auth (= 9.6.0)
- firebase_core
Expand All @@ -32,30 +20,6 @@ PODS:
- Firebase/Crashlytics (= 9.6.0)
- firebase_core
- Flutter
- firebase_remote_config (2.0.20):
- Firebase/RemoteConfig (= 9.6.0)
- firebase_core
- Flutter
- FirebaseABTesting (9.6.0):
- FirebaseCore (~> 9.0)
- FirebaseAnalytics (9.6.0):
- FirebaseAnalytics/AdIdSupport (= 9.6.0)
- FirebaseCore (~> 9.0)
- FirebaseInstallations (~> 9.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.7)
- GoogleUtilities/MethodSwizzler (~> 7.7)
- GoogleUtilities/Network (~> 7.7)
- "GoogleUtilities/NSData+zlib (~> 7.7)"
- nanopb (< 2.30910.0, >= 2.30908.0)
- FirebaseAnalytics/AdIdSupport (9.6.0):
- FirebaseCore (~> 9.0)
- FirebaseInstallations (~> 9.0)
- GoogleAppMeasurement (= 9.6.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.7)
- GoogleUtilities/MethodSwizzler (~> 7.7)
- GoogleUtilities/Network (~> 7.7)
- "GoogleUtilities/NSData+zlib (~> 7.7)"
- nanopb (< 2.30910.0, >= 2.30908.0)
- FirebaseAuth (9.6.0):
- FirebaseCore (~> 9.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.7)
Expand Down Expand Up @@ -85,36 +49,10 @@ PODS:
- GoogleUtilities/Environment (~> 7.7)
- GoogleUtilities/UserDefaults (~> 7.7)
- PromisesObjC (~> 2.1)
- FirebaseRemoteConfig (9.6.0):
- FirebaseABTesting (~> 9.0)
- FirebaseCore (~> 9.0)
- FirebaseInstallations (~> 9.0)
- GoogleUtilities/Environment (~> 7.7)
- "GoogleUtilities/NSData+zlib (~> 7.7)"
- Flutter (1.0.0)
- FMDB (2.7.5):
- FMDB/standard (= 2.7.5)
- FMDB/standard (2.7.5)
- GoogleAppMeasurement (9.6.0):
- GoogleAppMeasurement/AdIdSupport (= 9.6.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.7)
- GoogleUtilities/MethodSwizzler (~> 7.7)
- GoogleUtilities/Network (~> 7.7)
- "GoogleUtilities/NSData+zlib (~> 7.7)"
- nanopb (< 2.30910.0, >= 2.30908.0)
- GoogleAppMeasurement/AdIdSupport (9.6.0):
- GoogleAppMeasurement/WithoutAdIdSupport (= 9.6.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.7)
- GoogleUtilities/MethodSwizzler (~> 7.7)
- GoogleUtilities/Network (~> 7.7)
- "GoogleUtilities/NSData+zlib (~> 7.7)"
- nanopb (< 2.30910.0, >= 2.30908.0)
- GoogleAppMeasurement/WithoutAdIdSupport (9.6.0):
- GoogleUtilities/AppDelegateSwizzler (~> 7.7)
- GoogleUtilities/MethodSwizzler (~> 7.7)
- GoogleUtilities/Network (~> 7.7)
- "GoogleUtilities/NSData+zlib (~> 7.7)"
- nanopb (< 2.30910.0, >= 2.30908.0)
- GoogleDataTransport (9.2.0):
- GoogleUtilities/Environment (~> 7.7)
- nanopb (< 2.30910.0, >= 2.30908.0)
Expand All @@ -127,8 +65,6 @@ PODS:
- PromisesObjC (< 3.0, >= 1.2)
- GoogleUtilities/Logger (7.8.0):
- GoogleUtilities/Environment
- GoogleUtilities/MethodSwizzler (7.8.0):
- GoogleUtilities/Logger
- GoogleUtilities/Network (7.8.0):
- GoogleUtilities/Logger
- "GoogleUtilities/NSData+zlib"
Expand Down Expand Up @@ -173,11 +109,9 @@ PODS:

DEPENDENCIES:
- country_codes (from `.symlinks/plugins/country_codes/ios`)
- firebase_analytics (from `.symlinks/plugins/firebase_analytics/ios`)
- firebase_auth (from `.symlinks/plugins/firebase_auth/ios`)
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
- firebase_crashlytics (from `.symlinks/plugins/firebase_crashlytics/ios`)
- firebase_remote_config (from `.symlinks/plugins/firebase_remote_config/ios`)
- Flutter (from `Flutter`)
- image_cropper (from `.symlinks/plugins/image_cropper/ios`)
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
Expand All @@ -193,17 +127,13 @@ DEPENDENCIES:
SPEC REPOS:
trunk:
- Firebase
- FirebaseABTesting
- FirebaseAnalytics
- FirebaseAuth
- FirebaseCore
- FirebaseCoreDiagnostics
- FirebaseCoreInternal
- FirebaseCrashlytics
- FirebaseInstallations
- FirebaseRemoteConfig
- FMDB
- GoogleAppMeasurement
- GoogleDataTransport
- GoogleUtilities
- GTMSessionFetcher
Expand All @@ -215,16 +145,12 @@ SPEC REPOS:
EXTERNAL SOURCES:
country_codes:
:path: ".symlinks/plugins/country_codes/ios"
firebase_analytics:
:path: ".symlinks/plugins/firebase_analytics/ios"
firebase_auth:
:path: ".symlinks/plugins/firebase_auth/ios"
firebase_core:
:path: ".symlinks/plugins/firebase_core/ios"
firebase_crashlytics:
:path: ".symlinks/plugins/firebase_crashlytics/ios"
firebase_remote_config:
:path: ".symlinks/plugins/firebase_remote_config/ios"
Flutter:
:path: Flutter
image_cropper:
Expand All @@ -251,23 +177,17 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
country_codes: b0900f46ad686281d5dab438e354e44ad10f5941
Firebase: 5ae8b7cf8efce559a653aef0ad95bab3f427c351
firebase_analytics: 9937a91df25cce5b0ee19eaf65277ff8bf0f88e5
firebase_auth: 07a4db69cfa447ac42cb7faa560fc100708b707c
firebase_core: 7c28ecc1e5dd74e03829ac3e9ff5ba3314e737a9
firebase_crashlytics: 520a59314eaaadb34f9be4c2a285d99cfa88ebdb
firebase_remote_config: df81462997f4d1582113c543e5a39ef832cebb92
FirebaseABTesting: 61826730ce9eee8781ba99a2b3420e9bce148dc9
FirebaseAnalytics: 89ad762c6c3852a685794174757e2c60a36b6a82
FirebaseAuth: e4a5d3c36e778e41141b91cc861103a441d80bcc
FirebaseCore: 2082fffcd855f95f883c0a1641133eb9bbe76d40
FirebaseCoreDiagnostics: 99a495094b10a57eeb3ae8efa1665700ad0bdaa6
FirebaseCoreInternal: bca76517fe1ed381e989f5e7d8abb0da8d85bed3
FirebaseCrashlytics: 3210572ddb77801e5a0bd9d7bc890769f2066a0c
FirebaseInstallations: 0a115432c4e223c5ab20b0dbbe4cbefa793a0e8e
FirebaseRemoteConfig: ee09d77a7d7c7e31da6a0d1cf956cd611c85609c
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
GoogleAppMeasurement: 6de2b1a69e4326eb82ee05d138f6a5cb7311bcb1
GoogleDataTransport: 1c8145da7117bd68bbbed00cf304edb6a24de00f
GoogleUtilities: 1d20a6ad97ef46f67bbdec158ce00563a671ebb7
GTMSessionFetcher: ffbb25ec00ebcb5201adab0a56d808f6f1902d9f
Expand Down
5 changes: 2 additions & 3 deletions lib/application/auth/auth_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,8 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
Emitter<AuthState> emit,
_SignedOut event,
) async {
emit(const AuthState.signingOut());
await _authRepository.signOut();
emit(const AuthState.unAuthenticated());
emit(const AuthState.unauthenticated());
}

FutureOr<void> _mapAuthCheckRequestToState(
Expand All @@ -92,7 +91,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {

emit(
userOption.fold(
() => const AuthState.unAuthenticated(),
() => const AuthState.unauthenticated(),
(user) => AuthState.authenticated(user),
),
);
Expand Down
4 changes: 1 addition & 3 deletions lib/application/auth/auth_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,5 @@ class AuthState with _$AuthState {
/// Splash Auth states
const factory AuthState.authenticated(User user) = _Authenticated;

const factory AuthState.signingOut() = _SigningOut;

const factory AuthState.unAuthenticated() = _UnAuthenticated;
const factory AuthState.unauthenticated() = _UnAuthenticated;
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class CrowdActionDetailsPageState extends State<CrowdActionDetailsPage> {
participationBloc = getIt<ParticipationBloc>();
participate = _signUpModal;
id = widget.crowdActionId ?? widget.crowdAction!.id;
crowdAction = widget.crowdAction;
}

@override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:auto_route/auto_route.dart';
import 'package:collaction_app/application/crowdaction/crowdaction_details/crowdaction_details_bloc.dart';
import 'package:collaction_app/presentation/routes/app_routes.gr.dart';
import 'package:collaction_app/presentation/crowdaction/crowdaction_participants/crowdaction_participants_screen.dart';
import 'package:collaction_app/presentation/shared_widgets/shimmers/title_shimmer_line.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
Expand All @@ -20,9 +19,11 @@ class ParticipationCountText extends StatelessWidget {
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () => context.router.push(
CrowdActionParticipantsRoute(
crowdActionId: crowdAction!.id,
onTap: () => Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => CrowdActionParticipantsPage(
crowdActionId: crowdAction!.id,
),
),
),
child: BlocProvider<CrowdActionDetailsBloc>.value(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

import '../../../application/crowdaction/spotlight/spotlight_bloc.dart';
import '../../../infrastructure/core/injection.dart';
import '../../home/widgets/current_upcoming_layout.dart';
import '../../themes/constants.dart';
import 'widgets/in_spotlight_header.dart';
Expand All @@ -12,24 +13,30 @@ class CrowdActionHomeScreen extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: RefreshIndicator(
onRefresh: () async => BlocProvider.of<SpotlightBloc>(context)
.add(const SpotlightEvent.getSpotLightCrowdActions()),
color: kAccentColor,
child: SingleChildScrollView(
child: SizedBox(
width: double.infinity,
child: Column(
children: const [
InSpotLightHeader(),
CurrentAndUpcomingLayout(),
SizedBox(height: 20),
ShareCollActionCard(),
SizedBox(height: 20),
CurrentAndUpcomingLayout(isCurrent: false)
],
return BlocProvider(
create: (context) => getIt<SpotlightBloc>()
..add(const SpotlightEvent.getSpotLightCrowdActions()),
child: Builder(
builder: (context) => Scaffold(
body: SafeArea(
child: RefreshIndicator(
onRefresh: () async => BlocProvider.of<SpotlightBloc>(context)
.add(const SpotlightEvent.getSpotLightCrowdActions()),
color: kAccentColor,
child: SingleChildScrollView(
child: SizedBox(
width: double.infinity,
child: Column(
children: const [
InSpotLightHeader(),
CurrentAndUpcomingLayout(),
SizedBox(height: 20),
ShareCollActionCard(),
SizedBox(height: 20),
CurrentAndUpcomingLayout(isCurrent: false)
],
),
),
),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:intl/intl.dart';

import '../../../../infrastructure/core/injection.dart';
import '../../../shared_widgets/content_placeholder.dart';
import '../../../shared_widgets/crowdaction_card.dart';
import '../../../themes/constants.dart';
Expand Down Expand Up @@ -34,9 +33,8 @@ class _InSpotLightHeaderState extends State<InSpotLightHeader> {

@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => getIt<SpotlightBloc>()
..add(const SpotlightEvent.getSpotLightCrowdActions()),
return BlocProvider.value(
value: BlocProvider.of<SpotlightBloc>(context),
child: LayoutBuilder(
builder: (context, constraints) {
return Container(
Expand Down
6 changes: 2 additions & 4 deletions lib/presentation/home/widgets/current_upcoming_layout.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:auto_route/auto_route.dart';
import 'package:collaction_app/infrastructure/core/injection.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

Expand All @@ -25,9 +24,8 @@ class CurrentAndUpcomingLayout extends StatefulWidget {
class _CurrentAndUpcomingLayoutState extends State<CurrentAndUpcomingLayout> {
@override
Widget build(BuildContext context) {
return BlocProvider<SpotlightBloc>(
create: (context) => getIt<SpotlightBloc>()
..add(const SpotlightEvent.getSpotLightCrowdActions()),
return BlocProvider.value(
value: BlocProvider.of<SpotlightBloc>(context),
child: BlocBuilder<SpotlightBloc, SpotlightState>(
builder: (ctx, state) => LayoutBuilder(
builder: (context, constraints) {
Expand Down
Loading

0 comments on commit 8745836

Please sign in to comment.