Skip to content

Commit

Permalink
Feature/example (#4)
Browse files Browse the repository at this point in the history
* Update documentation

* Add metrics

* Add reconnects & subscriptions metrics

* Add metrics

* Update version

* Add override

* Add metrics to readme

* Update metrics

* Add generics

* Update subscription state

* Update metrics documentation

* Update codegeneration

* Update contribution guide

* Fix linter issues

* Bump release

* Add example

* Fix subscribe

* Update readme

* Add example placeholder

* Patch native platform

* Remove tests

* Add sign in form

* Update sign in form

* Update app

* Update example

* Update location of chat connection repository

* Add username by default

* Encode channels

* Update launch

* Update message sender

* Fix queue

* Remove extra column

* Update chat room

* Add placeholder subsriber

* Update analysis options

* Update depricated

* Update chat subscription

* Update chat message

* Bump version to 0.0.1-pre.7

* Update dependencies

* Do not get dependencies in example directory

* Update setting.json

* Update

* Update editor settings in .vscode/settings.json

* Remove nodoc comments

* Update analysis options and localization.dart files, refactor Controller class, and fix linting issues in various files
  • Loading branch information
PlugFox authored May 2, 2024
1 parent c03a5a3 commit c2aac2a
Show file tree
Hide file tree
Showing 37 changed files with 116 additions and 272 deletions.
16 changes: 7 additions & 9 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,25 @@
"editor.suggest.snippetsPreventQuickSuggestions": false,
"editor.suggestSelection": "first",
"editor.tabCompletion": "onlySnippets",
"editor.wordBasedSuggestions": false,
"editor.wordBasedSuggestions": "off",
"editor.selectionHighlight": false,
"editor.defaultFormatter": "Dart-Code.dart-code",
"editor.formatOnSave": true,
"editor.formatOnType": true,
"editor.formatOnPaste": true,
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": true
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
},
"editor.quickSuggestions": {
"comments": "on",
"strings": "on",
"other": "on"
},
"editor.links": true,
"editor.rulers": [80]
"editor.rulers": [
80
]
},
"dart.lineLength": 80,
"dart.doNotFormat": [
Expand All @@ -36,26 +38,22 @@
"**.pbjson.dart",
"**/generated/**"
],

// Flutter Version Manager
//"dart.flutterSdkPath": ".fvm/flutter_sdk",

// Remove .fvm files from search
"search.exclude": {
//"**/.fvm": true,
".dart_tool": true,
"coverage": true,
"build": true
},

// Remove from file watching
"files.watcherExclude": {
//"**/.fvm": true,
".dart_tool": true,
"coverage": true,
"build": true
},

// Causes the debug view to automatically appear when a breakpoint is hit. This
// setting is global and not configurable per-language.
"debug.openDebug": "openOnDebugBreak",
Expand Down Expand Up @@ -83,4 +81,4 @@
]
}
} */
}
}
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: format get test publish deploy centrifugo-up centrifugo-down coverage analyze check pana generate
.PHONY: format get outdated test publish deploy centrifugo-up centrifugo-down coverage analyze check pana generate

format:
@echo "Formatting the code"
Expand All @@ -8,6 +8,9 @@ format:
get:
@dart pub get

outdated:
@dart pub outdated --show-all --dev-dependencies --dependency-overrides --transitive --no-prereleases

test: get
@dart test --debug --coverage=.coverage --platform chrome,vm

Expand Down
3 changes: 0 additions & 3 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ linter:
avoid_js_rounded_ints: true
avoid_print: true
avoid_renaming_method_parameters: true
avoid_returning_null_for_future: true
avoid_returning_null_for_void: true
avoid_single_cascade_in_expression_statements: true
avoid_slow_async_io: true
Expand Down Expand Up @@ -140,7 +139,6 @@ linter:

# Pedantic 1.9.0
always_declare_return_types: true
always_require_non_null_named_parameters: true
annotate_overrides: true
avoid_empty_else: true
avoid_init_to_null: true
Expand Down Expand Up @@ -204,7 +202,6 @@ linter:
prefer_mixin: true
use_setters_to_change_properties: true
avoid_setters_without_getters: true
avoid_returning_null: true
avoid_returning_this: true
type_annotate_public_apis: true
avoid_types_on_closure_parameters: true
Expand Down
1 change: 1 addition & 0 deletions example/ios/Flutter/Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
1 change: 1 addition & 0 deletions example/ios/Flutter/Release.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
44 changes: 44 additions & 0 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}

def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end

File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
use_frameworks!
use_modular_headers!

flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths
end
end

post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
2 changes: 0 additions & 2 deletions example/lib/src/common/constant/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@ enum EnvironmentFlavor {
/// Production
production('production');

/// {@nodoc}
const EnvironmentFlavor(this.value);

/// {@nodoc}
factory EnvironmentFlavor.from(String? value) =>
switch (value?.trim().toLowerCase()) {
'local' || 'loc' || 'lcl' || 'l' => development,
Expand Down
7 changes: 5 additions & 2 deletions example/lib/src/common/controller/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ abstract interface class IControllerObserver {
void onDispose(IController controller);

/// Called on any state change in the controller.
void onStateChanged(IController controller, Object prevState, Object nextState);
void onStateChanged(
IController controller, Object prevState, Object nextState);

/// Called on any error in the controller.
void onError(IController controller, Object error, StackTrace stackTrace);
}

/// {@template controller}
/// {@macro controller}
abstract base class Controller with ChangeNotifier implements IController {
/// {@macro controller}
Controller() {
runZonedGuarded<void>(
() => Controller.observer?.onCreate(this),
Expand All @@ -44,6 +46,7 @@ abstract base class Controller with ChangeNotifier implements IController {
/// Controller observer
static IControllerObserver? observer;

/// Whether the controller is disposed.
bool get isDisposed => _$isDisposed;
bool _$isDisposed = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ base mixin SequentialControllerConcurrency on Controller {
);
}

/// {@nodoc}
final class _ControllerEventQueue {
/// {@nodoc}
_ControllerEventQueue();

final DoubleLinkedQueue<_SequentialTask<Object?>> _queue =
Expand All @@ -57,11 +55,9 @@ final class _ControllerEventQueue {
bool _isClosed = false;

/// Event queue length.
/// {@nodoc}
int get length => _queue.length;

/// Push it at the end of the queue.
/// {@nodoc}
Future<T> push<T>(FutureOr<T> Function() fn) {
final task = _SequentialTask<T>(fn);
_queue.add(task);
Expand All @@ -72,14 +68,12 @@ final class _ControllerEventQueue {
/// Mark the queue as closed.
/// The queue will be processed until it's empty.
/// But all new and current events will be rejected with [WSClientClosed].
/// {@nodoc}
FutureOr<void> close() async {
_isClosed = true;
await _processing;
}

/// Execute the queue.
/// {@nodoc}
void _exec() => _processing ??= Future.doWhile(() async {
final event = _queue.first;
try {
Expand All @@ -104,23 +98,17 @@ final class _ControllerEventQueue {
});
}

/// {@nodoc}
class _SequentialTask<T> {
/// {@nodoc}
_SequentialTask(FutureOr<T> Function() fn)
: _fn = fn,
_completer = Completer<T>();

/// {@nodoc}
final Completer<T> _completer;

/// {@nodoc}
final FutureOr<T> Function() _fn;

/// {@nodoc}
Future<T> get future => _completer.future;

/// {@nodoc}
FutureOr<T> call() async {
final result = await _fn();
if (!_completer.isCompleted) {
Expand All @@ -129,7 +117,6 @@ class _SequentialTask<T> {
return result;
}

/// {@nodoc}
void reject(Object error, [StackTrace? stackTrace]) {
if (_completer.isCompleted) return;
_completer.completeError(error, stackTrace);
Expand Down
2 changes: 1 addition & 1 deletion example/lib/src/common/localization/localization.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final class Localization extends generated.GeneratedLocalization {
/// Get language by code.
static ({String name, String nativeName})? getLanguageByCode(String code) =>
switch (_isoLangs[code]) {
(:String name, :String nativeName) => (
(String name, String nativeName) => (
name: name,
nativeName: nativeName
),
Expand Down
2 changes: 1 addition & 1 deletion example/lib/src/common/widget/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class App extends StatelessWidget {
builder: (context, child) => MediaQuery(
data: MediaQuery.of(context).copyWith(
/* textScaler: TextScaler.noScaling, */
textScaleFactor: 1,
textScaler: const TextScaler.linear(1),
),
child: WindowScope(
/* title: Localization.of(context).title, */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ sealed class AuthenticationState extends _$AuthenticationStateBase {
}

/// Idling state
/// {@nodoc}
final class AuthenticationState$Idle extends AuthenticationState
with _$AuthenticationState {
/// {@nodoc}
const AuthenticationState$Idle(
{required super.user, super.message = 'Idling', this.error});

Expand All @@ -37,28 +35,23 @@ final class AuthenticationState$Idle extends AuthenticationState
}

/// Processing
/// {@nodoc}
final class AuthenticationState$Processing extends AuthenticationState
with _$AuthenticationState {
/// {@nodoc}
const AuthenticationState$Processing(
{required super.user, super.message = 'Processing'});

@override
String? get error => null;
}

/// {@nodoc}
base mixin _$AuthenticationState on AuthenticationState {}

/// Pattern matching for [AuthenticationState].
typedef AuthenticationStateMatch<R, S extends AuthenticationState> = R Function(
S state);

/// {@nodoc}
@immutable
abstract base class _$AuthenticationStateBase {
/// {@nodoc}
const _$AuthenticationStateBase({required this.user, required this.message});

/// Data entity payload.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,26 @@ sealed class ChatConnectionState extends _$ChatConnectionStateBase {
}

/// Disconnected
/// {@nodoc}
final class ChatConnectionState$Disconnected extends ChatConnectionState {
/// {@nodoc}
const ChatConnectionState$Disconnected({super.message = 'Disconnected'});
}

/// Connecting
/// {@nodoc}
final class ChatConnectionState$Connecting extends ChatConnectionState {
/// {@nodoc}
const ChatConnectionState$Connecting({super.message = 'Connecting'});
}

/// Connected
/// {@nodoc}
final class ChatConnectionState$Connected extends ChatConnectionState {
/// {@nodoc}
const ChatConnectionState$Connected({super.message = 'Connected'});
}

/// Pattern matching for [ChatConnectionState].
typedef ChatConnectionStateMatch<R, S extends ChatConnectionState> = R Function(
S state);

/// {@nodoc}
@immutable
abstract base class _$ChatConnectionStateBase {
/// {@nodoc}
const _$ChatConnectionStateBase({required this.message});

/// Message or state description.
Expand Down
Loading

0 comments on commit c2aac2a

Please sign in to comment.