Skip to content

Commit

Permalink
Merge branch 'main' into feat/openapi-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
bkioshn authored Jan 25, 2024
2 parents 9272740 + ed887e3 commit ae10091
Show file tree
Hide file tree
Showing 15 changed files with 375 additions and 74 deletions.
6 changes: 3 additions & 3 deletions catalyst-gateway/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 1 addition & 7 deletions catalyst-gateway/bin/src/service/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ fn get_api_contact() -> ContactObject {
.url("https://projectcatalyst.io")
}

/// A summary describing the API
const API_SUMMARY: &str = "Project Catalyst Gateway API";

/// A long description of the API. Markdown is supported
const API_DESCRIPTION: &str = r#"# Catalyst Gateway API.
Expand All @@ -51,9 +48,7 @@ TODO:

/// Get the license details for the API
fn get_api_license() -> LicenseObject {
LicenseObject::new("Apache 2.0")
.url("https://www.apache.org/licenses/LICENSE-2.0")
.identifier("Apache-2.0")
LicenseObject::new("Apache 2.0").url("https://www.apache.org/licenses/LICENSE-2.0")
}

/// Get the terms of service for the API
Expand All @@ -72,7 +67,6 @@ pub(crate) fn mk_api(
.contact(get_api_contact())
.description(API_DESCRIPTION)
.license(get_api_license())
.summary(API_SUMMARY)
.terms_of_service(TERMS_OF_SERVICE)
.url_prefix(API_URL_PREFIX.as_str());

Expand Down
6 changes: 6 additions & 0 deletions catalyst_voices/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ PODS:
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
- url_launcher_ios (0.0.1):
- Flutter

DEPENDENCIES:
- Flutter (from `Flutter`)
- flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`)
- integration_test (from `.symlinks/plugins/integration_test/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)

EXTERNAL SOURCES:
Flutter:
Expand All @@ -23,12 +26,15 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/integration_test/ios"
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
url_launcher_ios:
:path: ".symlinks/plugins/url_launcher_ios/ios"

SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
flutter_secure_storage: 23fc622d89d073675f2eaa109381aefbcf5a49be
integration_test: 13825b8a9334a850581300559b8839134b124670
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
url_launcher_ios: bf5ce03e0e2088bad9cc378ea97fa0ed5b49673b

PODFILE CHECKSUM: ff9ae414ffbc80ad6f9d2058e299051a15f6eca7

Expand Down
31 changes: 21 additions & 10 deletions catalyst_voices/lib/app/view/app_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,33 @@ import 'package:catalyst_voices_localization/catalyst_voices_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_localized_locales/flutter_localized_locales.dart';
import 'package:go_router/go_router.dart';

const _restorationScopeId = 'rootVoices';

final class AppContent extends StatelessWidget {
const AppContent({super.key});

List<LocalizationsDelegate<dynamic>> get _localizationsDelegates {
return const [
...VoicesLocalizations.localizationsDelegates,
LocaleNamesLocalizationsDelegate(),
];
}

@override
Widget build(BuildContext context) {
final l10n = context.l10n;
return BlocListener<AuthenticationBloc, AuthenticationState>(
listener: (context, state) {},
child: MaterialApp.router(
restorationScopeId: 'rootVoices',
localizationsDelegates: const [
...VoicesLocalizations.localizationsDelegates,
LocaleNamesLocalizationsDelegate(),
],
restorationScopeId: _restorationScopeId,
localizationsDelegates: _localizationsDelegates,
supportedLocales: VoicesLocalizations.supportedLocales,
localeListResolutionCallback: basicLocaleListResolution,
routerConfig: AppRouter.init(
authenticationBloc: context.read<AuthenticationBloc>(),
),
title: 'Catalyst Voices',
routerConfig: _routeConfig(context),
title: l10n.homeScreenText,
theme: ThemeData(
useMaterial3: true,
brightness: Brightness.dark,
bottomNavigationBarTheme: const BottomNavigationBarThemeData(
type: BottomNavigationBarType.fixed,
Expand All @@ -34,4 +39,10 @@ final class AppContent extends StatelessWidget {
),
);
}

GoRouter _routeConfig(BuildContext context) {
return AppRouter.init(
authenticationBloc: context.read<AuthenticationBloc>(),
);
}
}
56 changes: 24 additions & 32 deletions catalyst_voices/lib/app/view/app_page.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ignore_for_file: discarded_futures

import 'package:catalyst_voices/app/view/app_content.dart';
import 'package:catalyst_voices_blocs/catalyst_voices_blocs.dart';
import 'package:catalyst_voices_repositories/catalyst_voices_repositories.dart';
import 'package:catalyst_voices_services/catalyst_voices_services.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

Expand All @@ -13,47 +13,39 @@ final class App extends StatefulWidget {
}

final class _AppState extends State<App> {
late final AuthenticationRepository _authenticationRepository;
late final CredentialsStorageRepository _credentialsStorageRepository;
late final Future<void> _initFuture;

@override
Widget build(BuildContext context) {
return MultiRepositoryProvider(
providers: [
RepositoryProvider.value(
value: _authenticationRepository,
),
],
child: BlocProvider(
create: (_) => AuthenticationBloc(
authenticationRepository: _authenticationRepository,
),
child: const AppContent(),
),
return FutureBuilder<void>(
future: _initFuture,
builder: (context, snapshot) {
return MultiBlocProvider(
providers: _multiBlocProviders(),
child: const AppContent(),
);
},
);
}

@override
Future<void> dispose() async {
await _authenticationRepository.dispose();

super.dispose();
}

@override
void initState() {
super.initState();

_configureRepositories();
_initFuture = _init();
}

void _configureRepositories() {
_credentialsStorageRepository = CredentialsStorageRepository(
secureStorageService: SecureStorageService(),
);
Future<void> _init() async {
await Dependency.instance.init();
}

_authenticationRepository = AuthenticationRepository(
credentialsStorageRepository: _credentialsStorageRepository,
);
List<BlocProvider> _multiBlocProviders() {
return [
BlocProvider<AuthenticationBloc>(
create: (_) => Dependency.instance.get<AuthenticationBloc>(),
),
BlocProvider<LoginBloc>(
create: (_) => Dependency.instance.get<LoginBloc>(),
),
];
}
}
16 changes: 1 addition & 15 deletions catalyst_voices/lib/pages/login/login_page.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import 'package:catalyst_voices/pages/login/login.dart';
import 'package:catalyst_voices_blocs/catalyst_voices_blocs.dart';
import 'package:catalyst_voices_repositories/catalyst_voices_repositories.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

final class LoginPage extends StatelessWidget {
static const loginPage = Key('LoginInPage');
Expand All @@ -11,17 +8,6 @@ final class LoginPage extends StatelessWidget {

@override
Widget build(BuildContext context) {
return BlocProvider(
key: loginPage,
create: (context) {
return LoginBloc(
authenticationRepository:
RepositoryProvider.of<AuthenticationRepository>(
context,
),
);
},
child: const LoginForm(),
);
return const LoginForm();
}
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export 'authentication/authentication.dart';
export 'dependency/dependency.dart';
export 'login/login.dart';
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import 'package:catalyst_voices_blocs/catalyst_voices_blocs.dart';
import 'package:catalyst_voices_blocs/src/dependency/dependency_provider.dart';
import 'package:catalyst_voices_repositories/catalyst_voices_repositories.dart';
import 'package:catalyst_voices_services/catalyst_voices_services.dart';

final class Dependency extends DependencyProvider {
static final Dependency instance = Dependency._();

Dependency._();

Future<void> init() async {
_registerServices();
_registerRepositories();
_registerBlocsWithDependencies();
}

void _registerBlocsWithDependencies() {
this
..registerSingleton<AuthenticationBloc>(
AuthenticationBloc(
authenticationRepository: get(),
),
)
..registerLazySingleton<LoginBloc>(
() => LoginBloc(
authenticationRepository: get(),
),
);
}

void _registerRepositories() {
this
..registerSingleton<CredentialsStorageRepository>(
CredentialsStorageRepository(secureStorageService: get()),
)
..registerSingleton<AuthenticationRepository>(
AuthenticationRepository(credentialsStorageRepository: get()),
);
}

void _registerServices() {
registerSingleton<SecureStorageService>(
SecureStorageService(),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import 'package:flutter/foundation.dart';
import 'package:get_it/get_it.dart';

abstract class DependencyProvider {
static final getIt = GetIt.instance;

static Future<void> get reset => getIt.reset();

@protected
Future<void> allReady() {
return getIt.allReady();
}

T get<T extends Object>() => getIt.get<T>();

Future<T> getAsync<T extends Object>() => getIt.getAsync<T>();

T getWithParam<T extends Object, P extends Object>({P? param}) {
return getIt.get<T>(param1: param);
}

@protected
void registerFactory<T extends Object>(ValueGetter<T> factoryFunc) {
getIt.registerFactory(factoryFunc);
}

@protected
void registerLazySingleton<T extends Object>(
ValueGetter<T> factoryFunc, {
DisposingFunc<T>? dispose,
}) {
getIt.registerLazySingleton(
factoryFunc,
dispose: dispose,
);
}

@protected
void registerSingleton<T extends Object>(T instance) {
getIt.registerSingleton(instance);
}

@protected
void registerSingletonAsync<T extends Object>(
ValueGetter<Future<T>> factoryFunc, {
Iterable<Type>? dependsOn,
}) {
getIt.registerSingletonAsync(
factoryFunc,
dependsOn: dependsOn,
);
}

@protected
void registerSingletonWithDependencies<T extends Object>(
FactoryFunc<T> factoryFunc, {
required List<Type> dependsOn,
}) {
getIt.registerSingletonWithDependencies(
factoryFunc,
dependsOn: dependsOn,
);
}
}
3 changes: 3 additions & 0 deletions catalyst_voices/packages/catalyst_voices_blocs/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ dependencies:
path: ../catalyst_voices_models
catalyst_voices_repositories:
path: ../catalyst_voices_repositories
catalyst_voices_services:
path: ../catalyst_voices_services
catalyst_voices_view_models:
path: ../catalyst_voices_view_models
collection: ^1.17.1
equatable: ^2.0.5
flutter:
sdk: flutter
formz: ^0.6.1
get_it: ^7.6.7
meta: ^1.10.0
result_type: ^0.2.0

Expand Down
Loading

0 comments on commit ae10091

Please sign in to comment.