From 13050116ac014feb96512ef2c65460fd26788df4 Mon Sep 17 00:00:00 2001 From: nadia Date: Mon, 29 Apr 2024 13:00:21 +0200 Subject: [PATCH] ficheros app_bar y bottom_bar creados --- lib/app_bar | 30 +++++++++++++++++++++++++++++ lib/bottom_bar | 44 +++++++++++++++++++++++++++++++++++++++++++ lib/my_home_page.dart | 36 +++++++++-------------------------- 3 files changed, 83 insertions(+), 27 deletions(-) create mode 100644 lib/app_bar create mode 100644 lib/bottom_bar diff --git a/lib/app_bar b/lib/app_bar new file mode 100644 index 0000000..993fbc2 --- /dev/null +++ b/lib/app_bar @@ -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); +} diff --git a/lib/bottom_bar b/lib/bottom_bar new file mode 100644 index 0000000..baded55 --- /dev/null +++ b/lib/bottom_bar @@ -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 _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'); + } + }, + ); + } + + +} diff --git a/lib/my_home_page.dart b/lib/my_home_page.dart index 1a1af4a..bdcd6bf 100644 --- a/lib/my_home_page.dart +++ b/lib/my_home_page.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_project/app_bar'; +import 'package:flutter_project/bottom_bar'; class MyHomePage extends StatelessWidget { const MyHomePage({Key? key, required this.title}) : super(key: key); @@ -8,26 +10,8 @@ class MyHomePage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: 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), // Margen superior - child: Image.asset( - 'assets/logo-civan.png', - height: 150, - width: 150, - ), - ), - ), - ), -), + appBar: const CustomAppBar(), - body: Container( decoration: const BoxDecoration( image: DecorationImage( @@ -40,8 +24,7 @@ class MyHomePage extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, children: [ InkWell( - onTap: () { - }, + onTap: () {}, child: SizedBox( width: 300.0, child: Padding( @@ -66,8 +49,7 @@ class MyHomePage extends StatelessWidget { ), ), InkWell( - onTap: () { - }, + onTap: () {}, child: SizedBox( width: 300.0, child: Padding( @@ -92,8 +74,7 @@ class MyHomePage extends StatelessWidget { ), ), InkWell( - onTap: () { - }, + onTap: () {}, child: SizedBox( width: 300.0, child: Padding( @@ -118,8 +99,7 @@ class MyHomePage extends StatelessWidget { ), ), InkWell( - onTap: () { - }, + onTap: () {}, child: SizedBox( width: 300.0, child: Padding( @@ -147,6 +127,8 @@ class MyHomePage extends StatelessWidget { ), ), ), + bottomNavigationBar: const CustomBottomBar(), + ); } }