76 lines
2.4 KiB
Dart
76 lines
2.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../../../../core/theme/app_theme.dart';
|
|
import '../../../../core/widgets/glass_container.dart';
|
|
|
|
class ServiceSettingsForm extends StatelessWidget {
|
|
final Map<String, TextEditingController> controllers;
|
|
final Color accentColor;
|
|
|
|
const ServiceSettingsForm({
|
|
super.key,
|
|
required this.controllers,
|
|
required this.accentColor,
|
|
});
|
|
|
|
Widget _buildField(String key, TextEditingController ctrl) {
|
|
final isBool = ctrl.text == 'true' || ctrl.text == 'false';
|
|
|
|
if (isBool) {
|
|
return StatefulBuilder(
|
|
builder: (ctx, setLocal) {
|
|
return SwitchListTile(
|
|
title: Text(key, style: const TextStyle(color: Colors.white, fontSize: 13, fontWeight: FontWeight.w600)),
|
|
subtitle: Text('Boolesche Konfigurationsflagge', style: TextStyle(color: AppTheme.textMuted, fontSize: 11)),
|
|
value: ctrl.text == 'true',
|
|
activeThumbColor: accentColor,
|
|
onChanged: (newVal) {
|
|
setLocal(() {
|
|
ctrl.text = newVal ? 'true' : 'false';
|
|
});
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
return Padding(
|
|
padding: const EdgeInsets.only(bottom: 12),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(key, style: const TextStyle(color: Colors.white, fontSize: 12, fontWeight: FontWeight.bold)),
|
|
const SizedBox(height: 6),
|
|
TextField(
|
|
controller: ctrl,
|
|
style: const TextStyle(color: Colors.white, fontSize: 13),
|
|
decoration: InputDecoration(
|
|
contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
|
border: OutlineInputBorder(borderRadius: BorderRadius.circular(10)),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (controllers.isEmpty) {
|
|
return GlassContainer(
|
|
padding: const EdgeInsets.all(20),
|
|
child: Center(
|
|
child: Text('Keine konfigurierbaren Parameter für diesen Dienst vorhanden.', style: TextStyle(color: AppTheme.textMuted)),
|
|
),
|
|
);
|
|
}
|
|
|
|
return GlassContainer(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: controllers.entries.map((e) => _buildField(e.key, e.value)).toList(),
|
|
),
|
|
);
|
|
}
|
|
}
|