-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea0d258
commit d891874
Showing
7 changed files
with
171 additions
and
62 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,117 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:packagekit/packagekit.dart'; | ||
import 'package:provider/provider.dart'; | ||
import 'package:snapd/snapd.dart'; | ||
import 'package:software/l10n/l10n.dart'; | ||
import 'package:software/snapx.dart'; | ||
import 'package:software/store_app/common/app_banner.dart'; | ||
import 'package:software/store_app/common/constants.dart'; | ||
import 'package:software/store_app/common/snap_dialog.dart'; | ||
import 'package:software/store_app/explore/explore_model.dart'; | ||
import 'package:software/store_app/my_apps/package_dialog.dart'; | ||
import 'package:yaru_icons/yaru_icons.dart'; | ||
import 'package:yaru_widgets/yaru_widgets.dart'; | ||
|
||
class SearchPage extends StatelessWidget { | ||
const SearchPage({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return YaruTabbedPage( | ||
tabIcons: const [YaruIcons.package_snap, YaruIcons.package_deb], | ||
tabTitles: [ | ||
context.l10n.snapPackages, | ||
context.l10n.debianPackages, | ||
], | ||
views: const [ | ||
_SnapSearchPage(), | ||
_PackageKitSearchPage(), | ||
], | ||
); | ||
} | ||
} | ||
|
||
class _SnapSearchPage extends StatelessWidget { | ||
// ignore: unused_element | ||
const _SnapSearchPage({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final model = context.watch<ExploreModel>(); | ||
|
||
return Padding( | ||
padding: const EdgeInsets.only(top: 20), | ||
child: FutureBuilder<List<Snap>>( | ||
future: model.findSnapsByQuery(), | ||
builder: (context, snapshot) => | ||
snapshot.hasData && snapshot.data!.isNotEmpty | ||
? GridView( | ||
controller: ScrollController(), | ||
padding: const EdgeInsets.symmetric(horizontal: 20), | ||
gridDelegate: kGridDelegate, | ||
shrinkWrap: true, | ||
children: [ | ||
for (final snap in snapshot.data!) | ||
AppBanner( | ||
name: snap.name, | ||
summary: snap.summary, | ||
url: snap.iconUrl, | ||
onTap: () => showDialog( | ||
context: context, | ||
builder: (context) => SnapDialog.create( | ||
context: context, | ||
huskSnapName: snap.name, | ||
), | ||
), | ||
) | ||
], | ||
) | ||
: const SizedBox(), | ||
), | ||
); | ||
} | ||
} | ||
|
||
class _PackageKitSearchPage extends StatelessWidget { | ||
// ignore: unused_element | ||
const _PackageKitSearchPage({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final model = context.watch<ExploreModel>(); | ||
if (model.searchQuery.isEmpty) return const SizedBox(); | ||
return FutureBuilder<List<Snap>>( | ||
future: model.findSnapsByQuery(), | ||
builder: (context, snapshot) => | ||
snapshot.hasData && snapshot.data!.isNotEmpty | ||
? GridView( | ||
padding: const EdgeInsets.symmetric(horizontal: 20), | ||
gridDelegate: kGridDelegate, | ||
shrinkWrap: true, | ||
children: [ | ||
for (final snap in snapshot.data!) | ||
AppBanner( | ||
name: snap.name, | ||
summary: snap.summary, | ||
url: snap.iconUrl, | ||
onTap: () => showDialog( | ||
context: context, | ||
builder: (context) => SnapDialog.create( | ||
|
||
return Padding( | ||
padding: const EdgeInsets.only(top: 20), | ||
child: FutureBuilder<List<PackageKitPackageId>>( | ||
future: model.findPackageKitPackageIds(), | ||
builder: (context, snapshot) => | ||
snapshot.hasData && snapshot.data!.isNotEmpty | ||
? GridView( | ||
controller: ScrollController(), | ||
padding: const EdgeInsets.symmetric(horizontal: 20), | ||
gridDelegate: kGridDelegate, | ||
shrinkWrap: true, | ||
children: [ | ||
for (final id in snapshot.data!) | ||
AppBanner( | ||
name: id.name, | ||
summary: id.version, | ||
icon: const Icon( | ||
YaruIcons.package_deb, | ||
size: 50, | ||
), | ||
onTap: () => showDialog( | ||
context: context, | ||
huskSnapName: snap.name, | ||
builder: (context) => PackageDialog.create( | ||
context, | ||
id, | ||
), | ||
), | ||
), | ||
) | ||
], | ||
) | ||
: const Center( | ||
child: Padding( | ||
padding: EdgeInsets.all(20.0), | ||
child: YaruCircularProgressIndicator(), | ||
), | ||
), | ||
) | ||
], | ||
) | ||
: const SizedBox(), | ||
), | ||
); | ||
} | ||
} |
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