<!-- Thanks for contributing! Provide a description of your changes below and a general summary in the title Please look at the following checklist to ensure that your PR can be accepted quickly: --> ## Description This is a PR that makes the auth build runnable on the Desktop platform. Below is a screenshot for the same:  Some things to note: - LocalAuth will be bypassed on unsupported platforms (desktop) - Switched to sodium and sodium-libs from flutter_sodium. - QR code library is incompatible with desktop, So I removed access to those pages. - Bumped some dependencies and done some lint fixes - Also add save key option as send file may not help on desktop (related #380) https://github.com/ente-io/auth/assets/41370460/3f3471e8-45f6-4146-88ac-b763d4f38b32 - Update Recovery Key Card UI  So this is a step towards more updated code and better multiplatform support. ## Type of Change <!--- Put an `x` in all the boxes that apply: --> - [ ] 🖼️ New icon - [x] ✨ New feature (non-breaking change which adds functionality) - [ ] 🛠️ Bug fix (non-breaking change which fixes an issue) - [ ] ❌ Breaking change (fix or feature that would cause existing functionality to change) - [x] 🧹 Code refactor - [ ] ✅ Build configuration change - [ ] 📝 Documentation - [ ] 🗑️ Chore --------- Co-authored-by: Neeraj Gupta <254676+ua741@users.noreply.github.com>
87 lines
2.1 KiB
Dart
87 lines
2.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class GradientButton extends StatelessWidget {
|
|
final List<Color> linearGradientColors;
|
|
final Function? onTap;
|
|
|
|
// text is ignored if child is specified
|
|
final String text;
|
|
|
|
// nullable
|
|
final IconData? iconData;
|
|
|
|
// padding between the text and icon
|
|
final double paddingValue;
|
|
|
|
// used when two icons are in row
|
|
final bool reversedGradient;
|
|
|
|
const GradientButton({
|
|
super.key,
|
|
this.linearGradientColors = const [
|
|
Color.fromARGB(255, 133, 44, 210),
|
|
Color.fromARGB(255, 187, 26, 93),
|
|
],
|
|
this.reversedGradient = false,
|
|
this.onTap,
|
|
this.text = '',
|
|
this.iconData,
|
|
this.paddingValue = 0.0,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Widget buttonContent;
|
|
if (iconData == null) {
|
|
buttonContent = Text(
|
|
text,
|
|
style: const TextStyle(
|
|
color: Colors.white,
|
|
fontWeight: FontWeight.w600,
|
|
fontFamily: 'Inter-SemiBold',
|
|
fontSize: 18,
|
|
),
|
|
);
|
|
} else {
|
|
buttonContent = Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Icon(
|
|
iconData,
|
|
size: 20,
|
|
color: Colors.white,
|
|
),
|
|
const Padding(padding: EdgeInsets.symmetric(horizontal: 6)),
|
|
Text(
|
|
text,
|
|
style: const TextStyle(
|
|
color: Colors.white,
|
|
fontWeight: FontWeight.w600,
|
|
fontFamily: 'Inter-SemiBold',
|
|
fontSize: 18,
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
return InkWell(
|
|
onTap: onTap as void Function()?,
|
|
child: Container(
|
|
height: 56,
|
|
decoration: BoxDecoration(
|
|
gradient: LinearGradient(
|
|
begin: const Alignment(0.1, -0.9),
|
|
end: const Alignment(-0.6, 0.9),
|
|
colors: reversedGradient
|
|
? linearGradientColors.reversed.toList()
|
|
: linearGradientColors,
|
|
),
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: Center(child: buttonContent),
|
|
),
|
|
);
|
|
}
|
|
}
|