mobile_nebula/lib/components/config/ConfigPageItem.dart
Ian VanSchooten 64d45f66c7
Update Flutter, target android SDK 34 (#160)
This updates flutter to 3.24.1, the latest stable version, and also updates our flutter dependencies to latest.

It targets the latest android sdk, 34, which is required if we want to publish a new version to the Google Play store.

I also needed to make a few adjustments to handle deprecations. The biggest change is that I needed to wrap the main widget in MaterialApp to avoid problems with AdaptiveSwitch in iOS.
2024-09-20 14:19:23 -04:00

62 lines
2.1 KiB
Dart

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(
{Key? key,
this.label,
this.content,
this.labelWidth = 100,
this.onPressed,
this.disabled = false,
this.crossAxisAlignment = CrossAxisAlignment.center})
: super(key: key);
final Widget? label;
final Widget? content;
final double labelWidth;
final CrossAxisAlignment crossAxisAlignment;
final onPressed;
final bool disabled;
@override
Widget build(BuildContext context) {
var theme;
if (Platform.isAndroid) {
final origTheme = Theme.of(context);
theme = origTheme.copyWith(
textTheme: origTheme.textTheme
.copyWith(labelLarge: origTheme.textTheme.labelLarge!.copyWith(fontWeight: FontWeight.normal)));
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: this.disabled ? null : 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))),
this.disabled
? Container()
: Icon(CupertinoIcons.forward, color: CupertinoColors.placeholderText.resolveFrom(context), size: 18)
],
)),
);
}
}