Skip to content
Open
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
21 changes: 20 additions & 1 deletion .github/workflows/app-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,26 @@ jobs:
channel: stable
cache: true
- run: flutter pub get
- run: flutter test
- run: flutter test --exclude-tags golden

golden:
name: Golden
runs-on: macos-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: stable
cache: true
- run: flutter pub get
- run: flutter test --tags golden
- if: failure()
uses: actions/upload-artifact@v4
with:
name: golden-failures
path: app/test/golden/failures/

build-android:
name: Build Android
Expand Down
4 changes: 3 additions & 1 deletion app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,6 @@ android/app/upload-keystore.jks
ios/ExportOptions.plist.local
*.p8
*.p12
*.mobileprovision
*.mobileprovision
# Diferenças dos testes golden
**/test/golden/failures/
12 changes: 12 additions & 0 deletions app/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ lib/

`SessionService.signedIn` (`ValueNotifier`) é restaurado do armazenamento antes do `runApp` e o `GoRouter` observa ele (`refreshListenable`). `sessionRedirect` manda rota privada sem sessão para `/entrar?de=<destino>` e, com sessão, devolve para o destino (só caminho interno) ou para `/inicio`. Por isso tela nenhuma navega depois de entrar ou sair: basta salvar ou remover o token. Rota nova entra em `AppRoutes`; rota aberta sem sessão entra em `AppRoutes.public`. Os links que abrem o app (B56, M21) chegam por esse mesmo roteador.

## Tema e componentes

- `lib/src/core/theme/`: `PhColors` (os tokens `--ph-*` do tema Sertão como `ThemeExtension`, lidos com `context.ph`), `PhTheme.build(colors)` (o `ThemeData`, com Lexend 400/500/600 de `assets/fonts/lexend/` e alvo mínimo de 44 px) e `contrast.dart`.
- Tema por edição (`features/edition_theme/`): `GET /public/editions/{id}/theme`, guardado no aparelho para abrir sem internet. Da edição o app usa só marca, destaque, apoio e logo (`PhColors.withEdition`); texto e cores de estado ficam fixos. Cor que não passa de 4,5:1 com o texto dela (ou de 3:1 da marca sobre o fundo) cai para a do Sertão. O `EditionThemeBloc` (singleton) recebe `EditionThemeRequested(editionId)` quando a edição é escolhida (M05) e `EditionThemeCleared` ao sair; o `AppWidget` monta o `ThemeData` a partir dele.
- `lib/src/core/ui/`: `PhButton` (primário, secundário, perigo, destaque, pequeno, carregando, largura total), `PhChip`, `PhBadge` (estado sempre com texto), `PhCard`, `PhTextField` (rótulo em cima, dica, erro), `PhAppBar` (voltar de 44 px), `PhBottomNav` (5 destinos, Ingresso no centro em destaque), `PhAvatar`, `PhStripe` e os estados `PhOfflineBanner`, `PhMessageState` (vazio), `PhErrorState` e `PhLoadingList`. Tela nova monta com eles antes de estilizar widget do Material na mão.
- Catálogo em `/_dev/componentes` (só em debug, sem login), com a troca entre o Sertão e um tema de edição de exemplo.
- Tema escuro fica fora até o design definir.

## Testes

`flutter test` roda tudo. Os golden (`test/golden/`, marcados com `@Tags(['golden'])`) comparam com imagens geradas num Mac; no CI rodam num job em macOS e o resto roda em Linux com `--exclude-tags golden`. `test/flutter_test_config.dart` carrega a Lexend e os ícones e aceita até 0,5% de diferença. Para atualizar as imagens depois de mudar um componente: `flutter test --tags golden --update-goldens`, e conferir as imagens no PR.

## Comandos

```bash
Expand Down
Binary file added app/assets/fonts/lexend/Lexend-Medium.ttf
Binary file not shown.
Binary file added app/assets/fonts/lexend/Lexend-Regular.ttf
Binary file not shown.
Binary file added app/assets/fonts/lexend/Lexend-SemiBold.ttf
Binary file not shown.
93 changes: 93 additions & 0 deletions app/assets/fonts/lexend/OFL.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Copyright 2018 The Lexend Project Authors (https://github.com/googlefonts/lexend), with Reserved Font Name “RevReading Lexend”.

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
https://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
2 changes: 2 additions & 0 deletions app/dart_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tags:
golden:
25 changes: 13 additions & 12 deletions app/lib/app_widget.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:material_ui/material_ui.dart';
import 'package:phpeste_app/routes.dart';
import 'package:phpeste_app/src/app/features/auth/presentation/bloc/auth_bloc.dart';
import 'package:phpeste_app/src/app/features/edition_theme/presentation/bloc/edition_theme_bloc.dart';
import 'package:phpeste_app/src/core/DI/dependency_injector.dart';
import 'package:phpeste_app/src/core/config/app_config.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:phpeste_app/src/core/theme/ph_theme.dart';

class AppWidget extends StatelessWidget {
const AppWidget({super.key});
Expand All @@ -12,18 +14,17 @@ class AppWidget extends StatelessWidget {
Widget build(BuildContext context) {
return MultiBlocProvider(
providers: [
BlocProvider(
create: (context) => injector<AuthBloc>(),
),
BlocProvider(create: (context) => injector<AuthBloc>()),
BlocProvider.value(value: injector<EditionThemeBloc>()),
],
child: MaterialApp.router(
title: 'PHPeste',
debugShowCheckedModeBanner: !AppConfig.isProduction,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
child: BlocBuilder<EditionThemeBloc, EditionThemeState>(
buildWhen: (previous, current) => previous.colors != current.colors,
builder: (context, state) => MaterialApp.router(
title: 'PHPeste',
debugShowCheckedModeBanner: !AppConfig.isProduction,
theme: PhTheme.build(state.colors),
routerConfig: router,
),
routerConfig: router,
),
);
}
Expand Down
26 changes: 15 additions & 11 deletions app/lib/routes.dart
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
import 'package:flutter/foundation.dart';
import 'package:go_router/go_router.dart';
import 'package:material_ui/material_ui.dart';
import 'package:phpeste_app/src/app/features/auth/presentation/pages/login_page.dart';
import 'package:phpeste_app/src/app/features/base/presentation/pages/base_page.dart';
import 'package:phpeste_app/src/app/features/base/presentation/pages/coming_soon_page.dart';
import 'package:phpeste_app/src/app/features/base/presentation/texts/base_texts.dart';
import 'package:phpeste_app/src/app/features/component_catalog/presentation/pages/component_catalog_page.dart';
import 'package:phpeste_app/src/app/features/home/presentation/pages/home_page.dart';
import 'package:phpeste_app/src/core/DI/dependency_injector.dart';
import 'package:phpeste_app/src/core/services/session_service.dart';

class AppRoutes {
static const String login = '/entrar';
static const String home = '/inicio';
static const String program = '/programacao';
static const String ticket = '/ingresso';
static const String agenda = '/agenda';
static const String profile = '/perfil';
static const String componentCatalog = '/_dev/componentes';

static const Set<String> public = {login};
static const Set<String> public = {login, if (kDebugMode) componentCatalog};
}

String? sessionRedirect({required bool signedIn, required Uri location}) {
Expand All @@ -38,18 +46,14 @@ GoRouter createRouter(SessionService session) => GoRouter(
StatefulShellRoute.indexedStack(
builder: (context, state, shell) => BasePage(shell: shell),
branches: [
StatefulShellBranch(
routes: [
GoRoute(path: AppRoutes.home, name: 'home', builder: (context, state) => const HomePage()),
],
),
StatefulShellBranch(
routes: [
GoRoute(path: AppRoutes.profile, name: 'profile', builder: (context, state) => const Placeholder()),
],
),
StatefulShellBranch(routes: [GoRoute(path: AppRoutes.home, name: 'home', builder: (context, state) => const HomePage())]),
StatefulShellBranch(routes: [GoRoute(path: AppRoutes.program, name: 'program', builder: (context, state) => const ComingSoonPage(title: BaseTexts.program, icon: Icons.calendar_month_outlined))]),
StatefulShellBranch(routes: [GoRoute(path: AppRoutes.ticket, name: 'ticket', builder: (context, state) => const ComingSoonPage(title: BaseTexts.ticket, icon: Icons.confirmation_number_outlined))]),
StatefulShellBranch(routes: [GoRoute(path: AppRoutes.agenda, name: 'agenda', builder: (context, state) => const ComingSoonPage(title: BaseTexts.agenda, icon: Icons.bookmark_border_rounded))]),
StatefulShellBranch(routes: [GoRoute(path: AppRoutes.profile, name: 'profile', builder: (context, state) => const ComingSoonPage(title: BaseTexts.profile, icon: Icons.person_outline_rounded))]),
],
),
if (kDebugMode) GoRoute(path: AppRoutes.componentCatalog, builder: (context, state) => const ComponentCatalogPage()),
GoRoute(path: '/', redirect: (context, state) => AppRoutes.home),
GoRoute(path: AppRoutes.login, name: 'login', builder: (context, state) => const LoginPage()),
],
Expand Down
32 changes: 16 additions & 16 deletions app/lib/src/app/features/base/presentation/pages/base_page.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import 'package:material_ui/material_ui.dart';
import 'package:go_router/go_router.dart';
import 'package:material_ui/material_ui.dart';
import 'package:phpeste_app/src/app/features/base/presentation/texts/base_texts.dart';
import 'package:phpeste_app/src/core/ui/ph_bottom_nav.dart';

class BasePage extends StatelessWidget {
static const int ticketIndex = 2;

static const List<PhNavDestination> destinations = [
PhNavDestination(label: BaseTexts.home, icon: Icons.home_outlined),
PhNavDestination(label: BaseTexts.program, icon: Icons.calendar_month_outlined),
PhNavDestination(label: BaseTexts.ticket, icon: Icons.confirmation_number_outlined),
PhNavDestination(label: BaseTexts.agenda, icon: Icons.bookmark_border_rounded),
PhNavDestination(label: BaseTexts.profile, icon: Icons.person_outline_rounded),
];

const BasePage({super.key, required this.shell});

final StatefulNavigationShell shell;
Expand All @@ -11,22 +22,11 @@ class BasePage extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
body: shell,
bottomNavigationBar: BottomNavigationBar(
bottomNavigationBar: PhBottomNav(
destinations: destinations,
currentIndex: shell.currentIndex,
onTap: shell.goBranch,
showUnselectedLabels: true,
items: const [
BottomNavigationBarItem(
backgroundColor: Colors.white,
icon: Icon(Icons.home_outlined),
label: BaseTexts.home,
),
BottomNavigationBarItem(
icon: Icon(Icons.person),
backgroundColor: Colors.white,
label: BaseTexts.profile,
),
],
highlightedIndex: ticketIndex,
onSelected: (index) => shell.goBranch(index, initialLocation: index == shell.currentIndex),
),
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:material_ui/material_ui.dart';
import 'package:phpeste_app/src/app/features/base/presentation/texts/base_texts.dart';
import 'package:phpeste_app/src/core/ui/ph_app_bar.dart';
import 'package:phpeste_app/src/core/ui/ph_states.dart';

class ComingSoonPage extends StatelessWidget {
final String title;
final IconData icon;

const ComingSoonPage({super.key, required this.title, required this.icon});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: PhAppBar(title: title),
body: PhMessageState(icon: icon, title: BaseTexts.soonTitle, text: BaseTexts.soonText),
);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
class BaseTexts {
static const String home = 'Início';
static const String program = 'Programação';
static const String ticket = 'Ingresso';
static const String agenda = 'Agenda';
static const String profile = 'Perfil';
static const String soonTitle = 'Chega em breve';
static const String soonText = 'Esta parte do app está sendo feita e aparece numa próxima versão.';
}
Loading
Loading