|
| 1 | +import 'package:flutter/material.dart' as mat; |
| 2 | +import 'package:flutter/material.dart'; |
| 3 | +import 'package:GitSync/global.dart'; |
| 4 | +import '../../../constant/colors.dart'; |
| 5 | +import '../../../constant/dimens.dart'; |
| 6 | +import '../../../ui/dialog/base_alert_dialog.dart'; |
| 7 | + |
| 8 | +Future<void> showDialog(BuildContext context, String? oldRemoteUrl, Future<void> Function(String newRemoteUrl) callback) async { |
| 9 | + final newRemoteController = TextEditingController(text: oldRemoteUrl); |
| 10 | + |
| 11 | + // TODO: Dialog doesn't open without this (investigate) |
| 12 | + await Future.delayed(Duration(milliseconds: 500)); |
| 13 | + |
| 14 | + return await mat.showDialog( |
| 15 | + context: context, |
| 16 | + builder: (BuildContext context) => BaseAlertDialog( |
| 17 | + expandable: false, |
| 18 | + backgroundColor: secondaryDark, |
| 19 | + title: SizedBox( |
| 20 | + width: MediaQuery.of(context).size.width, |
| 21 | + child: Text( |
| 22 | + "Set Remote URL".toUpperCase(), |
| 23 | + style: TextStyle(color: primaryLight, fontSize: textXL, fontWeight: FontWeight.bold), |
| 24 | + ), |
| 25 | + ), |
| 26 | + content: SingleChildScrollView( |
| 27 | + child: ListBody( |
| 28 | + children: [ |
| 29 | + SizedBox(height: spaceMD), |
| 30 | + TextField( |
| 31 | + controller: newRemoteController, |
| 32 | + maxLines: 1, |
| 33 | + style: TextStyle( |
| 34 | + color: primaryLight, |
| 35 | + fontWeight: FontWeight.bold, |
| 36 | + decoration: TextDecoration.none, |
| 37 | + decorationThickness: 0, |
| 38 | + fontSize: textMD, |
| 39 | + ), |
| 40 | + decoration: InputDecoration( |
| 41 | + fillColor: tertiaryDark, |
| 42 | + filled: true, |
| 43 | + border: const OutlineInputBorder(borderRadius: BorderRadius.all(cornerRadiusSM), borderSide: BorderSide.none), |
| 44 | + isCollapsed: true, |
| 45 | + label: Text( |
| 46 | + t.fileName.toUpperCase(), |
| 47 | + style: TextStyle(color: secondaryLight, fontSize: textSM, fontWeight: FontWeight.bold), |
| 48 | + ), |
| 49 | + floatingLabelBehavior: FloatingLabelBehavior.always, |
| 50 | + contentPadding: const EdgeInsets.symmetric(horizontal: spaceMD, vertical: spaceSM), |
| 51 | + isDense: true, |
| 52 | + ), |
| 53 | + ), |
| 54 | + ], |
| 55 | + ), |
| 56 | + ), |
| 57 | + actions: <Widget>[ |
| 58 | + TextButton( |
| 59 | + child: Text( |
| 60 | + t.cancel.toUpperCase(), |
| 61 | + style: TextStyle(color: primaryLight, fontSize: textMD), |
| 62 | + ), |
| 63 | + onPressed: () { |
| 64 | + Navigator.of(context).canPop() ? Navigator.pop(context) : null; |
| 65 | + }, |
| 66 | + ), |
| 67 | + TextButton( |
| 68 | + child: Text( |
| 69 | + "Modify".toUpperCase(), |
| 70 | + style: TextStyle(color: primaryPositive, fontSize: textMD), |
| 71 | + ), |
| 72 | + onPressed: () async { |
| 73 | + callback(newRemoteController.text); |
| 74 | + Navigator.of(context).canPop() ? Navigator.pop(context) : null; |
| 75 | + }, |
| 76 | + ), |
| 77 | + ], |
| 78 | + ), |
| 79 | + ); |
| 80 | +} |
0 commit comments