Files
tainagustului/UI_V2/pages/details/confidentialty_policy.py

44 lines
1.5 KiB
Python

import flet as ft
import json
class ConfidentialtyPolicy:
def __init__(self, page: ft.Page):
self.page = page
def load_data(self):
try:
with open('instance/policies.json', 'r', encoding='utf-8') as f:
data = json.load(f)
return data
except FileNotFoundError:
return {
'confidentialty_policy': '',
'delivery_policy': '',
'cancel_policy': '',
'gdpr': '',
'terms_and_conditions': ''
}
except json.JSONDecodeError:
self.page.snack_bar = ft.SnackBar(ft.Text('Eroare: fișierul policies.json este corupt.'))
self.page.snack_bar.open = True
self.page.update()
return None
except Exception as ex:
self.page.snack_bar = ft.SnackBar(ft.Text(f'Eroare la citirea politicilor: {ex}'))
self.page.snack_bar.open = True
self.page.update()
return None
def build(self):
return ft.Container(
content=ft.Column(
[
ft.Text("Politica de confidențialitate",size = 18, weight=ft.FontWeight.BOLD, text_align=ft.TextAlign.CENTER),
ft.Text(value=self.load_data()['confidentialty_policy'])
],
alignment=ft.MainAxisAlignment.START,
scroll=ft.ScrollMode.ADAPTIVE
),
padding=10,
expand=True
)