Skip to content

Commit

Permalink
💾 Feat(DownloadSourceSwitcher): Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Dynesshely committed Aug 10, 2024
1 parent 11ffd30 commit 00d61b1
Showing 1 changed file with 67 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,45 +97,77 @@ Widget getDownloadList(BuildContext context) {

backToHome = () => navigateTo(0);

var sourceSwitcher = Padding(
padding: EdgeInsets.only(top: tilesPadding),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Download_SelectDownloadSource'.tr),
const SizedBox(width: 20),
Container(
width: 120,
child: Obx(
() => DropdownButton<String>(
value: downloadSource.value,
icon: const Icon(Icons.arrow_downward),
isExpanded: true,
onChanged: (String? value) {
if (value == null) return;
var downloadSourceController = TextEditingController();

downloadSource.value = value;
},
items: const [
const DropdownMenuItem(
child: const Text('GitHub'),
value: 'GitHub',
),
// ToDo: Add Gitee download source
downloadSourceController.addListener(() {
var text = downloadSourceController.text;
var available = ['GitHub', 'Crequency'];
var valid = false;

// const DropdownMenuItem(
// child: const Text('Gitee'),
// value: 'Gitee',
// ),
const DropdownMenuItem(
child: const Text('Crequency'),
value: 'Crequency',
),
for (var element in available) {
if (element.startsWith(text)) {
valid = true;
downloadSourceController.text = element;
continue;
}
}

if (valid == false) {
downloadSourceController.text = 'GitHub';
}
});

var sourceSwitcher = Padding(
padding: EdgeInsets.only(top: tilesPadding),
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Download_SelectDownloadSource'.tr),
const SizedBox(width: 20),
Obx(
() => DropdownMenu(
initialSelection: downloadSource.value,
leadingIcon: const Icon(Icons.cloud_download_rounded),
controller: downloadSourceController,
enableFilter: false,
enableSearch: false,
// inputDecorationTheme: const InputDecorationTheme(filled: true),
onSelected: (value) => downloadSource.value = value!,
dropdownMenuEntries: [
DropdownMenuEntry(value: 'GitHub', label: 'GitHub'),
DropdownMenuEntry(value: 'Crequency', label: 'Crequency'),
],
),
// DropdownButton<String>(
// value: downloadSource.value,
// icon: const Icon(Icons.arrow_downward),
// isExpanded: true,
// onChanged: (String? value) {
// if (value == null) return;

// downloadSource.value = value;
// },
// items: const [
// const DropdownMenuItem(
// child: const Text('GitHub'),
// value: 'GitHub',
// ),
// // ToDo: Add Gitee download source

// // const DropdownMenuItem(
// // child: const Text('Gitee'),
// // value: 'Gitee',
// // ),
// const DropdownMenuItem(
// child: const Text('Crequency'),
// value: 'Crequency',
// ),
// ],
// ),
),
),
],
],
),
),
);

Expand Down Expand Up @@ -221,7 +253,7 @@ Widget getDownloadList(BuildContext context) {
trailing: const Icon(CommunityMaterialIcons.open_in_new),
onTap: () => openLink('GitHubRepo_KitX_Releases'),
),
sourceSwitcher,
// sourceSwitcher,
],
),
),
Expand Down

0 comments on commit 00d61b1

Please sign in to comment.