Skip to content

Commit

Permalink
feat(#65): Melhorias visuais
Browse files Browse the repository at this point in the history
  • Loading branch information
zDrNz committed Jan 31, 2025
1 parent b5ad9a8 commit caeba19
Show file tree
Hide file tree
Showing 3 changed files with 213 additions and 20 deletions.
146 changes: 139 additions & 7 deletions lib/ui/access_trails/view/access_trails_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:aranduapp/ui/shared/erro_screen.dart';
import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';
import 'package:provider/provider.dart';
import 'grafismo.dart';

class AccessTrails extends StatelessWidget {
final JourneyModel journey;
Expand All @@ -27,33 +28,164 @@ class _AccessTrailsScreen extends StatelessWidget {

@override
Widget build(BuildContext context) {
final brightness = MediaQuery.of(context).platformBrightness;
final viewModel =
Provider.of<AccessTrailsViewmodel>(context, listen: false);

viewModel.getAccessTrailsCommand.execute(journey.id);

final ColorScheme lightColors = ColorScheme(
brightness: Brightness.light,
primary: const Color(0xFFE65100),
onPrimary: Colors.white,
secondary: Colors.green,
onSecondary: Colors.white,
error: Colors.red,
onError: Colors.white,
background: Colors.grey[200]!,
onBackground: Colors.black,
surface: Colors.white,
onSurface: Colors.black,
onInverseSurface: const Color(0xFFEDE5E0),
);
final ColorScheme darkColors = ColorScheme(
brightness: Brightness.dark,
primary: const Color(0xFFFFB300),
onPrimary: Colors.black,
secondary: const Color(0xFF03DAC6),
onSecondary: Colors.black,
error: const Color(0xFFCF6679),
onError: Colors.black,
background: const Color(0xFF121212),
onBackground: Colors.white,
surface: Colors.black,
onSurface: Colors.white,
onInverseSurface: const Color(0xFF463F2C),
);

final colors = brightness == Brightness.dark ? darkColors : lightColors;
return Scaffold(
appBar: _buildAppBar(context),
body: ListenableBuilder(
listenable: viewModel.getAccessTrailsCommand,
builder: (context, child) {
if (viewModel.getAccessTrailsCommand.isOk)
return CorpoList();
return SingleChildScrollView(
child: Container(
color: Theme.of(context).colorScheme.surface,
child: Center(
child: Column(
children: [
CustomPaint(
painter: Fundo(colors),
child: const SizedBox(
height: 100,
width: 200,
),
),
CustomPaint(
painter: Square(colors),
child: const SizedBox(
height: 100,
width: 200,
),
),
CustomPaint(
painter: Base(colors),
child: const SizedBox(
height: 50,
width: 200,
),
),
CorpoList(colors: colors),
CustomPaint(
painter: Ponta(colors),
child: const SizedBox(
height: 250,
width: 225,
),
),
],
),
),
),
);
else if (viewModel.getAccessTrailsCommand.isError)
return ErrorScreen(
message:
"Dasdf \n ${viewModel.getAccessTrailsCommand.result!.asError!.error.toString()}");
"Não foi possível carregar trilha \n ${viewModel.getAccessTrailsCommand.result!.asError!.error.toString()}");

return Text("asdfasdf");
return Text("a");
}));
}

AppBar _buildAppBar(BuildContext context) {
final brightness = MediaQuery.of(context).platformBrightness;
final ColorScheme lightColors = ColorScheme(
brightness: Brightness.light,
primary: const Color(0xFFE65100),
onPrimary: Colors.white,
secondary: Colors.green,
onSecondary: Colors.white,
error: Colors.red,
onError: Colors.white,
background: Colors.grey[200]!,
onBackground: Colors.black,
surface: Colors.white,
onSurface: Colors.black,
onInverseSurface: const Color(0xFF463F2C),
);

final ColorScheme darkColors = ColorScheme(
brightness: Brightness.dark,
primary: const Color(0xFFFFB300),
onPrimary: Colors.black,
secondary: const Color(0xFF03DAC6),
onSecondary: Colors.black,
error: const Color(0xFFCF6679),
onError: Colors.black,
background: const Color(0xFF121212),
onBackground: Colors.white,
surface: Colors.black,
onSurface: Colors.white,
);

// Escolher o esquema de cores baseado no tema atual
final colors = brightness == Brightness.dark ? darkColors : lightColors;

return AppBar(
title: const Text('Lógica Booleana'),
leading: IconButton(
icon: const Icon(Icons.arrow_back),
onPressed: () => Navigator.of(context).pop(),
backgroundColor: Theme.of(context).colorScheme.surface,
flexibleSpace: CustomPaint(
size: Size(double.infinity, kToolbarHeight),
painter: CustomPatternPainter(colors),
),
toolbarHeight: 60,
title: Stack(
alignment: Alignment.center,
children: [
Container(
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.onInverseSurface,
borderRadius: BorderRadius.circular(20),
),
child: Text(
'Lógica booleana',
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
fontSize: 24,
fontWeight: FontWeight.w500,
),
),
),
],
),
centerTitle: true,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(20),
bottomRight: Radius.circular(20),
),
),
);
}
Expand Down
34 changes: 21 additions & 13 deletions lib/ui/access_trails/view/flecha.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'package:flutter/material.dart';

class Fundo extends CustomPainter {
final ColorScheme colors;
Fundo(this.colors);
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()..color = Colors.grey;
final paint = Paint()..color = colors.onInverseSurface;

final path = Path()
..moveTo(0, 0)
Expand All @@ -21,9 +23,11 @@ class Fundo extends CustomPainter {
}

class Square extends CustomPainter {
final ColorScheme colors;
Square(this.colors);
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()..color = Colors.grey;
final paint = Paint()..color = colors.onInverseSurface;

final path = Path()
..moveTo(0, 0)
Expand All @@ -40,9 +44,11 @@ class Square extends CustomPainter {
}

class Base extends CustomPainter {
final ColorScheme colors;
Base(this.colors);
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()..color = Colors.grey;
final paint = Paint()..color = colors.onInverseSurface;

final path = Path()
..moveTo(0, 0)
Expand All @@ -59,9 +65,11 @@ class Base extends CustomPainter {
}

class Corpo extends CustomPainter {
final ColorScheme colors;
Corpo(this.colors);
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()..color = Colors.grey;
final paint = Paint()..color = colors.onInverseSurface;

final path = Path()
..moveTo(size.width * 1 / 4, 0)
Expand All @@ -78,9 +86,11 @@ class Corpo extends CustomPainter {
}

class Ponta extends CustomPainter {
final ColorScheme colors;
Ponta(this.colors);
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()..color = Colors.grey;
final paint = Paint()..color = colors.onInverseSurface;

final path = Path()
..moveTo(0, 0)
Expand All @@ -96,7 +106,8 @@ class Ponta extends CustomPainter {
}

class CorpoList extends StatelessWidget {
const CorpoList({super.key});
const CorpoList({super.key, required this.colors});
final ColorScheme colors;

@override
Widget build(BuildContext context) {
Expand All @@ -108,7 +119,7 @@ class CorpoList extends StatelessWidget {
children: List.generate(
items.length,
(index) => CustomPaint(
painter: Corpo(),
painter: Corpo(colors),
child: SizedBox(
height: 100,
width: 200,
Expand All @@ -135,16 +146,13 @@ class CorpoList extends StatelessWidget {
);
},
style: ElevatedButton.styleFrom(
backgroundColor: Theme.of(context)
.colorScheme
.primary, // Cor do botão
backgroundColor: Theme.of(context).colorScheme.primary,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(10), // Cantos arredondados
borderRadius: BorderRadius.circular(37.5),
),
),
child: Text(
'B', // Texto no botão
'B',
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface),
),
Expand Down
53 changes: 53 additions & 0 deletions lib/ui/access_trails/view/grafismo.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import 'package:flutter/material.dart';

class CustomPatternPainter extends CustomPainter {
final ColorScheme colors;
CustomPatternPainter(this.colors);
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()
..color = colors.primary
..style = PaintingStyle.fill;

double tileWidth = 50.0; // Largura fixa dos losangos
double tileHeight = 30.0; // Altura fixa dos losangos
int columns = (size.width / tileWidth).floor();

Path path = Path();

double x = 0;

for (int i = 0; i < columns; i++) {
if (i == 0) {
x = 0;
} else {
x = x + (tileWidth * 2);
}

path.moveTo(x, 0);
path.lineTo(x + tileWidth / 2, 0);
path.lineTo(x, tileHeight / 2);
path.lineTo(x, 0);
path.close();

path.moveTo(x + tileWidth / 2, tileHeight / 2);
path.lineTo(x + tileWidth, 0);
path.lineTo(x + tileWidth * 3 / 2, tileHeight / 2);
path.lineTo(x + tileWidth, tileHeight);
path.close();

path.moveTo(x + tileWidth * 3 / 2, 0);
path.lineTo(x + tileWidth * 2, 0);
path.lineTo(x + tileWidth * 2, tileHeight / 2);
path.lineTo(x + tileWidth * 3 / 2, 0);
path.close();
}

canvas.drawPath(path, paint);
}

@override
bool shouldRepaint(covariant CustomPainter oldDelegate) {
return false;
}
}

0 comments on commit caeba19

Please sign in to comment.