47 lines
2.0 KiB
Python
47 lines
2.0 KiB
Python
import os
|
|
import re
|
|
|
|
widgets_dir = "packages/tactical_app/lib/widgets"
|
|
sheets = [
|
|
"tactical_route_planner_sheet.dart",
|
|
"tactical_los_sheet.dart",
|
|
"tactical_viewshed_sheet.dart",
|
|
"tactical_artillery_sheet.dart",
|
|
"tactical_hlz_sheet.dart",
|
|
"tactical_minefield_sheet.dart",
|
|
"tactical_isochrone_sheet.dart",
|
|
"tactical_symbols_sheet.dart",
|
|
"tactical_overlays_sheet.dart"
|
|
]
|
|
|
|
for sheet in sheets:
|
|
path = os.path.join(widgets_dir, sheet)
|
|
if not os.path.exists(path): continue
|
|
|
|
with open(path, "r") as f:
|
|
content = f.read()
|
|
|
|
# 1. Remove the outer Container decoration
|
|
content = re.sub(r'decoration:\s*const\s*BoxDecoration\([^)]+\),', '', content, flags=re.DOTALL)
|
|
content = re.sub(r'decoration:\s*BoxDecoration\([^)]+\),', '', content, flags=re.DOTALL)
|
|
|
|
# 2. Remove the header Row (starts with Row( mainAxisAlignment: MainAxisAlignment.spaceBetween ... )
|
|
# This regex is a bit tricky, but we know the header usually has "mainAxisAlignment: MainAxisAlignment.spaceBetween,"
|
|
# and ends with an IconButton for closing.
|
|
header_pattern = r'Row\(\s*mainAxisAlignment:\s*MainAxisAlignment\.spaceBetween,\s*children:\s*\[.*?IconButton\(\s*icon.*?onPressed:.*?widget\.onClose,?\s*\),?\s*\],\s*\),?'
|
|
content = re.sub(header_pattern, '', content, flags=re.DOTALL)
|
|
|
|
# 3. Some sheets might have `const Row(` for the header.
|
|
header_pattern_const = r'const\s*Row\(\s*mainAxisAlignment:\s*MainAxisAlignment\.spaceBetween,\s*children:\s*\[.*?IconButton\(\s*icon.*?onPressed:.*?widget\.onClose,?\s*\),?\s*\],\s*\),?'
|
|
content = re.sub(header_pattern_const, '', content, flags=re.DOTALL)
|
|
|
|
# 4. Remove padding from the outer container
|
|
content = re.sub(r'padding:\s*const\s*EdgeInsets\.only\([^)]+\),', 'padding: const EdgeInsets.all(16),', content, flags=re.DOTALL)
|
|
content = re.sub(r'padding:\s*const\s*EdgeInsets\.symmetric\([^)]+\),', 'padding: const EdgeInsets.all(16),', content, flags=re.DOTALL)
|
|
|
|
with open(path, "w") as f:
|
|
f.write(content)
|
|
|
|
print(f"Patched {sheet}")
|
|
|