Mobile. Share Screen. Split large ternary to smaller parts

This commit is contained in:
grummbeer 2023-03-06 15:27:22 +01:00
parent 1f8c64030d
commit 9c3334baf4

View File

@ -140,7 +140,9 @@ class _ServerPageState extends State<ServerPage> {
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
ServerInfo(), gFFI.serverModel.isStart
? ServerInfo()
: ServiceNotRunningNotification(),
const ConnectionManager(), const ConnectionManager(),
const PermissionChecker(), const PermissionChecker(),
SizedBox.fromSize(size: const Size(0, 15.0)), SizedBox.fromSize(size: const Size(0, 15.0)),
@ -161,6 +163,45 @@ void checkService() async {
} }
} }
class ServiceNotRunningNotification extends StatelessWidget {
ServiceNotRunningNotification({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final serverModel = Provider.of<ServerModel>(context);
return PaddingCard(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
const Icon(Icons.warning_amber_sharp,
color: Colors.redAccent, size: 24),
const SizedBox(width: 10),
Expanded(
child: Text(
translate("Service is not running"),
style: const TextStyle(
fontFamily: 'WorkSans',
fontWeight: FontWeight.bold,
fontSize: 18,
),
))
],
).marginOnly(bottom: 8),
Text(translate("android_start_service_tip"),
style: const TextStyle(fontSize: 12, color: MyTheme.darkGray))
.marginOnly(bottom: 8),
ElevatedButton.icon(
icon: const Icon(Icons.play_arrow),
onPressed: serverModel.toggleService,
label: Text(translate("Start Service")))
],
));
}
}
class ServerInfo extends StatelessWidget { class ServerInfo extends StatelessWidget {
final model = gFFI.serverModel; final model = gFFI.serverModel;
final emptyController = TextEditingController(text: "-"); final emptyController = TextEditingController(text: "-");
@ -199,75 +240,41 @@ class ServerInfo extends StatelessWidget {
} }
} }
return model.isStart return PaddingCard(
? PaddingCard( child: Column(
child: Column( mainAxisSize: MainAxisSize.min,
mainAxisSize: MainAxisSize.min, children: [
children: [ TextFormField(
TextFormField( readOnly: true,
readOnly: true, style: const TextStyle(fontSize: 25.0, fontWeight: FontWeight.bold),
style: const TextStyle( controller: model.serverId,
fontSize: 25.0, fontWeight: FontWeight.bold), decoration: InputDecoration(
controller: model.serverId, icon: const Icon(Icons.perm_identity),
decoration: InputDecoration( labelText: translate("ID"),
icon: const Icon(Icons.perm_identity), labelStyle: const TextStyle(fontWeight: FontWeight.bold),
labelText: translate("ID"), ),
labelStyle: const TextStyle(fontWeight: FontWeight.bold), onSaved: (String? value) {},
), ),
onSaved: (String? value) {}, TextFormField(
readOnly: true,
style: const TextStyle(fontSize: 25.0, fontWeight: FontWeight.bold),
controller: isPermanent ? emptyController : model.serverPasswd,
decoration: InputDecoration(
icon: const Icon(Icons.lock),
labelText: translate("Password"),
labelStyle: const TextStyle(
fontWeight: FontWeight.bold,
), ),
TextFormField( suffix: isPermanent
readOnly: true, ? null
style: const TextStyle( : IconButton(
fontSize: 25.0, fontWeight: FontWeight.bold), icon: const Icon(Icons.refresh),
controller: isPermanent ? emptyController : model.serverPasswd, onPressed: () => bind.mainUpdateTemporaryPassword())),
decoration: InputDecoration( onSaved: (String? value) {},
icon: const Icon(Icons.lock), ),
labelText: translate("Password"), Notification().marginOnly(top: 20)
labelStyle: const TextStyle( ],
fontWeight: FontWeight.bold, ));
),
suffix: isPermanent
? null
: IconButton(
icon: const Icon(Icons.refresh),
onPressed: () =>
bind.mainUpdateTemporaryPassword())),
onSaved: (String? value) {},
),
Notification().marginOnly(top: 20)
],
))
: PaddingCard(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
const Icon(Icons.warning_amber_sharp,
color: Colors.redAccent, size: 24),
const SizedBox(width: 10),
Expanded(
child: Text(
translate("Service is not running"),
style: const TextStyle(
fontFamily: 'WorkSans',
fontWeight: FontWeight.bold,
fontSize: 18,
),
))
],
).marginOnly(bottom: 8),
Text(translate("android_start_service_tip"),
style: const TextStyle(
fontSize: 12, color: MyTheme.darkGray))
.marginOnly(bottom: 8),
ElevatedButton.icon(
icon: const Icon(Icons.play_arrow),
onPressed: serverModel.toggleService,
label: Text(translate("Start Service")))
],
));
} }
} }