Skip to content
Snippets Groups Projects
Commit 7d86c58b authored by vjrj's avatar vjrj
Browse files

Fix floating buttons in mini cards

parent edd709e0
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,7 @@ class _ImportClipboardDialogState extends State<ImportClipboardDialog> {
children: <Widget>[
TextField(
controller: _textController,
maxLines: 3,
maxLines: 4,
decoration: InputDecoration(
hintText: tr('import_wallet_from_clipboard_desc')),
),
......
......@@ -23,9 +23,6 @@ class _CardNameEditableState extends State<CardNameEditable> {
final TextEditingController _controller = TextEditingController();
late String currentText;
final String pubKey = SharedPreferencesHelper().getPubKey();
final bool isG1nkgoCard = SharedPreferencesHelper().isG1nkgoCard();
String _previousValue = '';
bool _isSubmitting = false;
......@@ -33,18 +30,16 @@ class _CardNameEditableState extends State<CardNameEditable> {
void initState() {
final String localUsername = SharedPreferencesHelper().getName();
currentText = localUsername.isEmpty ? widget.defValue : localUsername;
initialValue = _initValue();
super.initState();
}
late Future<String> initialValue;
Future<String> _initValue() async {
final String localUsername = SharedPreferencesHelper().getName();
final bool isConnected = await ConnectivityWidgetWrapperWrapper.isConnected;
if (isConnected) {
try {
String? name = await getCesiumPlusUser(pubKey);
String? name =
await getCesiumPlusUser(SharedPreferencesHelper().getPubKey());
logger(
'currentText: $currentText, localUsername: $localUsername, _previousValue: $_previousValue, retrieved_name: $name');
if (localUsername != name) {
......@@ -52,11 +47,11 @@ class _CardNameEditableState extends State<CardNameEditable> {
name = name.replaceAll(userNameSuffix, '');
_controller.text = name;
currentText = name;
SharedPreferencesHelper().setName(name: name);
// SharedPreferencesHelper().setName(name: name);
} else {
_controller.text = '';
currentText = widget.defValue;
SharedPreferencesHelper().setName(name: '');
// SharedPreferencesHelper().setName(name: '');
}
}
} catch (e) {
......@@ -89,84 +84,84 @@ class _CardNameEditableState extends State<CardNameEditable> {
return Consumer<SharedPreferencesHelper>(builder: (BuildContext context,
SharedPreferencesHelper prefsHelper, Widget? child) {
return FutureBuilder<String>(
future: initialValue,
future: _initValue(),
builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
const Color black = Colors.black87;
return _isEditingText
? SizedBox(
width: 150.0,
child: SizedBox(
height: 40.0,
child: TextField(
// focusNode: myFocusNode,
style: const TextStyle(color: black),
decoration: InputDecoration(
contentPadding: const EdgeInsets.symmetric(
vertical: 5.0, horizontal: 7.0),
filled: true,
fillColor: Colors.white,
enabledBorder: const OutlineInputBorder(
borderSide: BorderSide(color: Colors.grey),
),
focusedBorder: const OutlineInputBorder(
borderSide: BorderSide(width: 2.0),
),
suffix: const Text('$userNameSuffix '),
suffixIcon: _isSubmitting
? const RefreshProgressIndicator()
: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
GestureDetector(
onTap: () {
setState(() {
_isEditingText = false;
});
},
child: const Padding(
padding: EdgeInsets.only(right: 8.0),
child: Icon(Icons.cancel_outlined,
color: black),
),
width: 150.0,
child: SizedBox(
height: 40.0,
child: TextField(
// focusNode: myFocusNode,
style: const TextStyle(color: black),
decoration: InputDecoration(
contentPadding: const EdgeInsets.symmetric(
vertical: 5.0, horizontal: 7.0),
filled: true,
fillColor: Colors.white,
enabledBorder: const OutlineInputBorder(
borderSide: BorderSide(color: Colors.grey),
),
GestureDetector(
onTap: () {
_updateValue(_controller.text);
},
child: const Padding(
padding: EdgeInsets.only(right: 8.0),
child: Icon(Icons.check, color: black),
),
focusedBorder: const OutlineInputBorder(
borderSide: BorderSide(width: 2.0),
),
],
),
),
cursorColor: black,
onSubmitted: _updateValue,
enabled: !_isSubmitting,
/* onChanged: (String value) {
suffix: const Text('$userNameSuffix '),
suffixIcon: _isSubmitting
? const RefreshProgressIndicator()
: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
GestureDetector(
onTap: () {
setState(() {
_isEditingText = false;
});
},
child: const Padding(
padding: EdgeInsets.only(right: 8.0),
child: Icon(Icons.cancel_outlined,
color: black),
),
),
GestureDetector(
onTap: () {
_updateValue(_controller.text);
},
child: const Padding(
padding: EdgeInsets.only(right: 8.0),
child:
Icon(Icons.check, color: black),
),
),
],
),
),
cursorColor: black,
onSubmitted: _updateValue,
enabled: !_isSubmitting,
/* onChanged: (String value) {
if (value.isEmpty) {
_deleteValue();
}
}, */
/*onSubmitted: (String newValue) {
/*onSubmitted: (String newValue) {
updateName(newValue);
}, */
// maxLength: 15,
autofocus: true,
controller: _controller,
)))
// maxLength: 15,
autofocus: true,
controller: _controller,
)))
: Tooltip(
message: widget.defValue,
child: CardNameText(
currentText: currentText,
isGinkgoCard: isG1nkgoCard,
onTap: () =>
isG1nkgoCard
? setState(() {
_isEditingText = true;
})
: null));
message: widget.defValue,
child: CardNameText(
currentText: currentText,
isGinkgoCard: SharedPreferencesHelper().isG1nkgoCard(),
onTap: () => SharedPreferencesHelper().isG1nkgoCard()
? setState(() {
_isEditingText = true;
})
: null));
});
});
}
......@@ -190,7 +185,7 @@ class _CardNameEditableState extends State<CardNameEditable> {
setState(() {
_controller.text = _previousValue;
currentText =
_previousValue.isEmpty ? widget.defValue : _previousValue;
_previousValue.isEmpty ? widget.defValue : _previousValue;
});
}
} catch (e) {
......@@ -241,10 +236,11 @@ class _CardNameEditableState extends State<CardNameEditable> {
}
class CardNameText extends StatelessWidget {
const CardNameText({super.key,
required this.currentText,
required this.onTap,
required this.isGinkgoCard});
const CardNameText(
{super.key,
required this.currentText,
required this.onTap,
required this.isGinkgoCard});
final String currentText;
final bool isGinkgoCard;
......@@ -262,9 +258,7 @@ class CardNameText extends StatelessWidget {
maxLines: 2,
overflow: TextOverflow.ellipsis,
text: TextSpan(
style: DefaultTextStyle
.of(context)
.style,
style: DefaultTextStyle.of(context).style,
children: <TextSpan>[
if (currentText == defValue)
TextSpan(
......
......@@ -45,120 +45,124 @@ class CreditCardMini extends StatelessWidget {
final double cardInternalElPadding = bigDevice ? 5 : 6.0;
return Padding(
padding: const EdgeInsets.all(10),
child: GestureDetector(
onTap: () => onCardTap(context),
child: Card(
elevation: 8.0,
shape: RoundedRectangleBorder(
child: settingsVisible
? _buildCard(cardRadius, context, cardInternalElPadding, bigDevice)
: GestureDetector(
onTap: () => onCardTap(context),
child: _buildCard(
cardRadius, context, cardInternalElPadding, bigDevice)));
}
Card _buildCard(double cardRadius, BuildContext context,
double cardInternalElPadding, bool bigDevice) {
return Card(
elevation: 8.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(cardRadius),
),
child: AspectRatio(
aspectRatio: cardAspectRatio,
// Credit cart aspect ratio
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(cardRadius),
boxShadow: <BoxShadow>[
BoxShadow(
color: Colors.grey[400]!,
blurRadius: 3.0,
spreadRadius: 1.0,
)
],
gradient: LinearGradient(
begin: Alignment.bottomLeft,
end: Alignment.topRight,
colors: <Color>[
card.theme.primaryColor,
card.theme.secondaryColor
],
),
),
child: AspectRatio(
aspectRatio: cardAspectRatio, // Credit cart aspect ratio
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(cardRadius),
boxShadow: <BoxShadow>[
BoxShadow(
color: Colors.grey[400]!,
blurRadius: 3.0,
spreadRadius: 1.0,
)
],
gradient: LinearGradient(
begin: Alignment.bottomLeft,
end: Alignment.topRight,
colors: <Color>[
card.theme.primaryColor,
card.theme.secondaryColor
],
child: Padding(
padding: const EdgeInsets.all(10),
child: Stack(children: <Widget>[
if (inDevelopment)
if (!SharedPreferencesHelper().isG1nkgoCard())
Positioned(
top: 60,
right: 0,
child: Visibility(
visible: settingsVisible,
child: FloatingActionButton(
backgroundColor: Colors.transparent,
elevation: 1,
onPressed: () {
SharedPreferencesHelper()
.selectCurrentWalletIndex(0);
SharedPreferencesHelper()
.removeCesiumCard(cardIndex);
Navigator.pop(context);
},
child:
const Icon(Icons.delete, color: Colors.white),
),
),
),
child: Padding(
padding: const EdgeInsets.all(10),
child: Stack(children: <Widget>[
if (inDevelopment)
if (!SharedPreferencesHelper().isG1nkgoCard())
Positioned(
top: 30,
right: -10,
child: Visibility(
visible: settingsVisible,
child: FloatingActionButton(
backgroundColor: Colors.transparent,
elevation: 0,
onPressed: () {
SharedPreferencesHelper()
.selectCurrentWalletIndex(0);
SharedPreferencesHelper()
.removeCesiumCard(cardIndex);
Navigator.pop(context);
},
child: const Icon(Icons.delete,
color: Colors.white),
),
),
),
Positioned(
top: -10,
right: -10,
child: Visibility(
visible: settingsVisible,
child: FloatingActionButton(
backgroundColor: Colors.transparent,
elevation: 0,
onPressed: () => _showThemeSelector(context),
child: const Icon(Icons.settings,
color: Colors.white),
),
),
),
Positioned(
top: 0,
right: 0,
child: Visibility(
visible: settingsVisible,
child: FloatingActionButton(
backgroundColor: Colors.transparent,
elevation: 1,
onPressed: () => _showThemeSelector(context),
child:
const Icon(Icons.settings, color: Colors.white),
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(120, 10, 0, 0),
child: Opacity(
opacity: 0.2,
child: Image.asset('assets/img/gbrevedot_alt.png',
width: 100, height: 100),
)),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
if (card.name.isNotEmpty)
Padding(
padding:
const EdgeInsets.fromLTRB(120, 10, 0, 0),
child: Opacity(
opacity: 0.2,
child: Image.asset(
'assets/img/gbrevedot_alt.png',
width: 100,
height: 100),
)),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
if (card.name.isNotEmpty)
Padding(
padding: EdgeInsets.symmetric(
horizontal: cardInternalElPadding,
vertical: cardInternalElPadding),
child: Row(children: <Widget>[
Expanded(
child: CardNameText(
currentText: card.name,
onTap: null,
isGinkgoCard:
SharedPreferencesHelper()
.isG1nkgoCard(card)),
),
])),
Padding(
padding: EdgeInsets.symmetric(
horizontal: cardInternalElPadding,
vertical: cardInternalElPadding),
child: Row(children: <Widget>[
FittedBox(
fit: BoxFit.scaleDown,
child: Text(
'${card.pubKey.substring(0, 4)} ${card.pubKey.substring(4, 8)}',
style: cardTextStyle(context,
fontSize: 16),
)),
])),
if (bigDevice) const SizedBox(height: 6.0),
const SizedBox(height: 8.0),
]),
]),
))))));
padding: EdgeInsets.symmetric(
horizontal: cardInternalElPadding,
vertical: cardInternalElPadding),
child: Row(children: <Widget>[
Expanded(
child: CardNameText(
currentText: card.name,
onTap: null,
isGinkgoCard: SharedPreferencesHelper()
.isG1nkgoCard(card)),
),
])),
Padding(
padding: EdgeInsets.symmetric(
horizontal: cardInternalElPadding,
vertical: cardInternalElPadding),
child: Row(children: <Widget>[
FittedBox(
fit: BoxFit.scaleDown,
child: Text(
'${card.pubKey.substring(0, 4)} ${card.pubKey.substring(4, 8)}',
style:
cardTextStyle(context, fontSize: 16),
)),
])),
if (bigDevice) const SizedBox(height: 6.0),
const SizedBox(height: 8.0),
]),
]),
))));
}
void onCardTap(BuildContext context) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment