2020-07-27 20:43:58 +00:00
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:mobile_nebula/components/SpecialButton.dart';
|
|
|
|
import 'package:mobile_nebula/services/utils.dart';
|
|
|
|
|
|
|
|
class ConfigPageItem extends StatelessWidget {
|
|
|
|
const ConfigPageItem(
|
2022-09-21 20:27:35 +00:00
|
|
|
{Key? key,
|
2020-07-27 20:43:58 +00:00
|
|
|
this.label,
|
|
|
|
this.content,
|
|
|
|
this.labelWidth = 100,
|
|
|
|
this.onPressed,
|
|
|
|
this.crossAxisAlignment = CrossAxisAlignment.center})
|
|
|
|
: super(key: key);
|
|
|
|
|
2022-09-21 20:27:35 +00:00
|
|
|
final Widget? label;
|
|
|
|
final Widget? content;
|
2020-07-27 20:43:58 +00:00
|
|
|
final double labelWidth;
|
|
|
|
final CrossAxisAlignment crossAxisAlignment;
|
|
|
|
final onPressed;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
var theme;
|
|
|
|
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
final origTheme = Theme.of(context);
|
|
|
|
theme = origTheme.copyWith(
|
2022-09-21 20:27:35 +00:00
|
|
|
textTheme: origTheme.textTheme
|
|
|
|
.copyWith(button: origTheme.textTheme.button!.copyWith(fontWeight: FontWeight.normal)));
|
2020-07-27 20:43:58 +00:00
|
|
|
return Theme(data: theme, child: _buildContent(context));
|
|
|
|
} else {
|
|
|
|
final origTheme = CupertinoTheme.of(context);
|
|
|
|
theme = origTheme.copyWith(primaryColor: CupertinoColors.label.resolveFrom(context));
|
|
|
|
return CupertinoTheme(data: theme, child: _buildContent(context));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildContent(BuildContext context) {
|
|
|
|
return SpecialButton(
|
|
|
|
onPressed: onPressed,
|
|
|
|
color: Utils.configItemBackground(context),
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.only(left: 15),
|
|
|
|
constraints: BoxConstraints(minHeight: Utils.minInteractiveSize, minWidth: double.infinity),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: crossAxisAlignment,
|
|
|
|
children: <Widget>[
|
|
|
|
label != null ? Container(width: labelWidth, child: label) : Container(),
|
|
|
|
Expanded(child: Container(child: content, padding: EdgeInsets.only(right: 10))),
|
|
|
|
Icon(CupertinoIcons.forward, color: CupertinoColors.placeholderText.resolveFrom(context), size: 18)
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|