Skip to content

Commit

Permalink
feat(fga-eps-mds/2024.2-ARANDU-DOC\#58): Adicionar padrões de projeto…
Browse files Browse the repository at this point in the history
…, cor, tipografia e provider
  • Loading branch information
EngDann committed Dec 3, 2024
1 parent 5e61f53 commit 4136254
Show file tree
Hide file tree
Showing 4 changed files with 219 additions and 0 deletions.
86 changes: 86 additions & 0 deletions lib/core/theme/app_colors.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import 'package:aranduapp/core/utils/color_utils.dart';
import 'package:flutter/material.dart';

class AppColors {
static late _Colors colors;
static late _GradientColors gradients;
static late _Alerts alerts;
static void initialize(BuildContext context) {
colors = (Theme.of(context).brightness == Brightness.dark)
? _darkColors()
: _lightColors();
gradients = _GradientColors();
alerts = _Alerts();
}

static _Colors get current => colors;
static _GradientColors get currentGradients => gradients;
static _Alerts get currentAlerts => alerts;

static _Colors _lightColors() {
return _Colors(
background: fromHex('#FFFFFF'),
secBackground: fromHex('#ada4a5'),
tituloApp: fromHex('#1E1E1E'),
text: fromHex('#000000'),
subText: fromHex('#7B6F72'),
textSecBackground: fromHex('#ADA4A5'),
losang: fromHex('#9a3412'),
colorDesenho: fromHex('#fed7aa'),
);
}

static _Colors _darkColors() {
return _Colors(
background: fromHex('#181818'),
secBackground: fromHex('#2C2C2C'),
tituloApp: fromHex('#EBEBEB'),
text: fromHex('#FFFFFF'),
subText: fromHex('#F0F0F0'),
textSecBackground: fromHex('#ADA4A5'),
losang: fromHex('#fb923c'),
colorDesenho: fromHex('#c2410b'),
);
}
}

class _Colors {
final Color background;
final Color secBackground;
final Color tituloApp;
final Color text;
final Color subText;
final Color textSecBackground;
final Color losang;
final Color colorDesenho;

_Colors({
required this.background,
required this.secBackground,
required this.tituloApp,
required this.text,
required this.subText,
required this.textSecBackground,
required this.losang,
required this.colorDesenho,
});
}

class _GradientColors {
final LinearGradient orange = LinearGradient(
colors: [fromHex('#FB923C'), fromHex('#C2410C')],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
);
final LinearGradient cyan = LinearGradient(
colors: [fromHex('#38CFE3'), fromHex('#0E7490')],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
);
}

class _Alerts {
final Color error = fromHex('#C00F0C');
final Color alert = fromHex('#D4B139');
final Color success = fromHex('#5A9D4B');
}
92 changes: 92 additions & 0 deletions lib/core/theme/app_typography.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import 'package:aranduapp/core/theme/app_colors.dart';
import 'package:flutter/material.dart';

class AppTypography {
static late _Typography typography;

// Inicialização de acordo com o tema
static void initialize(BuildContext context) {
typography = (Theme.of(context).brightness == Brightness.dark)
? _darkTypography(context)
: _lightTypography(context);
}

static _Typography get current => typography;

// Função para tipografia para o tema claro
static _Typography _lightTypography(BuildContext context) {
final colors = AppColors.current; // Obter as cores do tema atual
return _Typography(
titleH1: TextStyle(
fontFamily: 'Amarante',
fontWeight: FontWeight.bold, // Peso para título H1
fontSize: 26,
color: colors.tituloApp, // Usar a cor definida para o título
),
titleH1SemiBold: TextStyle(
fontFamily: 'Amarante',
fontWeight: FontWeight.w600, // Semi-bold para título H1
fontSize: 26,
color: colors.tituloApp,
),
titleH1Medium: TextStyle(
fontFamily: 'Amarante',
fontWeight: FontWeight.w500, // Medium para título H1
fontSize: 26,
color: colors.tituloApp,
),
titleH1Regular: TextStyle(
fontFamily: 'Amarante',
fontWeight: FontWeight.normal, // Regular para título H1
fontSize: 26,
color: colors.tituloApp,
),
);
}

// Função para tipografia para o tema escuro
static _Typography _darkTypography(BuildContext context) {
final colors = AppColors.current; // Obter as cores do tema atual
return _Typography(
titleH1: TextStyle(
fontFamily: 'Amarante',
fontWeight: FontWeight.bold,
fontSize: 26,
color: colors.tituloApp, // Usar a cor do tema escuro
),
titleH1SemiBold: TextStyle(
fontFamily: 'Amarante',
fontWeight: FontWeight.w600, // Semi-bold para título H1
fontSize: 26,
color: colors.tituloApp,
),
titleH1Medium: TextStyle(
fontFamily: 'Amarante',
fontWeight: FontWeight.w500, // Medium para título H1
fontSize: 26,
color: colors.tituloApp,
),
titleH1Regular: TextStyle(
fontFamily: 'Amarante',
fontWeight: FontWeight.normal, // Regular para título H1
fontSize: 26,
color: colors.tituloApp,
),
);
}
}

// Classe que armazena as configurações de tipografia divididas por Títulos e Subtítulos
class _Typography {
final TextStyle titleH1;
final TextStyle titleH1SemiBold;
final TextStyle titleH1Medium;
final TextStyle titleH1Regular;

_Typography({
required this.titleH1,
required this.titleH1SemiBold,
required this.titleH1Medium,
required this.titleH1Regular,
});
}
11 changes: 11 additions & 0 deletions lib/core/theme/theme_provider.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'package:flutter/material.dart';

class AppProvider with ChangeNotifier {
// Estado global do aplicativo
bool isDarkMode = false;

void toggleTheme() {
isDarkMode = !isDarkMode;
notifyListeners();
}
}
30 changes: 30 additions & 0 deletions lib/core/utils/color_utils.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'dart:ui';

Color fromHex(String hexString) {
final buffer = StringBuffer();
if (hexString.length == 6 || hexString.length == 7) buffer.write('FF');
buffer.write(hexString.replaceFirst('#', ''));
return Color(int.parse(buffer.toString(), radix: 16));
}

class _Colors {
final Color background;
final Color secBackground;
final Color tituloApp;
final Color text;
final Color subText;
final Color textSecBackground;
final Color losang;
final Color colorDesenho;

_Colors({
required this.background,
required this.secBackground,
required this.tituloApp,
required this.text,
required this.subText,
required this.textSecBackground,
required this.losang,
required this.colorDesenho,
});
}

0 comments on commit 4136254

Please sign in to comment.