ficheros app_bar y bottom_bar creados

This commit is contained in:
2024-04-29 13:00:21 +02:00
parent dd5be31611
commit 13050116ac
3 changed files with 83 additions and 27 deletions

30
lib/app_bar Normal file
View File

@ -0,0 +1,30 @@
import 'package:flutter/material.dart';
class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
const CustomAppBar({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return AppBar(
title: const Text(''),
centerTitle: true,
backgroundColor: Color.fromARGB(255, 194, 218, 230),
flexibleSpace: Container(
padding: const EdgeInsets.all(8.0),
child: Center(
child: Padding(
padding: const EdgeInsets.only(top: 30.0),
child: Image.asset(
'assets/logo-civan.png',
height: 150,
width: 150,
),
),
),
),
);
}
@override
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
}

44
lib/bottom_bar Normal file
View File

@ -0,0 +1,44 @@
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
class CustomBottomBar extends StatelessWidget {
const CustomBottomBar({Key? key}) : super(key: key);
Future<void> _launchURL(String url) async {
try {
await launch(url);
} catch (e) {
// Captura de la excepción
print('An error occurred: $e');
}
}
@override
Widget build(BuildContext context) {
return BottomNavigationBar(
items: const [
BottomNavigationBarItem(
icon: Icon(Icons.call),
label: 'Llamar',
),
BottomNavigationBarItem(
icon: Icon(Icons.email),
label: 'Correo',
),
],
selectedItemColor: Colors.blue,
unselectedItemColor: Colors.blue,
backgroundColor: const Color.fromARGB(255, 255, 255, 255),
currentIndex: 0,
onTap: (int index) {
if (index == 0) {
_launchURL('tel:+348766361379');
} else if (index == 1) {
_launchURL('mailto:civan@crcivan.com');
}
},
);
}
}

View File

@ -1,5 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_project/app_bar';
import 'package:flutter_project/bottom_bar';
class MyHomePage extends StatelessWidget { class MyHomePage extends StatelessWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key); const MyHomePage({Key? key, required this.title}) : super(key: key);
@ -8,25 +10,7 @@ class MyHomePage extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: const CustomAppBar(),
title: const Text(''),
centerTitle: true,
backgroundColor: Color.fromARGB(255, 194, 218, 230),
flexibleSpace: Container(
padding: const EdgeInsets.all(8.0),
child: Center(
child: Padding(
padding: const EdgeInsets.only(top: 30.0), // Margen superior
child: Image.asset(
'assets/logo-civan.png',
height: 150,
width: 150,
),
),
),
),
),
body: Container( body: Container(
decoration: const BoxDecoration( decoration: const BoxDecoration(
@ -40,8 +24,7 @@ class MyHomePage extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
InkWell( InkWell(
onTap: () { onTap: () {},
},
child: SizedBox( child: SizedBox(
width: 300.0, width: 300.0,
child: Padding( child: Padding(
@ -66,8 +49,7 @@ class MyHomePage extends StatelessWidget {
), ),
), ),
InkWell( InkWell(
onTap: () { onTap: () {},
},
child: SizedBox( child: SizedBox(
width: 300.0, width: 300.0,
child: Padding( child: Padding(
@ -92,8 +74,7 @@ class MyHomePage extends StatelessWidget {
), ),
), ),
InkWell( InkWell(
onTap: () { onTap: () {},
},
child: SizedBox( child: SizedBox(
width: 300.0, width: 300.0,
child: Padding( child: Padding(
@ -118,8 +99,7 @@ class MyHomePage extends StatelessWidget {
), ),
), ),
InkWell( InkWell(
onTap: () { onTap: () {},
},
child: SizedBox( child: SizedBox(
width: 300.0, width: 300.0,
child: Padding( child: Padding(
@ -147,6 +127,8 @@ class MyHomePage extends StatelessWidget {
), ),
), ),
), ),
bottomNavigationBar: const CustomBottomBar(),
); );
} }
} }