Skip to content

Commit

Permalink
update: clean up code style and restructure layout
Browse files Browse the repository at this point in the history
  • Loading branch information
esmaeil.ahmadipour committed Jan 9, 2025
1 parent 1427818 commit 66340bc
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 21 deletions.
1 change: 0 additions & 1 deletion lib/app_scaffold.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:pactus_gui_widgetbook/src/core/theme/app_theme.dart';


class AppScaffold extends StatelessWidget {
const AppScaffold({
super.key,
Expand Down
1 change: 0 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:pactus_gui_widgetbook/app_scaffold.dart';
import 'package:pactus_gui_widgetbook/src/core/utils/gen/localization/app_locales.dart';
import 'package:pactus_gui_widgetbook/src/features/main/language/core/language_constants.dart';
import 'package:pactus_gui_widgetbook/src/core/theme/app_theme.dart';
import 'package:pactus_gui_widgetbook/src/core/theme/app_theme_data.dart';
import 'package:pactus_gui_widgetbook/src/core/utils/gen/localization/customized_localization_addon.dart';
Expand Down
8 changes: 4 additions & 4 deletions lib/src/core/text_styles/inter_text_styles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class InterTextStyles {
fontSize: 24, // font-size: 24px;
fontWeight: FontWeight.w600, // font-weight: 600 (SemiBold);
height:
1.33, // line-height: 32px (32px line-height / 24px font-size = 1.33);
1.33, // line-height: 32px (32px line-height / 24px font-size = 1.33);
);

// Display/semi-bold
Expand All @@ -146,7 +146,7 @@ class InterTextStyles {
fontSize: 30, // font-size: 30px;
fontWeight: FontWeight.w600, // font-weight: 600 (SemiBold);
height:
1.47, // line-height: 44px (44px line-height / 30px font-size = 1.47);
1.47, // line-height: 44px (44px line-height / 30px font-size = 1.47);
);

// BodyLarge/bold
Expand All @@ -155,7 +155,7 @@ class InterTextStyles {
fontSize: 36, // font-size: 36px;
fontWeight: FontWeight.w700, // font-weight: 700 (Bold);
height:
1.33, // line-height: 48px (48px line-height / 36px font-size = 1.33);
1.33, // line-height: 48px (48px line-height / 36px font-size = 1.33);
);

// BodyStrong/bold
Expand All @@ -164,7 +164,7 @@ class InterTextStyles {
fontSize: 14, // font-size: 14px;
fontWeight: FontWeight.w700, // font-weight: 700 (Bold);
height:
1.43, // line-height: 20px (20px line-height / 14px font-size = 1.43);
1.43, // line-height: 20px (20px line-height / 14px font-size = 1.43);
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/core/utils/gen/localization/app_locales.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'dart:ui' show Locale;
import 'dart:ui' show Locale;

class AppLocales {
AppLocales._();
Expand Down
8 changes: 4 additions & 4 deletions lib/src/core/utils/gen/localization/codegen_loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ class CodegenLoader {
Future<Map<String, dynamic>?> load(
String path, Map<String, dynamic> localeMap) {
return Future.value(
mapLocales[Locale(localeMap["language"], localeMap["country"])]);
mapLocales["${Locale(localeMap["language"], localeMap["country"])}"]);
}

static const Map<String, dynamic> enUS = {
'app_name': 'Pactus GUI',
'app_name': 'Pactus GUI (EN)',
'man': 'Man',
'woman': 'Woman',
};
static const Map<String, dynamic> frFR = {
'app_name': 'Pactus GUI',
'app_name': 'Pactus GUI (FR)',
'man': 'Homme',
'woman': 'Femme',
};
static const Map<String, dynamic> esES = {
'app_name': 'Pactus GUI',
'app_name': 'Pactus GUI (ES)',
'man': 'Hombre',
'woman': 'Mujer',
};
Expand Down
8 changes: 3 additions & 5 deletions lib/src/core/utils/gen/localization/translations_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,18 @@ Future<void> _generateAppLocalesClass() async {
const translationsPath = arbDir;
final languageCases = LanguageConstants.languageCases;


final buffer = StringBuffer();
buffer.writeln(' import \'dart:ui\' show Locale;');
buffer.writeln('import \'dart:ui\' show Locale;');
buffer.writeln('');
buffer.writeln('class AppLocales {');
buffer.writeln(' AppLocales._();\n');
buffer.writeln(' static const translationsPath = \'$translationsPath\';\n');

// Generate constants for each locale
for (var locale in languageCases) {
final localeName = '${locale.language}_${locale.country}';
final localeConstName = '${locale.language}${locale.country}Locale';
buffer.writeln(
' static const $localeConstName = Locale(\"${locale.language}\", \"${locale.country}\");');
' static const $localeConstName = Locale("${locale.language}", "${locale.country}");');
}

// Generate the supportedLocales list
Expand Down Expand Up @@ -138,7 +136,7 @@ Future<void> _generateCodegenLoaderFile(
..writeln(' String path, Map<String, dynamic> localeMap) {')
..writeln(' return Future.value(')
..writeln(
' mapLocales[Locale(localeMap["language"], localeMap["country"])]);')
' mapLocales["\${Locale(localeMap["language"], localeMap["country"])}"]);')
..writeln(' }')
..writeln('');

Expand Down
4 changes: 1 addition & 3 deletions lib/src/features/main/language/data/language_case.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@ class LanguageCase {
final String country;

LanguageCase(
{required this.name,
required this.language,
required this.country});
{required this.name, required this.language, required this.country});
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ Widget customButtonWidgetUseCase(BuildContext context) {
final iconStateString = context.knobs.string(
label: 'Icon State',
initialValue: 'withIcon',
description: 'Choose whether the button has an icon or not. Use "withIcon" or "withoutIcon".',
description:
'Choose whether the button has an icon or not. Use "withIcon" or "withoutIcon".',
);

// Map string to ButtonIconState enum
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class CustomButtonWidget extends StatelessWidget {
size: size / 2,
color: Colors.white,
),

Text(context.tr(LocaleKeys.man))
],
),
Expand Down

0 comments on commit 66340bc

Please sign in to comment.