-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #276 from tusharlock10/236-add-option-to-remove-lo…
…adouts feat(loadout): add functionality to delete custom loadout
- Loading branch information
Showing
26 changed files
with
488 additions
and
175 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
lib/screens/create_loadout/create_loadout_delete_button.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_feather_icons/flutter_feather_icons.dart'; | ||
import 'package:paladinsedge/screens/create_loadout/create_loadout_delete_confirmation.dart'; | ||
import 'package:paladinsedge/widgets/index.dart' as widgets; | ||
|
||
class CreateLoadoutDeleteButton extends StatelessWidget { | ||
final void Function() onDelete; | ||
const CreateLoadoutDeleteButton({ | ||
required this.onDelete, | ||
Key? key, | ||
}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return widgets.Button( | ||
label: 'Delete', | ||
color: Colors.red, | ||
disabled: false, | ||
leading: FeatherIcons.trash, | ||
onPressed: () => showCreateLoadoutDeleteConfirmation( | ||
context: context, | ||
onDelete: onDelete, | ||
), | ||
); | ||
} | ||
} |
103 changes: 103 additions & 0 deletions
103
lib/screens/create_loadout/create_loadout_delete_confirmation.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_hooks/flutter_hooks.dart'; | ||
import 'package:paladinsedge/widgets/index.dart' as widgets; | ||
|
||
void showCreateLoadoutDeleteConfirmation({ | ||
required BuildContext context, | ||
required void Function() onDelete, | ||
}) { | ||
final backgroundColor = Theme.of(context).scaffoldBackgroundColor; | ||
|
||
showModalBottomSheet( | ||
elevation: 10, | ||
backgroundColor: backgroundColor, | ||
shape: const RoundedRectangleBorder( | ||
borderRadius: BorderRadius.only( | ||
topLeft: Radius.circular(15), | ||
topRight: Radius.circular(15), | ||
), | ||
), | ||
context: context, | ||
builder: (_) => _CreateLoadoutDeleteConfirmation(onDelete: onDelete), | ||
); | ||
} | ||
|
||
class _CreateLoadoutDeleteConfirmation extends HookWidget { | ||
final void Function() onDelete; | ||
const _CreateLoadoutDeleteConfirmation({ | ||
required this.onDelete, | ||
Key? key, | ||
}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
// Variables | ||
final textTheme = Theme.of(context).textTheme; | ||
|
||
// Methods | ||
final onDeleteConfirm = useCallback( | ||
() { | ||
Navigator.of(context).pop(); | ||
onDelete(); | ||
}, | ||
[], | ||
); | ||
|
||
return Column( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
Card( | ||
elevation: 0, | ||
clipBehavior: Clip.hardEdge, | ||
shape: const RoundedRectangleBorder( | ||
borderRadius: BorderRadius.all(Radius.circular(10)), | ||
), | ||
margin: const EdgeInsets.all(15), | ||
child: Padding( | ||
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10), | ||
child: Column( | ||
children: [ | ||
Align( | ||
alignment: Alignment.centerLeft, | ||
child: Padding( | ||
padding: const EdgeInsets.only(right: 10), | ||
child: Text( | ||
'DELETE LOADOUT', | ||
style: textTheme.headline1?.copyWith( | ||
fontSize: 20, | ||
fontWeight: FontWeight.w900, | ||
), | ||
), | ||
), | ||
), | ||
const SizedBox(height: 10), | ||
Text( | ||
'Are you sure, you want to delete this loadout?', | ||
style: textTheme.bodyText1?.copyWith(fontSize: 16), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
const SizedBox(height: 5), | ||
Row( | ||
mainAxisAlignment: MainAxisAlignment.spaceAround, | ||
children: [ | ||
widgets.Button( | ||
label: 'Cancel', | ||
onPressed: Navigator.of(context).pop, | ||
color: Colors.red, | ||
style: widgets.ButtonStyle.outlined, | ||
), | ||
widgets.Button( | ||
label: 'Confirm', | ||
onPressed: onDeleteConfirm, | ||
color: Colors.green, | ||
), | ||
], | ||
), | ||
const SizedBox(height: 15), | ||
], | ||
); | ||
} | ||
} |
Oops, something went wrong.