Skip to content

Commit

Permalink
refactor: reformat code, organize import
Browse files Browse the repository at this point in the history
  • Loading branch information
cevheri committed Dec 18, 2024
1 parent 16db4c1 commit 320dc9d
Show file tree
Hide file tree
Showing 16 changed files with 1,395 additions and 278 deletions.
1 change: 0 additions & 1 deletion lib/configuration/local_storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class AppLocalStorageCached {
/// LocalStorage predefined keys
enum StorageKeys { jwtToken, roles, language, username, theme }


/// Application Local Storage
///
/// This class is used to store data locally with the help of shared preferences.
Expand Down
3 changes: 1 addition & 2 deletions lib/data/models/menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class Menu extends Equatable {
}
return result;
}

static List<Menu> fromJsonStringList(String json) {
List<Menu> result = [];
var jsonList = jsonDecode(json) as List<dynamic>;
Expand All @@ -130,8 +131,6 @@ class Menu extends Equatable {
return result;
}



Map<String, dynamic>? toJson() => JsonMapper.toMap(this);

@override
Expand Down
1 change: 0 additions & 1 deletion lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"max_length_500": "Field cannot be more than 500 characters long",
"max_length_1000": "Field cannot be more than 1000 characters long",
"max_length_4000": "Field cannot be more than 4000 characters long",

"required_range": "Range is required",
"list": "List",
"filter": "Filter",
Expand Down
7 changes: 5 additions & 2 deletions lib/main/app_stateless_widget.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import 'dart:io';
import 'package:flutter/material.dart';

import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:flutter/material.dart';

/// App stateless widget
/// This class is used to create a stateless widget that can be used in the app.
Expand Down Expand Up @@ -51,7 +52,9 @@ abstract class AppStatelessWidget extends StatelessWidget {
const AppStatelessWidget({super.key});

Widget buildCupertinoWidget(BuildContext context);

Widget buildMaterialWidget(BuildContext context);

Widget buildWebWidget(BuildContext context);

@override
Expand All @@ -64,4 +67,4 @@ abstract class AppStatelessWidget extends StatelessWidget {
}
return buildMaterialWidget(context);
}
}
}
733 changes: 644 additions & 89 deletions lib/main/main_local.mapper.g.dart

Large diffs are not rendered by default.

733 changes: 644 additions & 89 deletions lib/main/main_prod.mapper.g.dart

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AuthorityBloc extends Bloc<AuthorityEvent, AuthorityState> {
emit(const AuthorityLoadingState());
try {
final authorities = await _repository.getAuthorities();
if(authorities.isEmpty) {
if (authorities.isEmpty) {
emit(const AuthorityLoadFailureState(message: "No authorities found"));
_log.error("END: getAuthorities bloc: _onLoad error: {}", ["No authorities found"]);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ class ChangeThemeEvent extends DrawerEvent {

@override
List<Object> get props => [theme];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ class DrawerLanguageChanged extends DrawerState {

class DrawerThemeChanged extends DrawerState {
const DrawerThemeChanged({required super.theme}) : super(status: DrawerStateStatus.success);
}
}
8 changes: 4 additions & 4 deletions lib/presentation/screen/account/account_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ class AccountScreen extends StatelessWidget {
final user = _createUserFromFormData(formData, state.data?.id);

context.read<UserBloc>().add(UserSubmitEvent(user));
late final StreamSubscription<UserState> userSubscription;
userSubscription = context.read<UserBloc>().stream.listen((userState) {
if (userState.status == UserStatus.success && context.mounted) {
late final StreamSubscription<UserState> subscription;
subscription = context.read<UserBloc>().stream.listen((userState) {
if ((userState.status == UserStatus.success || userState.status == UserStatus.saveSuccess) && context.mounted) {
context.read<AccountBloc>().add(const AccountFetchEvent());
_formKey.currentState?.reset();
userSubscription.cancel();
subscription.cancel();
}
}); // cancel the stream after the first event
}
Expand Down
3 changes: 1 addition & 2 deletions lib/presentation/screen/components/editor_form_mode.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

/// Enum for the mode of the editor form
///
/// The editor form can be in one of three modes:
/// - create: the form is used to create a new entity
/// - edit: the form is used to edit an existing entity
/// - view: the form is used to view an existing entity
enum EditorFormMode { create, edit, view }
enum EditorFormMode { create, edit, view }
4 changes: 3 additions & 1 deletion lib/presentation/screen/home/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ class HomeScreen extends StatelessWidget {
debugPrint("HomeScreen account bloc builder: ${state.status}");
if (state.status == AccountStatus.success) {
return Scaffold(
appBar: AppBar(title: const Text(AppConstants.appName),),
appBar: AppBar(
title: const Text(AppConstants.appName),
),
key: _scaffoldKey,
body: Center(child: Column(children: [backgroundImage(context)])),
drawer: _buildDrawer(context),
Expand Down
1 change: 0 additions & 1 deletion lib/presentation/screen/login/bloc/login_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
_log.debug("onSubmit save storage username: {}", [event.username]);
emit(LoginLoadedState(username: event.username, password: event.password));


_log.debug("END:onSubmit LoginFormSubmitted event success: {}", [token.toString()]);
} else {
throw BadRequestException("Invalid Access Token");
Expand Down
4 changes: 2 additions & 2 deletions lib/presentation/screen/settings/settings_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class SettingsScreen extends StatelessWidget {

_buildAppBar(BuildContext context) {
return AppBar(
title: Text(S.of(context).settings),
leading: IconButton(icon: const Icon(Icons.arrow_back), onPressed: () => AppRouter().push(context, ApplicationRoutesConstants.home)),
title: Text(S.of(context).settings),
leading: IconButton(icon: const Icon(Icons.arrow_back), onPressed: () => AppRouter().push(context, ApplicationRoutesConstants.home)),
);
}

Expand Down
Loading

0 comments on commit 320dc9d

Please sign in to comment.