Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Codebase refactor part 2 & bug fixes #221

Merged
merged 20 commits into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 33 additions & 17 deletions docs/config.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,75 @@
## Configuration

1. Create Alice instance:

```dart

Alice alice = Alice();
```

2. Add navigator key to your application:

```dart
MaterialApp( navigatorKey: alice.getNavigatorKey(), home: ...)
MaterialApp(navigatorKey: alice.getNavigatorKey(), home: ...);
```

You need to add this navigator key in order to show inspector UI.
You can use also your navigator key in Alice:

```dart
Alice alice = Alice(showNotification: true, navigatorKey: yourNavigatorKeyHere);

Alice alice = Alice(configuration: AliceConfiguration(navigatorKey: yourNavigatorKeyHere));
```

If you need to pass navigatorKey lazily, you can use:

```dart
alice.setNavigatorKey(yourNavigatorKeyHere);
```
This is minimal configuration required to run Alice. Can set optional settings in Alice constructor, which are presented below. If you don't want to change anything, you can move to Http clients configuration.

### Additional settings
This is minimal configuration required to run Alice. Can set optional settings in Alice constructor,
which are presented below. If you don't want to change anything, you can move to Http clients
configuration.

You can set `showNotification` in Alice constructor to show notification. Clicking on this notification will open inspector.
```dart
Alice alice = Alice(..., showNotification: true);
```
### Alice configuration

You can set `showInspectorOnShake` in Alice constructor to open inspector by shaking your device (default disabled):
You can pass optional `AliceConfiguration` parameter to `Alice` instance.

You can set `showNotification` in Alice constructor to show notification. Clicking on this
notification will open inspector.

```dart
Alice alice = Alice(..., showInspectorOnShake: true);

Alice alice = Alice(configuration: AliceConfiguration(showNotification: true));
```

If you want to pass another notification icon, you can use `notificationIcon` parameter. Default value is @mipmap/ic_launcher.
You can set `showInspectorOnShake` in Alice constructor to open inspector by shaking your device (
default disabled):

```dart
Alice alice = Alice(..., notificationIcon: "myNotificationIconResourceName");

Alice alice = Alice(configuration: AliceConfiguation(showInspectorOnShake: true));
```

If you want to limit max numbers of HTTP calls saved in memory, you may use `maxCallsCount` parameter.
If you want to pass another notification icon, you can use `notificationIcon` parameter. Default
value is @mipmap/ic_launcher.

```dart
Alice alice = Alice(..., maxCallsCount: 1000));

Alice alice = Alice(configuration: AliceConfiguration(notificationIcon: "myNotificationIconResourceName"));
```

If you want to change the Directionality of Alice, you can use the `directionality` parameter. If the parameter is set to null, the Directionality of the app will be used.
If you want to change the Directionality of Alice, you can use the `directionality` parameter. If
the parameter is set to null, the Directionality of the app will be used.

```dart
Alice alice = Alice(..., directionality: TextDirection.ltr);

Alice alice = Alice(configuration: AliceConfiguration(directionality: TextDirection.ltr));
```

If you want to hide share button, you can use `showShareButton` parameter.

```dart
Alice alice = Alice(..., showShareButton: false);

Alice alice = Alice(configuration: AliceConfiguration(showShareButton: false));
```
19 changes: 17 additions & 2 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,51 @@

```yaml
dependencies:
alice: ^1.0.0-dev9
alice: ^1.0.0-dev10
```

2. Choose adapter based on your HTTP client. **pubspec.yaml** file:

### Dio

```yaml
dependencies:
alice_dio: ^1.0.4
```

### Chopper

```yaml
dependencies:
alice_chopper: ^1.0.5
```

### Http

```yaml
dependencies:
alice_http: ^1.0.4
```

### Http Client

```yaml
dependencies:
alice_http_client: ^1.0.4
```

3. Run `get` command:
3. Choose optional database:

### Objectbox
jhomlala marked this conversation as resolved.
Show resolved Hide resolved

```yaml
dependencies:
objectbox: any
alice_objectbox: ^1.0.2
```

4. Run `get` command:

```bash
$ flutter packages get
```
8 changes: 0 additions & 8 deletions docs/other.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ You may need that if you won't use shake or notification:
alice.showInspector();
```

## Saving calls

Alice supports saving logs to your mobile device storage. In order to make save feature works, you need to add in your Android application manifest:

```xml
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
```

## Flutter logs

If you want to log Flutter logs in Alice, you may use these methods:
Expand Down
9 changes: 0 additions & 9 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,6 @@ httpClient

Setting up ObjectBox with Alice is simple, however, there are a few crucial steps which need to be followed.

1. Add it to your dependencies

```yaml
dependencies:
alice_objectbox: ^1.0.0
```

2. Follow the ObjectBox [example](https://github.com/objectbox/objectbox-dart/blob/main/objectbox/example/flutter/objectbox_demo/lib/main.dart)

```dart
Future<void> main() async {
/// This is required so ObjectBox can get the application directory
Expand Down
7 changes: 2 additions & 5 deletions examples/alice/lib/main.dart
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/material.dart';

void main() => runApp(const MyApp());
Expand All @@ -11,11 +12,7 @@ class MyApp extends StatefulWidget {
}

class _MyAppState extends State<MyApp> {
late final Alice _alice = Alice(
showNotification: true,
showInspectorOnShake: true,
maxCallsCount: 1000,
);
late final Alice _alice = Alice(configuration: AliceConfiguration());

@override
Widget build(BuildContext context) {
Expand Down
9 changes: 4 additions & 5 deletions examples/alice_chopper/lib/main.dart
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:alice_chopper/alice_chopper_adapter.dart';
import 'package:alice_chopper_example/interceptors/json_content_type_inerceptor.dart';
import 'package:alice_chopper_example/interceptors/json_headers_interceptor.dart';
Expand Down Expand Up @@ -35,11 +36,9 @@ class MyApp extends StatefulWidget {
class _MyAppState extends State<MyApp> {
final AliceChopperAdapter _aliceChopperAdapter = AliceChopperAdapter();

late final Alice _alice = Alice(
showNotification: true,
showInspectorOnShake: true,
maxCallsCount: 1000,
)..addAdapter(_aliceChopperAdapter);
final configuration = AliceConfiguration();
late final Alice _alice = Alice(configuration: configuration)
..addAdapter(_aliceChopperAdapter);

late final ChopperClient _chopper = ChopperClient(
baseUrl: Uri.https('jsonplaceholder.typicode.com'),
Expand Down
9 changes: 4 additions & 5 deletions examples/alice_dio/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:io';

import 'package:alice/alice.dart';
import 'package:alice/model/alice_configuration.dart';
import 'package:alice_dio/alice_dio_adapter.dart';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
Expand All @@ -19,11 +20,9 @@ class MyApp extends StatefulWidget {
class _MyAppState extends State<MyApp> {
late final AliceDioAdapter _aliceDioAdapter = AliceDioAdapter();

late final Alice _alice = Alice(
showNotification: true,
showInspectorOnShake: true,
maxCallsCount: 1000,
)..addAdapter(_aliceDioAdapter);
final configuration = AliceConfiguration();
late final Alice _alice = Alice(configuration: configuration)
..addAdapter(_aliceDioAdapter);

late final Dio _dio = Dio(BaseOptions(followRedirects: false))
..interceptors.add(_aliceDioAdapter);
Expand Down
9 changes: 4 additions & 5 deletions examples/alice_http/lib/main.dart
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:alice_http/alice_http_adapter.dart';
import 'package:alice_http/alice_http_extensions.dart';
import 'package:flutter/material.dart';
Expand All @@ -16,11 +17,9 @@ class MyApp extends StatefulWidget {
class _MyAppState extends State<MyApp> {
late final AliceHttpAdapter _aliceHttpAdapter = AliceHttpAdapter();

late final Alice _alice = Alice(
showNotification: true,
showInspectorOnShake: true,
maxCallsCount: 1000,
)..addAdapter(_aliceHttpAdapter);
final configuration = AliceConfiguration();
late final Alice _alice = Alice(configuration: configuration)
..addAdapter(_aliceHttpAdapter);

@override
Widget build(BuildContext context) {
Expand Down
9 changes: 4 additions & 5 deletions examples/alice_http_client/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:convert';
import 'dart:io';

import 'package:alice/alice.dart';
import 'package:alice/model/alice_configuration.dart';
import 'package:alice_http_client/alice_http_client_adapter.dart';
import 'package:alice_http_client/alice_http_client_extensions.dart';
import 'package:flutter/material.dart';
Expand All @@ -21,11 +22,9 @@ class _MyAppState extends State<MyApp> {
late final AliceHttpClientAdapter _httpClientAdapter =
AliceHttpClientAdapter();

late final Alice _alice = Alice(
showNotification: true,
showInspectorOnShake: true,
maxCallsCount: 1000,
)..addAdapter(_httpClientAdapter);
final configuration = AliceConfiguration();
late final Alice _alice = Alice(configuration: configuration)
..addAdapter(_httpClientAdapter);

@override
Widget build(BuildContext context) {
Expand Down
11 changes: 6 additions & 5 deletions examples/alice_objectbox/lib/main.dart
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:alice_http/alice_http_adapter.dart';
import 'package:alice_http/alice_http_extensions.dart';
import 'package:alice_objectbox/alice_objectbox.dart';
Expand Down Expand Up @@ -34,14 +35,14 @@ class MyApp extends StatefulWidget {
class _MyAppState extends State<MyApp> {
late final AliceHttpAdapter _aliceHttpAdapter = AliceHttpAdapter();

late final Alice _alice = Alice(
showNotification: true,
showInspectorOnShake: true,
maxCallsCount: 1000,
aliceStorage: AliceObjectBox(
late final configuration = AliceConfiguration(
storage: AliceObjectBox(
store: widget.store,
maxCallsCount: 1000,
),
);
late final Alice _alice = Alice(
configuration: configuration
)..addAdapter(_aliceHttpAdapter);

@override
Expand Down
13 changes: 13 additions & 0 deletions packages/alice/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
# 1.0.0-dev.10

* [BREAKING_CHANGE] Removed `maxCallsCount`. To change call count, use `storage` constructor parameter
with call count.
* [BREAKING_CHANGE] Replaced configuration parameter of Alice with `AliceConfiguration`.
* Fixed issue with invalid count of calls in notification.
* Added payload to notification.
* General refactor of code base.
* Updated documentation.

# 1.0.0-dev.9

* Fixed saving issue with Android 13 onwards.
* Added unit tests.
* Updated CI/CD task for tests.
* General refactor of code base.
* Updated metadata.

# 1.0.0-dev.8

* Added storage abstractions (by Klemen Tusar https://github.com/techouse).
* Added in memory storage implementation (by Klemen Tusar https://github.com/techouse).
* Added translations.

# 1.0.0-dev.7

* Refactored UI code.

# 1.0.0-dev.6
Expand Down
2 changes: 2 additions & 0 deletions packages/alice/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ Alice is an HTTP Inspector tool for Flutter which helps debugging http requests.
✔️ Shake to open inspector
✔️ HTTP calls search
✔️ Flutter/Android logs
✔️ ObjectBox storage


## Documentation
You can find documentation [here.](https://jhomlala.github.io/alice/)
Loading