Sabatino81 commited on
Commit
e99c86d
ยท
verified ยท
1 Parent(s): 37ce01e

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +250 -36
app.py CHANGED
@@ -1189,7 +1189,7 @@ def render_background_html(bg_id: str, bg_info: dict, primary: str, secondary: s
1189
 
1190
  def render_header_html(header_id: str, header_info: dict, primary: str, secondary: str, accent: str) -> str:
1191
  """
1192
- Generate HTML/CSS for a single header preview
1193
  Returns HTML div with the header rendered
1194
  """
1195
  header_name = header_info['name']
@@ -1197,53 +1197,267 @@ def render_header_html(header_id: str, header_info: dict, primary: str, secondar
1197
  # Common container style
1198
  base_style = "width: 300px; height: 100px; border-radius: 12px 12px 0 0; position: relative; overflow: hidden; box-shadow: 0 4px 12px rgba(0,0,0,0.15); background: linear-gradient(135deg, {}, {});".format(primary, secondary)
1199
 
1200
- # Generate header based on type
1201
- if header_id == "minimal":
1202
  content = f"""
1203
- <div style="padding: 20px; text-align: center;">
1204
- <div style="color: white; font-size: 20px; font-weight: 700;">Dashboard</div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1205
  </div>
1206
  """
1207
- elif header_id == "avatar_search":
1208
  content = f"""
1209
  <div style="padding: 12px; display: flex; align-items: center; gap: 10px;">
1210
- <div style="width: 36px; height: 36px; border-radius: 50%; background: {accent}; display: flex; align-items: center; justify-content: center; color: white;">๐Ÿ‘ค</div>
1211
- <div style="flex: 1; background: rgba(255,255,255,0.2); border-radius: 20px; padding: 8px 12px; font-size: 12px; color: rgba(255,255,255,0.8);">๐Ÿ” Search...</div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1212
  <div style="color: white; font-size: 20px;">๐Ÿ””</div>
1213
  </div>
1214
  """
1215
- elif header_id == "tabs":
1216
  content = f"""
1217
- <div style="padding: 16px 20px 8px;">
1218
- <div style="color: white; font-size: 18px; font-weight: 700; margin-bottom: 12px;">Dashboard</div>
1219
- <div style="display: flex; gap: 16px; font-size: 13px;">
1220
- <span style="color: white; border-bottom: 2px solid white; padding-bottom: 4px;">Home</span>
1221
- <span style="color: rgba(255,255,255,0.6);">Activity</span>
1222
- <span style="color: rgba(255,255,255,0.6);">Profile</span>
 
 
 
1223
  </div>
1224
  </div>
1225
  """
1226
- elif header_id == "collapsible":
1227
  content = f"""
1228
- <div style="padding: 20px;">
1229
- <div style="color: white; font-size: 22px; font-weight: 700;">Dashboard</div>
1230
- <div style="color: rgba(255,255,255,0.7); font-size: 12px; margin-top: 4px;">Welcome back</div>
 
 
 
1231
  </div>
1232
  """
1233
- elif header_id == "stats_header":
1234
  content = f"""
1235
- <div style="padding: 20px; display: flex; justify-content: space-around;">
1236
- <div style="text-align: center;">
1237
- <div style="color: white; font-size: 18px; font-weight: 700;">24</div>
1238
- <div style="color: rgba(255,255,255,0.7); font-size: 10px;">Active</div>
1239
  </div>
1240
- <div style="text-align: center;">
1241
- <div style="color: white; font-size: 18px; font-weight: 700;">156</div>
1242
- <div style="color: rgba(255,255,255,0.7); font-size: 10px;">Total</div>
 
1243
  </div>
1244
- <div style="text-align: center;">
1245
- <div style="color: white; font-size: 18px; font-weight: 700;">4.8</div>
1246
- <div style="color: rgba(255,255,255,0.7); font-size: 10px;">Rating</div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1247
  </div>
1248
  </div>
1249
  """
@@ -1468,7 +1682,7 @@ def generate_background_gallery(theme_json: str = ""):
1468
 
1469
  def generate_header_gallery(theme_json: str = ""):
1470
  """
1471
- Generate HTML gallery of all 5 headers
1472
  Headers are rendered directly with HTML/CSS using theme colors
1473
  """
1474
  from agents.flutter_screen_generator import FlutterScreenGenerator
@@ -1497,9 +1711,9 @@ def generate_header_gallery(theme_json: str = ""):
1497
  html_parts = []
1498
  html_parts.append("""
1499
  <div style="background: #f8f9fa; padding: 24px; border-radius: 12px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">
1500
- <h3 style="margin-top: 0; color: #212529; font-size: 20px;">๐ŸŽฏ Header Catalog (5 Headers)</h3>
1501
  <p style="color: #6c757d; font-size: 14px; margin-bottom: 24px;">
1502
- Tutti gli header renderizzati con i tuoi colori del tema
1503
  </p>
1504
  """)
1505
 
@@ -2093,10 +2307,10 @@ Snapchat - bright colors, fun filters, youthful design""",
2093
 
2094
  # Header Gallery Section
2095
  gr.Markdown("---")
2096
- with gr.Accordion("๐ŸŽฏ Header Catalog (5 Headers)", open=False):
2097
  gr.Markdown("""
2098
- Tutti i 5 header disponibili con preview renderizzate in HTML/CSS.
2099
- Gli header vengono stilizzati automaticamente con i colori del tema.
2100
  """)
2101
 
2102
  # Refresh button to update with new theme
 
1189
 
1190
  def render_header_html(header_id: str, header_info: dict, primary: str, secondary: str, accent: str) -> str:
1191
  """
1192
+ Generate HTML/CSS for a single header preview (20 realistic headers)
1193
  Returns HTML div with the header rendered
1194
  """
1195
  header_name = header_info['name']
 
1197
  # Common container style
1198
  base_style = "width: 300px; height: 100px; border-radius: 12px 12px 0 0; position: relative; overflow: hidden; box-shadow: 0 4px 12px rgba(0,0,0,0.15); background: linear-gradient(135deg, {}, {});".format(primary, secondary)
1199
 
1200
+ # SOCIAL & PROFILE (5)
1201
+ if header_id == "profile_avatar_menu":
1202
  content = f"""
1203
+ <div style="padding: 14px; display: flex; align-items: center; gap: 12px;">
1204
+ <div style="width: 44px; height: 44px; border-radius: 50%; background: white; display: flex; align-items: center; justify-content: center; font-size: 24px;">๐Ÿ‘ค</div>
1205
+ <div style="flex: 1;">
1206
+ <div style="color: white; font-size: 15px; font-weight: 700;">John Doe</div>
1207
+ <div style="color: rgba(255,255,255,0.8); font-size: 11px;">๐Ÿ“ San Francisco, CA</div>
1208
+ </div>
1209
+ <div style="color: white; font-size: 24px; cursor: pointer;">โ˜ฐ</div>
1210
+ </div>
1211
+ """
1212
+ elif header_id == "avatar_notification_cart":
1213
+ content = f"""
1214
+ <div style="padding: 14px; display: flex; align-items: center; gap: 14px;">
1215
+ <div style="width: 40px; height: 40px; border-radius: 50%; background: {accent}; display: flex; align-items: center; justify-content: center; color: white; font-size: 20px;">๐Ÿ‘ค</div>
1216
+ <div style="flex: 1;"></div>
1217
+ <div style="position: relative; color: white; font-size: 22px;">
1218
+ ๐Ÿ””
1219
+ <div style="position: absolute; top: -4px; right: -4px; background: #FF3B30; border-radius: 50%; width: 16px; height: 16px; font-size: 9px; display: flex; align-items: center; justify-content: center; font-weight: 700;">3</div>
1220
+ </div>
1221
+ <div style="position: relative; color: white; font-size: 22px;">
1222
+ ๐Ÿ›’
1223
+ <div style="position: absolute; top: -4px; right: -4px; background: #FF3B30; border-radius: 50%; width: 16px; height: 16px; font-size: 9px; display: flex; align-items: center; justify-content: center; font-weight: 700;">2</div>
1224
+ </div>
1225
  </div>
1226
  """
1227
+ elif header_id == "profile_stats_share":
1228
  content = f"""
1229
  <div style="padding: 12px; display: flex; align-items: center; gap: 10px;">
1230
+ <div style="width: 50px; height: 50px; border-radius: 50%; background: white; display: flex; align-items: center; justify-content: center; font-size: 26px;">๐Ÿ‘ค</div>
1231
+ <div style="flex: 1; display: flex; gap: 12px; font-size: 11px; color: white;">
1232
+ <div style="text-align: center;">
1233
+ <div style="font-weight: 700; font-size: 15px;">245</div>
1234
+ <div style="opacity: 0.8;">Followers</div>
1235
+ </div>
1236
+ <div style="text-align: center;">
1237
+ <div style="font-weight: 700; font-size: 15px;">189</div>
1238
+ <div style="opacity: 0.8;">Following</div>
1239
+ </div>
1240
+ </div>
1241
+ <div style="color: white; font-size: 20px;">๐Ÿ“ค</div>
1242
+ </div>
1243
+ """
1244
+ elif header_id == "social_search_filter":
1245
+ content = f"""
1246
+ <div style="padding: 14px; display: flex; align-items: center; gap: 10px;">
1247
+ <div style="flex: 1; background: rgba(255,255,255,0.2); border-radius: 20px; padding: 10px 14px; font-size: 13px; color: rgba(255,255,255,0.9); display: flex; align-items: center; gap: 8px;">
1248
+ <span>๐Ÿ”</span>
1249
+ <span>Search posts...</span>
1250
+ </div>
1251
+ <div style="color: white; font-size: 22px;">โš™๏ธ</div>
1252
+ <div style="color: white; font-size: 22px;">๐ŸŽš๏ธ</div>
1253
+ </div>
1254
+ """
1255
+ elif header_id == "messenger_header":
1256
+ content = f"""
1257
+ <div style="padding: 14px; display: flex; align-items: center; gap: 12px;">
1258
+ <div style="color: white; font-size: 22px;">โ†</div>
1259
+ <div style="width: 40px; height: 40px; border-radius: 50%; background: white; display: flex; align-items: center; justify-content: center; font-size: 20px;">๐Ÿ‘ค</div>
1260
+ <div style="flex: 1; color: white;">
1261
+ <div style="font-weight: 700; font-size: 14px;">Sarah Johnson</div>
1262
+ <div style="opacity: 0.8; font-size: 11px;">Active now</div>
1263
+ </div>
1264
+ <div style="color: white; font-size: 22px;">๐Ÿ“ž</div>
1265
+ <div style="color: white; font-size: 22px;">๐Ÿ“น</div>
1266
+ </div>
1267
+ """
1268
+
1269
+ # LOCATION & DELIVERY (4)
1270
+ elif header_id == "location_picker":
1271
+ content = f"""
1272
+ <div style="padding: 14px; display: flex; align-items: center; gap: 10px;">
1273
+ <div style="color: white; font-size: 24px;">๐Ÿ“</div>
1274
+ <div style="flex: 1; color: white;">
1275
+ <div style="font-size: 11px; opacity: 0.8;">Deliver to</div>
1276
+ <div style="font-weight: 700; font-size: 14px;">1234 Market St, SF โ–ผ</div>
1277
+ </div>
1278
  <div style="color: white; font-size: 20px;">๐Ÿ””</div>
1279
  </div>
1280
  """
1281
+ elif header_id == "delivery_address_time":
1282
  content = f"""
1283
+ <div style="padding: 12px; color: white;">
1284
+ <div style="display: flex; align-items: center; gap: 8px; margin-bottom: 6px;">
1285
+ <span style="font-size: 16px;">๐Ÿ“</span>
1286
+ <span style="font-size: 13px; font-weight: 600;">1234 Market Street</span>
1287
+ <span style="margin-left: auto; font-size: 11px; background: rgba(255,255,255,0.2); padding: 4px 8px; border-radius: 12px;">Change</span>
1288
+ </div>
1289
+ <div style="font-size: 11px; opacity: 0.9; display: flex; align-items: center; gap: 6px;">
1290
+ <span>โฑ๏ธ</span>
1291
+ <span>Delivery in 25-30 mins</span>
1292
  </div>
1293
  </div>
1294
  """
1295
+ elif header_id == "map_search_location":
1296
  content = f"""
1297
+ <div style="padding: 14px;">
1298
+ <div style="background: rgba(255,255,255,0.95); border-radius: 24px; padding: 10px 14px; display: flex; align-items: center; gap: 10px;">
1299
+ <span style="font-size: 18px;">๐Ÿ“</span>
1300
+ <input style="border: none; background: transparent; flex: 1; font-size: 13px;" placeholder="Search location..."/>
1301
+ <span style="font-size: 18px; color: {primary};">๐ŸŽฏ</span>
1302
+ </div>
1303
  </div>
1304
  """
1305
+ elif header_id == "ride_pickup_header":
1306
  content = f"""
1307
+ <div style="padding: 12px; color: white; font-size: 12px;">
1308
+ <div style="display: flex; align-items: center; gap: 8px; margin-bottom: 8px;">
1309
+ <span style="font-size: 14px;">๐ŸŸข</span>
1310
+ <span style="font-weight: 600;">Home - 123 Main St</span>
1311
  </div>
1312
+ <div style="display: flex; align-items: center; gap: 8px;">
1313
+ <span style="font-size: 14px;">๐Ÿ”ด</span>
1314
+ <span style="font-weight: 600;">Office - 456 Market St</span>
1315
+ <span style="margin-left: auto; font-size: 18px;">๐Ÿ”„</span>
1316
  </div>
1317
+ </div>
1318
+ """
1319
+
1320
+ # E-COMMERCE (3)
1321
+ elif header_id == "shop_cart_wishlist":
1322
+ content = f"""
1323
+ <div style="padding: 14px; display: flex; align-items: center; gap: 14px;">
1324
+ <div style="color: white; font-size: 20px; font-weight: 700;">๐Ÿช ShopApp</div>
1325
+ <div style="flex: 1; background: rgba(255,255,255,0.2); border-radius: 20px; padding: 8px 12px;">
1326
+ <span style="color: rgba(255,255,255,0.9); font-size: 12px;">๐Ÿ” Search products...</span>
1327
+ </div>
1328
+ <div style="color: white; font-size: 20px;">โค๏ธ</div>
1329
+ <div style="position: relative; color: white; font-size: 20px;">
1330
+ ๐Ÿ›’
1331
+ <div style="position: absolute; top: -6px; right: -6px; background: #FF3B30; border-radius: 50%; width: 16px; height: 16px; font-size: 9px; display: flex; align-items: center; justify-content: center; font-weight: 700;">5</div>
1332
+ </div>
1333
+ </div>
1334
+ """
1335
+ elif header_id == "category_filter_sort":
1336
+ content = f"""
1337
+ <div style="padding: 14px;">
1338
+ <div style="display: flex; gap: 8px; align-items: center;">
1339
+ <div style="flex: 1; background: rgba(255,255,255,0.2); color: white; border-radius: 20px; padding: 8px 12px; font-size: 12px; font-weight: 600;">
1340
+ Electronics โ–ผ
1341
+ </div>
1342
+ <div style="background: rgba(255,255,255,0.2); color: white; border-radius: 20px; padding: 8px 12px; font-size: 12px;">
1343
+ ๐ŸŽš๏ธ Filter
1344
+ </div>
1345
+ <div style="background: rgba(255,255,255,0.2); color: white; border-radius: 20px; padding: 8px 12px; font-size: 12px;">
1346
+ โฌ Sort
1347
+ </div>
1348
+ </div>
1349
+ </div>
1350
+ """
1351
+ elif header_id == "product_search_scan":
1352
+ content = f"""
1353
+ <div style="padding: 14px;">
1354
+ <div style="background: rgba(255,255,255,0.95); border-radius: 24px; padding: 10px 14px; display: flex; align-items: center; gap: 10px;">
1355
+ <span style="font-size: 18px;">๐Ÿ”</span>
1356
+ <input style="border: none; background: transparent; flex: 1; font-size: 13px;" placeholder="Search products..."/>
1357
+ <span style="font-size: 18px; color: {primary};">๐Ÿ“ท</span>
1358
+ <span style="font-size: 18px; color: {primary};">๐ŸŽค</span>
1359
+ </div>
1360
+ </div>
1361
+ """
1362
+
1363
+ # FINANCE & WALLET (3)
1364
+ elif header_id == "wallet_balance_qr":
1365
+ content = f"""
1366
+ <div style="padding: 12px; display: flex; align-items: center; gap: 12px;">
1367
+ <div style="width: 44px; height: 44px; border-radius: 50%; background: white; display: flex; align-items: center; justify-content: center; font-size: 24px;">๐Ÿ‘ค</div>
1368
+ <div style="flex: 1; color: white;">
1369
+ <div style="font-size: 11px; opacity: 0.8;">Total Balance</div>
1370
+ <div style="font-weight: 700; font-size: 20px;">$2,458.50</div>
1371
+ </div>
1372
+ <div style="background: white; padding: 8px; border-radius: 8px; font-size: 20px;">๐Ÿ“ฑ</div>
1373
+ </div>
1374
+ """
1375
+ elif header_id == "banking_accounts_menu":
1376
+ content = f"""
1377
+ <div style="padding: 14px; color: white;">
1378
+ <div style="display: flex; align-items: center; gap: 10px; margin-bottom: 6px;">
1379
+ <div style="flex: 1; font-weight: 700; font-size: 13px;">Checking Account โ–ผ</div>
1380
+ <div style="font-size: 22px;">โ˜ฐ</div>
1381
+ </div>
1382
+ <div style="font-size: 20px; font-weight: 700;">$12,345.67</div>
1383
+ </div>
1384
+ """
1385
+ elif header_id == "crypto_portfolio_refresh":
1386
+ content = f"""
1387
+ <div style="padding: 14px; color: white;">
1388
+ <div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px;">
1389
+ <div style="font-size: 11px; opacity: 0.8;">Portfolio Value</div>
1390
+ <div style="font-size: 18px;">๐Ÿ”„</div>
1391
+ </div>
1392
+ <div style="display: flex; align-items: baseline; gap: 10px;">
1393
+ <div style="font-size: 22px; font-weight: 700;">$45,678</div>
1394
+ <div style="font-size: 13px; color: #34C759;">+2.45% โ†—</div>
1395
+ </div>
1396
+ </div>
1397
+ """
1398
+
1399
+ # HEALTH & FITNESS (2)
1400
+ elif header_id == "fitness_streak_profile":
1401
+ content = f"""
1402
+ <div style="padding: 12px; display: flex; align-items: center; gap: 12px;">
1403
+ <div style="width: 48px; height: 48px; border-radius: 50%; background: white; display: flex; align-items: center; justify-content: center; font-size: 26px;">๐Ÿ’ช</div>
1404
+ <div style="flex: 1; color: white;">
1405
+ <div style="font-weight: 700; font-size: 15px;">Sarah's Fitness</div>
1406
+ <div style="font-size: 11px; opacity: 0.9;">๐Ÿ”ฅ 7 day streak</div>
1407
+ </div>
1408
+ <div style="background: rgba(255,255,255,0.2); padding: 6px 10px; border-radius: 16px; font-size: 11px; color: white; font-weight: 600;">
1409
+ ๐Ÿ† Level 12
1410
+ </div>
1411
+ </div>
1412
+ """
1413
+ elif header_id == "workout_timer_pause":
1414
+ content = f"""
1415
+ <div style="padding: 14px; text-align: center; color: white;">
1416
+ <div style="font-size: 11px; opacity: 0.8; margin-bottom: 4px;">WORKOUT IN PROGRESS</div>
1417
+ <div style="display: flex; justify-content: center; align-items: center; gap: 16px;">
1418
+ <div style="font-size: 20px;">โญ๏ธ</div>
1419
+ <div style="font-size: 28px; font-weight: 700;">12:34</div>
1420
+ <div style="font-size: 24px;">โธ๏ธ</div>
1421
+ </div>
1422
+ </div>
1423
+ """
1424
+
1425
+ # MEDIA & ENTERTAINMENT (3)
1426
+ elif header_id == "video_player_controls":
1427
+ content = f"""
1428
+ <div style="padding: 14px; display: flex; align-items: center; gap: 12px;">
1429
+ <div style="color: white; font-size: 22px;">โ†</div>
1430
+ <div style="flex: 1; color: white;">
1431
+ <div style="font-weight: 600; font-size: 13px;">How to Code in Python</div>
1432
+ <div style="opacity: 0.8; font-size: 11px;">TechChannel โ€ข 1.2M views</div>
1433
+ </div>
1434
+ <div style="color: white; font-size: 20px;">๐Ÿ“ก</div>
1435
+ <div style="color: white; font-size: 20px;">โ‹ฎ</div>
1436
+ </div>
1437
+ """
1438
+ elif header_id == "music_player_header":
1439
+ content = f"""
1440
+ <div style="padding: 16px; display: flex; align-items: center; gap: 12px;">
1441
+ <div style="color: white; font-size: 22px;">โ†</div>
1442
+ <div style="flex: 1; color: white; text-align: center;">
1443
+ <div style="font-weight: 700; font-size: 15px;">Blinding Lights</div>
1444
+ <div style="opacity: 0.8; font-size: 12px;">The Weeknd</div>
1445
+ </div>
1446
+ <div style="color: white; font-size: 22px;">โค๏ธ</div>
1447
+ </div>
1448
+ """
1449
+ elif header_id == "news_category_tabs":
1450
+ content = f"""
1451
+ <div style="padding: 12px; color: white;">
1452
+ <div style="font-size: 18px; font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between;">
1453
+ <span>๐Ÿ“ฐ NewsApp</span>
1454
+ <span style="font-size: 20px;">๐Ÿ”–</span>
1455
+ </div>
1456
+ <div style="display: flex; gap: 14px; font-size: 12px; font-weight: 600;">
1457
+ <span style="border-bottom: 2px solid white; padding-bottom: 4px;">Top</span>
1458
+ <span style="opacity: 0.6;">Tech</span>
1459
+ <span style="opacity: 0.6;">Sports</span>
1460
+ <span style="opacity: 0.6;">World</span>
1461
  </div>
1462
  </div>
1463
  """
 
1682
 
1683
  def generate_header_gallery(theme_json: str = ""):
1684
  """
1685
+ Generate HTML gallery of all 20 realistic headers
1686
  Headers are rendered directly with HTML/CSS using theme colors
1687
  """
1688
  from agents.flutter_screen_generator import FlutterScreenGenerator
 
1711
  html_parts = []
1712
  html_parts.append("""
1713
  <div style="background: #f8f9fa; padding: 24px; border-radius: 12px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">
1714
+ <h3 style="margin-top: 0; color: #212529; font-size: 20px;">๐ŸŽฏ Header Catalog (20 Headers)</h3>
1715
  <p style="color: #6c757d; font-size: 14px; margin-bottom: 24px;">
1716
+ 20 header realistici con profilo, localizzazione, notifiche, cart e menu - renderizzati con i tuoi colori del tema
1717
  </p>
1718
  """)
1719
 
 
2307
 
2308
  # Header Gallery Section
2309
  gr.Markdown("---")
2310
+ with gr.Accordion("๐ŸŽฏ Header Catalog (20 Headers)", open=False):
2311
  gr.Markdown("""
2312
+ Tutti i 20 header realistici disponibili con preview renderizzate in HTML/CSS.
2313
+ Gli header includono profilo, localizzazione, notifiche, menu e altri elementi.
2314
  """)
2315
 
2316
  # Refresh button to update with new theme