Skip to content

Commit

Permalink
APK
Browse files Browse the repository at this point in the history
  • Loading branch information
ositoMalvado committed Oct 17, 2024
1 parent d10671b commit 486f63b
Show file tree
Hide file tree
Showing 5 changed files with 195 additions and 30 deletions.
21 changes: 13 additions & 8 deletions .github/workflows/ipa-build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: IPA Build
name: APK Build

on:
# Runs on push to any of the below branches
Expand All @@ -24,7 +24,7 @@ env:

jobs:
build:
runs-on: macos-latest
runs-on: ubuntu-latest

steps:
- name: Checkout code
Expand All @@ -45,16 +45,21 @@ jobs:
with:
flutter-version: ${{ env.FLUTTER_VERSION }}

- name: Flet Build IPA
- name: Setup Java JDK
uses: actions/[email protected]
with:
distribution: 'temurin' # See https://github.com/marketplace/actions/setup-java-jdk#supported-distributions for available options
java-version: '21'

- name: Flet Build APK
run: |
flutter config --no-analytics
flet build ipa --verbose --build-number=$BUILD_NUMBER --build-version=$BUILD_VERSION --include-packages flet_audio
flet build apk --verbose --include-packages flet_audio
- name: Upload IPA Artifact
- name: Upload APK Artifact
uses: actions/[email protected] # https://github.com/marketplace/actions/upload-a-build-artifact
with:
name: ipa-build-artifact # the name of the artifact
path: build/ipa # location of Flet build output
name: apk-build-artifact # the name of the artifact
path: build/apk # location of Flet build output
if-no-files-found: error # Fail the action with an error message if no files are found
overwrite: false # If true, an artifact with a matching name will be deleted before a new one is uploaded. If false, the action will fail if an artifact for the given name already exists. Does not fail if the artifact does not exist.

Binary file added components/__pycache__/functions.cpython-311.pyc
Binary file not shown.
Binary file added components/__pycache__/widgets.cpython-311.pyc
Binary file not shown.
185 changes: 164 additions & 21 deletions components/widgets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,147 @@
import flet as ft
import time, math, random


class Billetes(ft.Container):
billetes = [
10, 20, 50, 100, 200, 500, 1000, 2000, 10000
]

def update_total(self):
total = 0
for billete in self.billetes:
if self.text_fields[billete].value:
total += int(self.text_fields[billete].value) * billete
self.total_final.value = f"Total: ${str(total)}"
self.total_final.update()
if total > 0:
self.clear_all_button.visible = True
self.clear_all_button.update()
else:
self.clear_all_button.visible = False
self.clear_all_button.update()

def on_change_billete(self, e):
valor = int(e.control.data)
if not e.control.value:
self.totales[valor].value = f"= $0"
self.totales[valor].update()
self.update_total()
return
cantidad = int(e.control.value)
self.totales[valor].value = f"= ${str(int(cantidad * valor))}"
self.totales[valor].update()
self.update_total()

def clear_all_tf(self, e):
for billete in self.billetes:
self.text_fields[billete].value = ""
self.totales[billete].value = f"= $0"
self.text_fields[billete].update()
self.totales[billete].update()
self.update_total()

def clear_tf(self, e):
self.text_fields[int(e.control.data)].value = ""
self.totales[int(e.control.data)].value = f"= $0"
self.text_fields[int(e.control.data)].update()
self.totales[int(e.control.data)].update()
self.update_total()

def __init__(self):
super().__init__()
self.totales = {
billete: ft.Text("= $0", width=100, size=16)
for billete in self.billetes
}
self.total_final = ft.Text("Total: $0", size=24, weight=ft.FontWeight.BOLD)
self.text_fields = {
billete: ft.TextField(label=f"", height=40, content_padding=3, input_filter=ft.NumbersOnlyInputFilter(),
on_change=self.on_change_billete,
data=str(billete),
width=80,
expand=True,
keyboard_type=ft.KeyboardType.NUMBER,
suffix=ft.Container(
padding=ft.padding.only(right=5),
content=ft.IconButton(
ft.icons.CLEAR,
on_click=self.clear_tf,
data=str(billete),
padding=0,
icon_size=15,
width=20,
height=20,
)
)
)
for billete in self.billetes
}
self.clear_all_button = ft.IconButton(
ft.icons.CLEAR_ALL,
on_click=self.clear_all_tf,
visible=False
)
self.content = ft.Column(
[
ft.Stack(
[
ft.Row(
[
self.total_final,
],
alignment=ft.MainAxisAlignment.CENTER,
),
ft.Row(
[
self.clear_all_button
],
alignment=ft.MainAxisAlignment.END,
)
],
),
ft.Column(
[
ft.ListView(
[
ft.ListTile(
leading=ft.Row(
[
ft.Row(
[
ft.Icon(ft.icons.ATTACH_MONEY),
ft.Text(f"{billete}", size=20, weight=ft.FontWeight.BOLD)
],
width=120
),
ft.Row(
[
ft.Text("x", size=20, weight=ft.FontWeight.BOLD),
ft.Container(
self.text_fields[billete],
padding=ft.padding.only(left=10, right=10)
),
self.totales[billete]
],
expand=True,
alignment=ft.MainAxisAlignment.SPACE_BETWEEN
)
],
spacing=0,
vertical_alignment=ft.CrossAxisAlignment.CENTER,
),
content_padding=0,
)
for billete in self.billetes
]
)
],
expand=True,
scroll="auto"
)
]
)

class Widget(ft.Container):

def did_mount(self):
Expand Down Expand Up @@ -108,7 +250,8 @@ class CalculadoraPremio(ft.Container):


def hide_keyboard(self,e ):

if not self.page.platform == ft.PagePlatform.IOS:
return
self.text_field_premio.disabled = True
self.text_field_premio.update()
time.sleep(0.01)
Expand All @@ -122,25 +265,13 @@ def hide_keyboard(self,e ):
self.keyboard = False

def update_premio(self, e):
# Aplicar el descuento del 15%
# if not self.keyboard and e.control == self.text_field_premio :
# self.keyboard = True
# self.page.floating_action_button = ft.FloatingActionButton(
# icon=ft.icons.KEYBOARD_HIDE,
# on_click=self.hide_keyboard
# )
# self.page.update()

if self.text_field_premio.value == '' or int(self.text_field_premio.value) <= 0:
self.valor_final.value = "Ingresa un premio"
self.premio_display.value = "$0"
self.boton_copiar.disabled = True
self.premio_display.update()
self.boton_copiar.update()
# if e.control.data == "descuento":
# return
else:
# return
self.boton_copiar.disabled = False
self.boton_copiar.update()
self.intervalo_display.value = "$" + str(int(self.intervalo_slider.value))
Expand All @@ -153,10 +284,10 @@ def update_premio(self, e):
discounted_value = int(float(self.text_field_premio.value) * (1 - self.descuento / 100))

intervalo = int(self.intervalo_slider.value)
# Redondear al múltiplo de 300 más cercano, siempre hacia arriba

rounded_value = int(math.ceil(discounted_value / intervalo) * intervalo)

# Asegurarse de que el valor redondeado no sea menor que el valor descontado

final_value = max(rounded_value, math.ceil(discounted_value))
self.copy_value = final_value
self.premio_display.value = "$" + str(int(final_value))
Expand Down Expand Up @@ -190,7 +321,7 @@ def copy_premio(self, e):
self.page.update()

def did_mount(self):
# self.page.overlay.append(self.sb_copiado)


self.page.overlay.append(self.sonido)
self.page.overlay.append(self.copy_sound)
Expand Down Expand Up @@ -255,7 +386,7 @@ def __init__(self):
value=self.intervalo,
min=50,
max=1000,
divisions=19, # i need each division be by 50
divisions=19,
on_change=self.slider_handle,
label="Intervalo: 300",
data="intervalo"
Expand All @@ -274,8 +405,7 @@ def __init__(self):
label="Cuotas: " + str(self.cuotas),
data="cuotas"
)

self.content = ft.Column(
pointer = ft.Column(
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
controls=[
ft.Text("Calculadora de Premio", weight=ft.FontWeight.BOLD, expand=True),
Expand Down Expand Up @@ -318,6 +448,19 @@ def __init__(self):
spacing=2,
expand=True
)
if False:
pointer = ft.TransparentPointer(
content=pointer
)
self.content = ft.Stack(
expand=True,
controls=[
ft.GestureDetector(
on_double_tap=lambda _: self.hide_keyboard(None),
),
pointer
]
)
self.border_radius=10
self.border=ft.border.all(1, ft.colors.BLACK12)
self.bgcolor=ft.colors.PRIMARY_CONTAINER
Expand Down Expand Up @@ -366,7 +509,7 @@ def __init__(self):
self.on_click = self.change_theme


# import pythoncom # Import pythoncom



class TabGeneralPatentes(ft.Tab):
Expand Down Expand Up @@ -414,7 +557,7 @@ class TabGeneralPatentes(ft.Tab):

def __init__(self):
super().__init__()
self.text = "Año de auto por patente"
self.text = "Año patente"
self.mi_data_table = ft.DataTable(
columns=[
ft.DataColumn(ft.Text("Patente", weight=ft.FontWeight.BOLD)),
Expand Down
19 changes: 18 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,26 @@ def resize_task():
def on_resize(e):
page.run_thread(resize_task)
page.on_resized = on_resize
page.window.width, page.window.height = calcular_alto(200)
page.window.width, page.window.height = calcular_alto(380)
page.window.always_on_top = True
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER


tabs = ft.Tabs(
[
# ft.Tab(
# text="TEST",
# content=ft.Container(
# expand=True,
# content=ft.Tabs(
# [
# ],
# tab_alignment=ft.TabAlignment.CENTER,
# expand=True
# ),

# )
# ),
ft.Tab(
text="RUS",
content=ft.Container(
Expand All @@ -65,6 +78,10 @@ def on_resize(e):
[
TabGeneralPatentes(),
TabFederacionFranquicias(),
ft.Tab(
text="Premio",
content=Billetes()
)
],
tab_alignment=ft.TabAlignment.CENTER,
expand=True
Expand Down

0 comments on commit 486f63b

Please sign in to comment.