Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
danemadsen committed Jun 26, 2024
1 parent f39d387 commit d0dc71a
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions lib/ui/desktop/dialogs/huggingface_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,27 @@ class HuggingfaceDialog extends StatelessWidget {
builder: (context, huggingfaceSelection, child) {
return FutureBuilder(
future: huggingfaceSelection.alreadyExists,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
return FilledButton(
onPressed: () {
final future = HuggingfaceSelection.of(context).download();
LlamaCppModel.of(context).setModelWithFuture(future);
Navigator.of(context).pop();
},
child: Text(
(snapshot.data as bool) ? "Select" : "Download"
),
);
}
else {
return const CircularProgressIndicator();
}
},
builder: buildFuture,
);
},
);
}

Widget buildFuture(BuildContext context, AsyncSnapshot<bool> snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
return FilledButton(
onPressed: () {
final future = HuggingfaceSelection.of(context).download();
LlamaCppModel.of(context).setModelWithFuture(future);
Navigator.of(context).pop();
},
child: Text(
(snapshot.data as bool) ? "Select" : "Download"
),
);
}
else {
return const CircularProgressIndicator();
}
}
}

0 comments on commit d0dc71a

Please sign in to comment.