Skip to content

Commit

Permalink
Merge pull request #803 from Prime-Holding/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
DDavidPrime authored Sep 11, 2024
2 parents 1ca892d + 94355b9 commit 059976f
Show file tree
Hide file tree
Showing 16 changed files with 136 additions and 91 deletions.
16 changes: 10 additions & 6 deletions packages/rx_bloc_cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
## [5.0.0]
Generated projects have their dependencies updated:
* `rx_bloc` to `^6.0.0`
* `rxdart` to `^0.28.0`
* Update generated project min supported iOS version to `13.0`
* Generated projects have their dependencies updated:
* `rxdart` to `^0.28.0`
* `rx_bloc` to `^6.0.0` (and related ecosystem packages)
* `widget_toolkit` to `^0.2.0` (and related ecosystem packages)
* `firebase_core` to `^3.4.0` (and related ecosystem packages)
* `alice` to use a forked version until the official package is updated (see [issue](https://github.com/Prime-Holding/rx_bloc/pull/704#issuecomment-2340266154))

## [4.0.1]
* Added [README][patrol_integration_test_url] about Patrol Integration Test.
* Fixed the compile errors of the generated projects.

## [4.0.0]
Contains breaking changes
* The `--enable-auth-matrix` option is removed in favour of the [--enable-mfa][mfa_doc_url] (Multi-Factor Authentication) capability.
* The `go_router` package is upgraded to version `^14.2.1`
* The `flutter_local_notifications` package is upgraded to version `^17.2.1+2`
* The `--enable-auth-matrix` option is removed in favour of the [--enable-mfa][mfa_doc_url] (Multi-Factor Authentication) capability.
* The `go_router` package is upgraded to version `^14.2.1`
* The `flutter_local_notifications` package is upgraded to version `^17.2.1+2`

## [3.8.1]
* Added reference in [example documentation][golden_tests_doc_url] about [writing golden tests for smart widgets with dependency injection][golden_tests_doc_url].
Expand Down
2 changes: 2 additions & 0 deletions packages/rx_bloc_cli/bin/compile_bundles.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env sh

set -e
dart pub upgrade

dart run mason_cli:mason bundle \
-t dart \
-o lib/src/templates/ \
Expand Down
17 changes: 8 additions & 9 deletions packages/rx_bloc_cli/example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -460,18 +460,17 @@ The `AppDevMenuGestureDetector` widget is a widget that is listening for user in
As a good use case, you can wrap your page widget with this widget so you are able to access the functionality while on the same page.

```dart
AppDevMenuGestureDetector.withDependencies(
context,
navKey!,
AppDevMenuGestureDetector(
navigatorKey: navKey!,
child: materialApp,
onDevMenuPresented: () {
showAppDevMenuBottomSheet(
context.read<AppRouter>().rootNavigatorKey.currentContext!,
);
},
onDevMenuPresented: () {
showAppDevMenuBottomSheet(
context.read<AppRouter>().rootNavigatorKey.currentContext!,
);
},
);
```

By default after you trigger `AppDevMenuGestureDetector` you only need to add your proxy ip and restart app so you are all set to use Charles.
Alice is working right out of the box.

Expand Down
19 changes: 16 additions & 3 deletions packages/rx_bloc_cli/lib/src/processors/ios/podfile_processor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class PodfileProcessor extends StringProcessor {
/// Podfile file processor constructor
PodfileProcessor(super.args);

static const _minSupportedIOSVersion = '13.0';

Map<String, String> get _buildModeMapping => {
'Debug': 'debug',
'Profile': 'release',
Expand All @@ -31,8 +33,19 @@ class PodfileProcessor extends StringProcessor {
/// region Private methods
void _updateGlobalIOSPlatform(StringBuffer buffer) {
final replacement =
buffer.toString().replaceAll('# platform :ios', 'platform :ios');
final globalPlatformCommand = 'platform :ios';
var replacement =
buffer.toString().replaceAll('# platform :ios', globalPlatformCommand);

// Update the minimum supported iOS version
var startIndex =
replacement.indexOf("'", replacement.indexOf(globalPlatformCommand));
var endIndex = replacement.indexOf("'", startIndex + 1);
if (startIndex >= 0 && endIndex >= 0 && endIndex > startIndex) {
replacement = replacement.replaceRange(
startIndex + 1, endIndex, _minSupportedIOSVersion);
}

buffer
..clear()
..write(replacement);
Expand Down Expand Up @@ -61,7 +74,7 @@ class PodfileProcessor extends StringProcessor {
'flutter_additional_ios_build_settings(target)';
const deploymentTargetsConfig = '''\n
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '$_minSupportedIOSVersion'
end
''';
buffer.insertAfter(additionalBuildSettingsConfig, deploymentTargetsConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class CommonComponentsPage extends StatelessWidget {
WidgetSection(
description:
context.l10n.featureWidgetToolkit.openUrlWidgetLaunchURLLink,
child: OpenUrlWidget.withDependencies(
child: OpenUrlWidgetWithDependencies(
url: context.l10n.featureWidgetToolkit.primeHoldingUrl,
translateError: translateError,
child: Text(
Expand All @@ -41,7 +41,7 @@ class CommonComponentsPage extends StatelessWidget {
WidgetSection(
description: context
.l10n.featureWidgetToolkit.openUrlWidgetCallAPhoneNumber,
child: OpenUrlWidget.withDependencies(
child: OpenUrlWidgetWithDependencies(
url: context.l10n.featureWidgetToolkit.phoneNumber,
uriType: UriType.telephone,
translateError: translateError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,20 @@ The `AppDevMenuGestureDetector` widget is a widget that is listening for user in

The widget is dependent on the `DevMenuBloc` which is an essential part of the system. The `DevMenuBloc` contains the necessary logic for registering and emitting stream events after a specific number of taps has been made. By default that number is 5 taps, but a custom number can be specified (by setting the `maxTaps` value when instantiating the bloc). The `DevMenuDependencies.from` factory can be used to define all necessary dependencies which can be accessed from the `providers` field.

The `AppDevMenuGestureDetector` widget comes with a static method called `AppDevMenuGestureDetector.withDependencies` which allows you to easily and on-the-go define a widget with the necessary dependencies. It will instantiate and properly nest a child widget within a MultiProvider for you. The hitbox of the `child` widget will be used to trigger any interactions within the bloc.
Besides the `AppDevMenuGestureDetector` widget, you can also use the `AppDevMenuGestureDetectorWithDependencies` which allows you to easily and on-the-go define a widget with the necessary dependencies. It will instantiate and properly nest a child widget within a MultiProvider for you. The hitbox of the `child` widget will be used to trigger any interactions within the bloc.

As a good use case, you can wrap your page widget with this widget so you are able to access the functionality while on the same page. By default whole app is wrapped so you are able to access DevMenu from any page.

```dart
AppDevMenuGestureDetector.withDependencies(
context,
navKey!,
AppDevMenuGestureDetector(
navigatorKey: navKey!,
child: materialApp,
onDevMenuPresented: () {
onDevMenuPresented: () {
showAppDevMenuBottomSheet(
context.read<AppRouter>().rootNavigatorKey.currentContext!,
);
},
);
```

### `showAppDevMenuBottomSheet`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:alice/alice.dart';
import 'package:alice/model/alice_configuration.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_rx_bloc/flutter_rx_bloc.dart';
import 'package:provider/provider.dart';
Expand Down Expand Up @@ -26,9 +27,11 @@ class DevMenuDependencies {
List<Provider> get _packages => [
Provider<Alice>(
create: (context) => Alice(
showNotification: true,
showInspectorOnShake: false,
maxCallsCount: 1000,
configuration: AliceConfiguration(
showNotification: true,
showInspectorOnShake: false,
storage: AliceMemoryStorage(maxCallsCount: 1000),
),
),
)
];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
{{> licence.dart }}

import 'package:alice/alice.dart';
import 'package:alice_dio/alice_dio_adapter.dart';
import 'package:flutter/cupertino.dart';
import 'package:provider/provider.dart';
import 'package:rxdart/rxdart.dart';

import '../../base/data_sources/remote/http_clients/api_http_client.dart';
import '../../base/data_sources/remote/http_clients/plain_http_client.dart';
import '../../lib_router/router.dart';
import '../blocs/dev_menu_bloc.dart';
import '../di/dev_menu_dependencies.dart';
import 'dev_menu_bottom_sheet.dart';

class AppDevMenuGestureDetector extends StatefulWidget {
const AppDevMenuGestureDetector({
Expand All @@ -24,24 +22,6 @@ class AppDevMenuGestureDetector extends StatefulWidget {
final VoidCallback onDevMenuPresented;
final GlobalKey<NavigatorState>? navigatorKey;

static Widget withDependencies(
BuildContext context,
GlobalKey<NavigatorState> navigatorKey, {
required Widget child,
}) =>
MultiProvider(
providers: DevMenuDependencies.from(context).providers,
child: AppDevMenuGestureDetector(
onDevMenuPresented: () {
showAppDevMenuBottomSheet(
AppRouter.rootNavigatorKey.currentContext!,
);
},
navigatorKey: navigatorKey,
child: child,
),
);

@override
State<AppDevMenuGestureDetector> createState() =>
_AppDevMenuGestureDetectorState();
Expand Down Expand Up @@ -81,14 +61,16 @@ class _AppDevMenuGestureDetectorState extends State<AppDevMenuGestureDetector> {

final navKey = widget.navigatorKey;
if (navKey != null) {
//Set navigator key if not null
alice.setNavigatorKey(navKey);
//Set navigator key if not null
alice.setNavigatorKey(navKey);
}
final adapter = AliceDioAdapter();
alice.addAdapter(adapter);

// Attach interceptor to ApiHttpClient
context.read<ApiHttpClient>().interceptors.add(alice.getDioInterceptor());
context.read<ApiHttpClient>().interceptors.add(adapter);

// Attach interceptor to PlainHttpClient
context.read<PlainHttpClient>().interceptors.add(alice.getDioInterceptor());
context.read<PlainHttpClient>().interceptors.add(adapter);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import '../../lib_router/router.dart';
import '../di/dev_menu_dependencies.dart';
import 'app_dev_menu_gesture_detector.dart';
import 'dev_menu_bottom_sheet.dart';

class AppDevMenuGestureDetectorWithDependencies extends StatelessWidget {
const AppDevMenuGestureDetectorWithDependencies({
required this.child,
this.navigatorKey,
super.key,
});

final GlobalKey<NavigatorState>? navigatorKey;
final Widget child;

@override
Widget build(BuildContext context) => MultiProvider(
providers: DevMenuDependencies.from(context).providers,
child: AppDevMenuGestureDetector(
onDevMenuPresented: () {
showAppDevMenuBottomSheet(
AppRouter.rootNavigatorKey.currentContext!,
);
},
navigatorKey: navigatorKey,
child: child,
),
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class FacebookCredentialDataSource {

return FacebookAuthRequestModel(
email: userInfo['email'],
facebookToken: result.accessToken!.token,
facebookToken: result.accessToken!.tokenString,
isAuthenticated: true,
name: userInfo['name'],
userPictureUrl: userInfo['picture']['data']['url'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,18 +460,17 @@ The `AppDevMenuGestureDetector` widget is a widget that is listening for user in
As a good use case, you can wrap your page widget with this widget so you are able to access the functionality while on the same page.

```dart
AppDevMenuGestureDetector.withDependencies(
context,
navKey!,
AppDevMenuGestureDetector(
navigatorKey: navKey!,
child: materialApp,
onDevMenuPresented: () {
showAppDevMenuBottomSheet(
context.read<AppRouter>().rootNavigatorKey.currentContext!,
);
},
onDevMenuPresented: () {
showAppDevMenuBottomSheet(
context.read<AppRouter>().rootNavigatorKey.currentContext!,
);
},
);
```

By default after you trigger `AppDevMenuGestureDetector` you only need to add your proxy ip and restart app so you are all set to use Charles.
Alice is working right out of the box.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import '../../lib_analytics/blocs/analytics_bloc.dart';{{/analytics}}{{#has_auth
import '../../lib_auth/blocs/user_account_bloc.dart';{{/enable_pin_code}}
import '../../lib_auth/data_sources/remote/interceptors/auth_interceptor.dart';{{/has_authentication}} {{#enable_change_language}}
import '../../lib_change_language/bloc/change_language_bloc.dart';{{/enable_change_language}}{{#enable_dev_menu}}
import '../../lib_dev_menu/ui_components/app_dev_menu.dart';{{/enable_dev_menu}}{{#enable_pin_code}}
import '../../lib_dev_menu/ui_components/app_dev_menu_gesture_detector_with_dependencies.dart';{{/enable_dev_menu}}{{#enable_pin_code}}
import '../../lib_pin_code/bloc/create_pin_bloc.dart';
import '../../lib_pin_code/bloc/update_and_verify_pin_bloc.dart';
import '../../lib_pin_code/models/pin_code_arguments.dart';
Expand Down Expand Up @@ -207,9 +207,8 @@ class __MyMaterialAppState extends State<_MyMaterialApp> {

{{#enable_dev_menu}}
if (EnvironmentConfig.enableDevMenu) {
return AppDevMenuGestureDetector.withDependencies(
context,
AppRouter.rootNavigatorKey,
return AppDevMenuGestureDetectorWithDependencies(
navigatorKey: AppRouter.rootNavigatorKey,
child: materialApp,
);
}{{/enable_dev_menu}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ class AnalyticsInterceptor extends Interceptor {
final hasResponse = err.response != null;
observer.analytics.logEvent(name: 'RequestError', parameters: {
'errorType': err.type.toString(),
'errorMessage': err.message,
'errorMessage': err.message.toString(),
'stackTrace': err.stackTrace.toString(),
'requestUrl': err.requestOptions.path,
'requestMethod': err.requestOptions.method,
if (hasResponse && err.response!.statusCode != null)
'responseStatusCode': err.response!.statusCode,
'responseStatusCode': err.response!.statusCode!,
if (hasResponse && err.response!.data != null)
'responseData': err.response!.data.toString(),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class HomePage extends StatelessWidget {
),
bottomNavigationBar: BottomNavigationBar(
key: K.bottomNavigationBar,
backgroundColor: context.designSystem.colors.backgroundColor,
type: BottomNavigationBarType.fixed,
currentIndex: currentIndex,
onTap: onNavigationItemSelected,
Expand Down
Loading

0 comments on commit 059976f

Please sign in to comment.