Skip to content

Commit

Permalink
feat(#65): Tela de acessar trilhas
Browse files Browse the repository at this point in the history
  • Loading branch information
zDrNz committed Jan 28, 2025
1 parent 1f10097 commit 3966cff
Show file tree
Hide file tree
Showing 2 changed files with 228 additions and 0 deletions.
79 changes: 79 additions & 0 deletions lib/ui/access_trails/view/access_trails.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import 'package:flutter/material.dart';
import 'flecha.dart';

void main() {
runApp(const MainApp());
}

class MainApp extends StatelessWidget {
const MainApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: _buildAppBar(context),
body: SingleChildScrollView(
child: Center(
child: Column(
children: [
CustomPaint(
painter: Fundo(),
child: const SizedBox(
height: 100,
width: 200,
),
),
CustomPaint(
painter: Square(),
child: const SizedBox(
height: 100,
width: 200,
),
),
CustomPaint(
painter: Base(),
child: const SizedBox(
height: 50,
width: 200,
),
),
CorpoList(), // Agora os itens da lista são botões!
CustomPaint(
painter: Ponta(),
child: const SizedBox(
height: 250,
width: 225,
),
),
],
),
),
),
),
);
}

AppBar _buildAppBar(BuildContext context) {
return AppBar(
backgroundColor: Theme.of(context).colorScheme.surface,
elevation: 0,
title: Center(
child: Text(
'Lógica Booleana',
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
fontSize: 24,
),
),
),
leading: IconButton(
color: Theme.of(context).colorScheme.primary,
icon: const Icon(Icons.arrow_back),
onPressed: () {
Navigator.of(context).pop();
},
),
);
}
}
149 changes: 149 additions & 0 deletions lib/ui/access_trails/view/flecha.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
import 'package:flutter/material.dart';

class Fundo extends CustomPainter {
void paint(Canvas canvas, Size size) {
final paint = Paint()..color = Colors.grey;

final path = Path()
..moveTo(0, 0)
..lineTo(0, size.height)
..lineTo(size.width / 2, size.height)
..moveTo(size.width, 0)
..lineTo(size.width, size.height)
..lineTo(size.width / 2, size.height);

canvas.drawPath(path, paint);
}

bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
}

class Square extends CustomPainter {
void paint(Canvas canvas, Size size) {
final paint = Paint()..color = Colors.grey;

final path = Path()
..moveTo(0, 0)
..lineTo(0, size.height)
..lineTo(size.width, size.height)
..lineTo(size.width, 0)
..lineTo(0, 0);

canvas.drawPath(path, paint);
}

bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
}

class Base extends CustomPainter {
void paint(Canvas canvas, Size size) {
final paint = Paint()..color = Colors.grey;

final path = Path()
..moveTo(0, 0)
..lineTo(size.width * 1 / 4, size.height)
..lineTo(size.width * 3 / 4, size.height)
..lineTo(size.width, 0)
..lineTo(0, 0);

canvas.drawPath(path, paint);
}

bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
}

class Corpo extends CustomPainter {
void paint(Canvas canvas, Size size) {
final paint = Paint()..color = Colors.grey;

final path = Path()
..moveTo(size.width * 1 / 4, 0)
..lineTo(size.width * 1 / 4, size.height)
..lineTo(size.width * 3 / 4, size.height)
..lineTo(size.width * 3 / 4, 0)
..lineTo(size.width * 1 / 4, 0);

canvas.drawPath(path, paint);
}

bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
}

class Ponta extends CustomPainter {
void paint(Canvas canvas, Size size) {
final paint = Paint()..color = Colors.grey;

final path = Path()
..moveTo(0, 0)
..lineTo(size.width * 1 / 2, size.height)
..lineTo(size.width, 0)
..lineTo(0, 0);

canvas.drawPath(path, paint);
}

bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
}

class CorpoList extends StatelessWidget {
@override
Widget build(BuildContext context) {
// Lista de dados para os botões
final List<String> items =
List.generate(5, (index) => "Botão ${index + 1}");

return Column(
children: List.generate(
items.length,
(index) => CustomPaint(
painter: Corpo(),
child: SizedBox(
height: 100,
width: 200,
child: Stack(
children: [
Align(
alignment: Alignment.center,
child: Container(
width: 75,
height: 75,
child: ElevatedButton(
onPressed: () {
// Ação ao pressionar o botão
showDialog(
context: context,
builder: (context) => AlertDialog(
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: const Text('OK'),
),
],
),
);
},
style: ElevatedButton.styleFrom(
backgroundColor: Theme.of(context)
.colorScheme
.primary, // Cor do botão
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(10), // Cantos arredondados
),
),
child: Text(
'B', // Texto no botão
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface),
),
),
),
),
],
),
),
),
),
);
}
}

0 comments on commit 3966cff

Please sign in to comment.