diff --git a/.gitignore b/.gitignore index 68bc17f..275db0d 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,7 @@ __pycache__/ .Python build/ develop-eggs/ -dist/ +# dist/ downloads/ eggs/ .eggs/ diff --git a/Funciones.py b/Funciones.py new file mode 100644 index 0000000..0db9b58 --- /dev/null +++ b/Funciones.py @@ -0,0 +1,20 @@ +def github_to_raw(url): + # Dividir la URL en partes + parts = url.split('/') + + # Verificar si es una URL de GitHub + if 'github.com' not in parts: + return "La URL proporcionada no es de GitHub" + + # Encontrar el índice de 'github.com' en la URL + github_index = parts.index('github.com') + + # Construir la nueva URL + raw_url = 'https://raw.githubusercontent.com' + + # Agregar el resto de la ruta, saltando 'github.com' y eliminando 'blob' si está presente + for part in parts[github_index + 1:]: + if part != 'blob': + raw_url += '/' + part + + return raw_url \ No newline at end of file diff --git a/Tabs.py b/Tabs.py new file mode 100644 index 0000000..fdacf48 --- /dev/null +++ b/Tabs.py @@ -0,0 +1,153 @@ +import flet as ft +from Widgets import CalculadoraPremio + +class TabFederacionFranquicias(ft.Tab): + + franquicias = [ + {"tipo": "Auto", "porcentaje": "1%", "Monto": "$300.000"}, + {"tipo": "Auto", "porcentaje": "2%", "Monto": "$400.000"}, + {"tipo": "Auto", "porcentaje": "4%", "Monto": "$500.000"}, + {"tipo": "Auto", "porcentaje": "6%", "Monto": "$630.000"}, + {"tipo": "Camiones", "porcentaje": "2%", "Monto": "$1.150.000"}, + {"tipo": "Acoplados", "porcentaje": "2%", "Monto": "$870.000"}, + ] + + + def __init__(self): + super().__init__() + self.text = "Franquicias" + self.mi_data_table = ft.DataTable( + columns=[ + ft.DataColumn(ft.Text("Tipo de Vehículo", weight=ft.FontWeight.BOLD), tooltip="Tipo de Vehículo"), + ft.DataColumn(ft.Text("% Suma Asegurada", weight=ft.FontWeight.BOLD), tooltip="% Suma Asegurada"), + ft.DataColumn(ft.Text("Monto mínimo de Franquicia", weight=ft.FontWeight.BOLD), tooltip="Monto mínimo de Franquicia"), + ], + rows=[], + ) + + for i, franquicia in enumerate(self.franquicias): + self.mi_data_table.rows.append( + ft.DataRow( + cells=[ + ft.DataCell(ft.Text(franquicia["tipo"], weight=ft.FontWeight.BOLD)), + ft.DataCell(ft.Text(franquicia["porcentaje"])), + ft.DataCell(ft.Text(franquicia["Monto"])), + ], + color=ft.colors.BLACK12 if i % 2 == 0 else None + ) + ) + self.expand = True + self.content = ft.Column( + controls=[ + ft.Container(height=5), + ft.Container( + self.mi_data_table, + border_radius=10, + border=ft.border.all(1, ft.colors.BLACK12), + bgcolor=ft.colors.PRIMARY_CONTAINER + ) + ], + spacing=0, + horizontal_alignment=ft.CrossAxisAlignment.CENTER, + scroll="auto", + expand=True + ) + +class TabGeneralPatentes(ft.Tab): + + patentes = { + "AG450AA": "Enero 2024", + "AG300AA": "Octubre 2023", + "AG000AA": "Mayo 2023", + "AF770AA": "Enero 2023", + "AF600AA": "Octubre 2022", + "AF000AA": "Agosto 2021", + "AE600AA": "Enero 2021", + "AE100AA": "Enero 2020", + "AE000AA": "Octubre 2019", + "AD400AA": "Enero 2019", + "AD000AA": "Julio 2018", + "AC200AA": "Enero 2018", + "AC000AA": "Noviembre 2017", + "AB000AA": "Febrero 2017", + "AA900AA": "Enero 2017", + "AA000AA": "Abril 2016", + "PMA000": "2016", + "ONA000": "2015", + "NMA000": "2014", + "MBA000": "2013", + "KUA000": "2012", + "JNA000": "2011", + "IMA000": "2010", + "HTA000": "2009", + "GVA000": "2008", + "GBA000": "2007", + "FIA000": "2006", + "ETA000": "2005", + "EIA000": "2004", + "EDA000": "2003", + "DXA000": "2002", + "DOA000": "2001", + "DCA000": "2000", + "CMA000": "1999", + "BUA000": "1998", + "BDA000": "1997", + "APA000": "1996", + "AAA000": "1995", + } + + def __init__(self): + super().__init__() + self.text = "Año de auto por patente" + self.mi_data_table = ft.DataTable( + columns=[ + ft.DataColumn(ft.Text("Patente", weight=ft.FontWeight.BOLD), tooltip="Patente"), + ft.DataColumn(ft.Text("Año", weight=ft.FontWeight.BOLD), tooltip="Año"), + ], + rows=[], + ) + for i, patente in enumerate(self.patentes): + self.mi_data_table.rows.append( + ft.DataRow( + cells=[ + ft.DataCell(ft.Text(patente, weight=ft.FontWeight.BOLD)), + ft.DataCell(ft.Text(self.patentes[patente])), + ], + color=ft.colors.BLACK12 if i % 2 == 0 else None + ) + ) + + self.expand = True + self.content = ft.Column( + controls=[ + ft.Container(height=5), + ft.Container( + self.mi_data_table, + border_radius=10, + border=ft.border.all(1, ft.colors.BLACK12), + bgcolor=ft.colors.PRIMARY_CONTAINER + ) + ], + spacing=0, + horizontal_alignment=ft.CrossAxisAlignment.CENTER, + scroll="auto", + expand=True + ) + +class TabRioUruguayPremio(ft.Tab): + + def __init__(self): + super().__init__() + self.text = "Premio" + + self.expand = True + self.content = ft.Column( + controls=[ + ft.Container(height=5), + CalculadoraPremio() + ], + spacing=0, + horizontal_alignment=ft.CrossAxisAlignment.CENTER, + scroll="auto", + expand=True + ) diff --git a/Widgets.py b/Widgets.py new file mode 100644 index 0000000..a4890dc --- /dev/null +++ b/Widgets.py @@ -0,0 +1,63 @@ +import flet as ft +import math +class CalculadoraPremio(ft.Container): + + + def update_premio(self, e): + # Aplicar el descuento del 15% + # Actualizar el valor en la interfaz + if final_value and self.text_field_premio.value: + discounted_value = float(self.text_field_premio.value) * 0.85 + + # Redondear al múltiplo de 300 más cercano, siempre hacia arriba + rounded_value = math.ceil(discounted_value / 300) * 300 + + # Asegurarse de que el valor redondeado no sea menor que el valor descontado + final_value = max(rounded_value, math.ceil(discounted_value)) + + self.valor_final.value = str(int(final_value)) + else: + self.valor_final.value = "0" + self.valor_final.update() + + def __init__(self): + super().__init__() + + self.valor_final = ft.Text("0") + + self.text_field_premio = ft.TextField( + label="Premio", + prefix_icon=ft.icons.ATTACH_MONEY_ROUNDED, + hint_text="Ingresa el premio", + on_change=self.update_premio + ) + self.boton_copiar = ft.ElevatedButton( + content=ft.Row( + [ + ft.Icon(ft.icons.ATTACH_MONEY_ROUNDED), + self.valor_final, + ], + alignment=ft.MainAxisAlignment.SPACE_BETWEEN, + ), + tooltip="Copiar premio con descuento", + ) + self.content = ft.Column( + controls=[ + ft.Text("Calculadora de Premio"), + self.text_field_premio, + self.boton_copiar + ] + ) + self.border_radius=10 + self.border=ft.border.all(1, ft.colors.BLACK12) + self.bgcolor=ft.colors.PRIMARY_CONTAINER + self.width=500 + self.padding=10 + + +def main(page: ft.Page): + page.add(CalculadoraPremio()) + + +if __name__ == "__main__": + ft.app(target=main) \ No newline at end of file diff --git a/assets/favicon.ico b/assets/favicon.ico new file mode 100644 index 0000000..a0f5bef Binary files /dev/null and b/assets/favicon.ico differ diff --git a/assets/favicon.png b/assets/favicon.png new file mode 100644 index 0000000..269063d Binary files /dev/null and b/assets/favicon.png differ diff --git a/assets/marzo24.jpg b/assets/marzo24.jpg new file mode 100644 index 0000000..f768f8a Binary files /dev/null and b/assets/marzo24.jpg differ diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000..a0f5bef Binary files /dev/null and b/favicon.ico differ diff --git a/favicon.png b/favicon.png new file mode 100644 index 0000000..269063d Binary files /dev/null and b/favicon.png differ diff --git a/main.py b/main.py index 8f5429e..014418e 100644 --- a/main.py +++ b/main.py @@ -1,8 +1,71 @@ import flet as ft - +from Tabs import * +from Funciones import * +import random def main(page: ft.Page): - page.add(ft.SafeArea(ft.Text("Te amo ana"))) + + page.horizontal_alignment = ft.CrossAxisAlignment.CENTER + page.padding = 0 + + page.fonts = { + "Sans": github_to_raw("https://github.com/chrisbull/font-collection/raw/master/GoogleSans/GoogleSans-Regular.ttf") + } + + page.theme = ft.Theme( + font_family="Sans" + ) + + def change_color(): + random_color = "#%02x%02x%02x" % (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) + page.theme = ft.Theme( + color_scheme_seed=random_color + ) + page.update() + change_color() + + page.add( + ft.Tabs( + [ + ft.Tab( + text="Federación Patronal", + content=ft.Tabs( + [ + TabFederacionFranquicias() + ], + tab_alignment=ft.TabAlignment.CENTER, + expand=True, + scrollable=True + ) + ), + ft.Tab( + text="Río Uruguay", + content=ft.Tabs( + [ + TabRioUruguayPremio() + ], + tab_alignment=ft.TabAlignment.CENTER, + expand=True, + scrollable=True + ) + ), + ft.Tab( + text="General", + content=ft.Tabs( + [ + TabGeneralPatentes() + ], + tab_alignment=ft.TabAlignment.CENTER, + expand=True, + scrollable=True + ) + ) + ], + tab_alignment=ft.TabAlignment.CENTER, + expand=True + ) + ) + -ft.app(main, view=ft.WEB_BROWSER) \ No newline at end of file +ft.app(main, assets_dir="assets", view=ft.AppView.WEB_BROWSER) \ No newline at end of file