From 3966cff936ad17303f889420589c30d6a73b0448 Mon Sep 17 00:00:00 2001 From: zDrNz Date: Tue, 28 Jan 2025 11:53:28 -0300 Subject: [PATCH] feat(#65): Tela de acessar trilhas --- lib/ui/access_trails/view/access_trails.dart | 79 ++++++++++ lib/ui/access_trails/view/flecha.dart | 149 +++++++++++++++++++ 2 files changed, 228 insertions(+) create mode 100644 lib/ui/access_trails/view/access_trails.dart create mode 100644 lib/ui/access_trails/view/flecha.dart diff --git a/lib/ui/access_trails/view/access_trails.dart b/lib/ui/access_trails/view/access_trails.dart new file mode 100644 index 0000000..e145808 --- /dev/null +++ b/lib/ui/access_trails/view/access_trails.dart @@ -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(); + }, + ), + ); + } +} diff --git a/lib/ui/access_trails/view/flecha.dart b/lib/ui/access_trails/view/flecha.dart new file mode 100644 index 0000000..4d87f72 --- /dev/null +++ b/lib/ui/access_trails/view/flecha.dart @@ -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 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), + ), + ), + ), + ), + ], + ), + ), + ), + ), + ); + } +}