Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
danemadsen committed Jun 25, 2024
1 parent 96bb712 commit f3301bd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 26 deletions.
31 changes: 5 additions & 26 deletions lib/ui/desktop/buttons/huggingface_button.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:maid/ui/desktop/dropdowns/huggingface_model_dropdown.dart';
import 'package:maid/ui/desktop/dialogs/huggingface_dialog.dart';

class HuggingfaceButton extends StatefulWidget {
const HuggingfaceButton({super.key});
Expand All @@ -14,7 +14,10 @@ class _HuggingfaceButtonState extends State<HuggingfaceButton> {
Widget build(BuildContext context) {
return IconButton(
tooltip: 'HuggingFace',
onPressed: () => showHuggingfaceDialog(context),
onPressed: () => showDialog(
context: context,
builder: (BuildContext context) => const HuggingfaceDialog(),
),
icon: SizedBox(
width: 30.0,
height: 30.0,
Expand All @@ -24,28 +27,4 @@ class _HuggingfaceButtonState extends State<HuggingfaceButton> {
)
);
}

void showHuggingfaceDialog(BuildContext context) {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text(
'Select HuggingFace Model',
textAlign: TextAlign.center
),
content: const HuggingfaceModelDropdown(),
actions: [
FilledButton(
onPressed: () => Navigator.of(context).pop(),
child: const Text(
"Close"
),
),
],
actionsAlignment: MainAxisAlignment.center,
);
},
);
}
}
26 changes: 26 additions & 0 deletions lib/ui/desktop/dialogs/huggingface_dialog.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import 'package:flutter/material.dart';
import 'package:maid/ui/desktop/dropdowns/huggingface_model_dropdown.dart';

class HuggingfaceDialog extends StatelessWidget {
const HuggingfaceDialog({super.key});

@override
Widget build(BuildContext context) {
return AlertDialog(
title: const Text(
'Select HuggingFace Model',
textAlign: TextAlign.center
),
content: const HuggingfaceModelDropdown(),
actions: [
FilledButton(
onPressed: () => Navigator.of(context).pop(),
child: const Text(
"Close"
),
),
],
actionsAlignment: MainAxisAlignment.center,
);
}
}

0 comments on commit f3301bd

Please sign in to comment.