replace offstage with if-else for LinearProgressIndicator in dialog

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages 2023-08-18 16:13:24 +08:00
parent a7163c6a04
commit 979203cbdb
7 changed files with 59 additions and 55 deletions

View File

@ -46,6 +46,7 @@ class _AddressBookState extends State<AddressBook> {
} }
return Column( return Column(
children: [ children: [
// NOT use Offstage to wrap LinearProgressIndicator
if (gFFI.abModel.retrying.value) LinearProgressIndicator(), if (gFFI.abModel.retrying.value) LinearProgressIndicator(),
_buildErrorBanner( _buildErrorBanner(
err: gFFI.abModel.pullError, err: gFFI.abModel.pullError,
@ -397,8 +398,8 @@ class _AddressBookState extends State<AddressBook> {
const SizedBox( const SizedBox(
height: 4.0, height: 4.0,
), ),
Offstage( // NOT use Offstage to wrap LinearProgressIndicator
offstage: !isInProgress, child: const LinearProgressIndicator()) if (isInProgress) const LinearProgressIndicator(),
], ],
), ),
actions: [ actions: [
@ -463,8 +464,8 @@ class _AddressBookState extends State<AddressBook> {
const SizedBox( const SizedBox(
height: 4.0, height: 4.0,
), ),
Offstage( // NOT use Offstage to wrap LinearProgressIndicator
offstage: !isInProgress, child: const LinearProgressIndicator()) if (isInProgress) const LinearProgressIndicator(),
], ],
), ),
actions: [ actions: [

View File

@ -156,8 +156,8 @@ void changeIdDialog() {
}).toList(), }).toList(),
)).marginOnly(bottom: 8) )).marginOnly(bottom: 8)
: SizedBox.shrink(), : SizedBox.shrink(),
Offstage( // NOT use Offstage to wrap LinearProgressIndicator
offstage: !isInProgress, child: const LinearProgressIndicator()) if (isInProgress) const LinearProgressIndicator(),
], ],
), ),
actions: [ actions: [
@ -202,8 +202,8 @@ void changeWhiteList({Function()? callback}) async {
const SizedBox( const SizedBox(
height: 4.0, height: 4.0,
), ),
Offstage( // NOT use Offstage to wrap LinearProgressIndicator
offstage: !isInProgress, child: const LinearProgressIndicator()) if (isInProgress) const LinearProgressIndicator(),
], ],
), ),
actions: [ actions: [
@ -1435,8 +1435,8 @@ void editAbTagDialog(
.toList(growable: false), .toList(growable: false),
), ),
), ),
Offstage( // NOT use Offstage to wrap LinearProgressIndicator
offstage: !isInProgress, child: const LinearProgressIndicator()) if (isInProgress) const LinearProgressIndicator(),
], ],
), ),
actions: [ actions: [
@ -1496,9 +1496,9 @@ void renameDialog(
), ),
), ),
), ),
Obx(() => Offstage( // NOT use Offstage to wrap LinearProgressIndicator
offstage: isInProgress.isFalse, Obx(() =>
child: const LinearProgressIndicator())), isInProgress.value ? const LinearProgressIndicator() : Offstage())
], ],
), ),
actions: [ actions: [

View File

@ -12,7 +12,15 @@ import 'package:url_launcher/url_launcher.dart';
import '../../common.dart'; import '../../common.dart';
import './dialog.dart'; import './dialog.dart';
const kOpSvgList = ['github', 'google', 'apple', 'okta', 'facebook', 'azure', 'auth0']; const kOpSvgList = [
'github',
'google',
'apple',
'okta',
'facebook',
'azure',
'auth0'
];
class _IconOP extends StatelessWidget { class _IconOP extends StatelessWidget {
final String op; final String op;
@ -27,7 +35,8 @@ class _IconOP extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final svgFile = kOpSvgList.contains(op.toLowerCase()) ? op.toLowerCase() : 'default'; final svgFile =
kOpSvgList.contains(op.toLowerCase()) ? op.toLowerCase() : 'default';
return Container( return Container(
margin: margin, margin: margin,
child: icon == null child: icon == null
@ -345,9 +354,8 @@ class LoginWidgetUserPass extends StatelessWidget {
autoFocus: false, autoFocus: false,
errorText: passMsg, errorText: passMsg,
), ),
Offstage( // NOT use Offstage to wrap LinearProgressIndicator
offstage: !isInProgress, if (isInProgress) const LinearProgressIndicator(),
child: const LinearProgressIndicator()),
const SizedBox(height: 12.0), const SizedBox(height: 12.0),
FittedBox( FittedBox(
child: child:
@ -664,9 +672,8 @@ Future<bool?> verificationCodeDialog(UserPayload? user) async {
}, },
), ),
*/ */
Offstage( // NOT use Offstage to wrap LinearProgressIndicator
offstage: !isInProgress, if (isInProgress) const LinearProgressIndicator(),
child: const LinearProgressIndicator()),
], ],
), ),
onCancel: close, onCancel: close,

View File

@ -208,28 +208,26 @@ class _PeerTabPageState extends State<PeerTabPage>
} }
Widget _createRefresh() { Widget _createRefresh() {
if (gFFI.peerTabModel.currentTab < 3) return Offstage();
final textColor = Theme.of(context).textTheme.titleLarge?.color; final textColor = Theme.of(context).textTheme.titleLarge?.color;
return Offstage( return Container(
offstage: gFFI.peerTabModel.currentTab < 3, // local tab can't see effect padding: EdgeInsets.all(4.0),
child: Container( child: AnimatedRotationWidget(
padding: EdgeInsets.all(4.0), onPressed: () {
child: AnimatedRotationWidget( if (gFFI.peerTabModel.currentTab < entries.length) {
onPressed: () { entries[gFFI.peerTabModel.currentTab].load();
if (gFFI.peerTabModel.currentTab < entries.length) { }
entries[gFFI.peerTabModel.currentTab].load(); },
} spinning: gFFI.abModel.abLoading,
}, child: RotatedBox(
spinning: gFFI.abModel.abLoading, quarterTurns: 2,
child: RotatedBox( child: Tooltip(
quarterTurns: 2, message: translate('Refresh'),
child: Tooltip( child: Icon(
message: translate('Refresh'), Icons.refresh,
child: Icon( size: 18,
Icons.refresh, color: textColor,
size: 18, )))),
color: textColor,
)))),
),
); );
} }

View File

@ -2065,9 +2065,9 @@ void changeSocks5Proxy() async {
), ),
], ],
), ),
Offstage( // NOT use Offstage to wrap LinearProgressIndicator
offstage: !isInProgress, if (isInProgress)
child: const LinearProgressIndicator().marginOnly(top: 8)) const LinearProgressIndicator().marginOnly(top: 8),
], ],
), ),
), ),

View File

@ -182,8 +182,8 @@ class _InstallPageBodyState extends State<_InstallPageBody>
.marginOnly(bottom: em), .marginOnly(bottom: em),
InkWell( InkWell(
hoverColor: Colors.transparent, hoverColor: Colors.transparent,
onTap: () => onTap: () => launchUrlString(
launchUrlString('https://rustdesk.com/privacy.html'), 'https://rustdesk.com/privacy.html'),
child: Tooltip( child: Tooltip(
message: 'https://rustdesk.com/privacy.html', message: 'https://rustdesk.com/privacy.html',
child: Row(children: [ child: Row(children: [
@ -204,11 +204,10 @@ class _InstallPageBodyState extends State<_InstallPageBody>
Row( Row(
children: [ children: [
Expanded( Expanded(
child: Obx(() => Offstage( // NOT use Offstage to wrap LinearProgressIndicator
offstage: !showProgress.value, child: Obx(() => showProgress.value
child: ? LinearProgressIndicator().marginOnly(right: 10)
LinearProgressIndicator().marginOnly(right: 10), : Offstage()),
)),
), ),
Obx( Obx(
() => OutlinedButton.icon( () => OutlinedButton.icon(

View File

@ -223,9 +223,8 @@ void showServerSettingsWithValue(
labelText: 'Key', labelText: 'Key',
), ),
), ),
Offstage( // NOT use Offstage to wrap LinearProgressIndicator
offstage: !isInProgress, if (isInProgress) const LinearProgressIndicator(),
child: LinearProgressIndicator())
])), ])),
actions: [ actions: [
dialogButton('Cancel', onPressed: () { dialogButton('Cancel', onPressed: () {