Skip to content

Commit

Permalink
Fix touchpad scrolling (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
Feichtmeier committed Jun 15, 2022
1 parent d1386e7 commit e356cca
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 43 deletions.
15 changes: 9 additions & 6 deletions lib/store_app/explore/explore_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,17 @@ class _ExploreModePage extends StatelessWidget {

@override
Widget build(BuildContext context) {
return const YaruPage(
padding: EdgeInsets.symmetric(horizontal: 20),
return YaruPage(
padding: const EdgeInsets.symmetric(horizontal: 20),
children: [
SnapBannerCarousel(
const SnapBannerCarousel(
snapSection: SnapSection.featured,
height: 220,
),
SectionBannerGrid(snapSection: SnapSection.development),
SectionBannerGrid(snapSection: SnapSection.games)
SectionBannerGrid(
controller: ScrollController(),
snapSection: SnapSection.featured,
),
],
);
}
Expand All @@ -136,7 +138,7 @@ class _GridViewPage extends StatelessWidget {
final model = context.watch<ExploreModel>();

return YaruPage(
padding: const EdgeInsets.symmetric(horizontal: 20),
padding: const EdgeInsets.all(0),
children: [
if (model.searchActive)
const SizedBox(
Expand All @@ -151,6 +153,7 @@ class _GridViewPage extends StatelessWidget {
for (int i = 0; i < model.filters.entries.length; i++)
if (model.filters.entries.elementAt(i).value == true)
SnapTileGrid(
controller: ScrollController(),
appendBottomDivier: true,
name: model.filters.entries.elementAt(i).key.title,
headline: model.filters.entries
Expand Down
5 changes: 4 additions & 1 deletion lib/store_app/explore/section_banner_grid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ class SectionBannerGrid extends StatefulWidget {
Key? key,
required this.snapSection,
this.amount = 20,
this.controller,
}) : super(key: key);

final SnapSection snapSection;
final int amount;
final ScrollController? controller;

@override
State<SectionBannerGrid> createState() => _SectionBannerGridState();
Expand All @@ -31,12 +33,13 @@ class _SectionBannerGridState extends State<SectionBannerGrid> {
final sections = model.sectionNameToSnapsMap[widget.snapSection.title];

return GridView(
controller: widget.controller,
shrinkWrap: true,
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
mainAxisExtent: 110,
mainAxisSpacing: 20,
crossAxisSpacing: 20,
maxCrossAxisExtent: 500,
maxCrossAxisExtent: 450,
),
children: sections != null && sections.isNotEmpty
? sections.take(widget.amount).map((snap) {
Expand Down
7 changes: 7 additions & 0 deletions lib/store_app/explore/snap_tile_grid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ class SnapTileGrid extends StatefulWidget {
required this.findByQuery,
this.itemCount = 20,
this.appendBottomDivier = false,
this.controller,
}) : super(key: key);

final String name;
final String? headline;
final bool findByQuery;
final int itemCount;
final bool appendBottomDivier;
final ScrollController? controller;

@override
State<SnapTileGrid> createState() => _SnapTileGridState();
Expand All @@ -47,6 +49,7 @@ class _SnapTileGridState extends State<SnapTileGrid> {
if (!widget.findByQuery) {
final snaps = model.sectionNameToSnapsMap[widget.name];
return _Grid(
controller: widget.controller,
appendBottomDivider: widget.appendBottomDivier,
snapAmount: widget.itemCount,
headline: widget.headline,
Expand All @@ -58,6 +61,7 @@ class _SnapTileGridState extends State<SnapTileGrid> {
future: model.findSnapsByQuery(),
builder: (context, snapshot) => snapshot.hasData
? _Grid(
controller: widget.controller,
appendBottomDivider: widget.appendBottomDivier,
snapAmount: widget.itemCount,
headline: widget.headline,
Expand All @@ -80,12 +84,14 @@ class _Grid extends StatefulWidget {
required this.snaps,
required this.snapAmount,
required this.appendBottomDivider,
this.controller,
}) : super(key: key);

final String? headline;
final List<Snap> snaps;
final int snapAmount;
final bool appendBottomDivider;
final ScrollController? controller;

@override
State<_Grid> createState() => _GridState();
Expand Down Expand Up @@ -134,6 +140,7 @@ class _GridState extends State<_Grid> {
height: 15,
),
GridView(
controller: widget.controller,
shrinkWrap: true,
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
crossAxisSpacing: 40,
Expand Down
13 changes: 5 additions & 8 deletions lib/store_app/my_apps/my_packages_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:software/store_app/my_apps/my_apps_page.dart';
import 'package:software/store_app/my_apps/my_packages_model.dart';
import 'package:software/store_app/my_apps/package_banner.dart';
import 'package:ubuntu_service/ubuntu_service.dart';
import 'package:yaru_widgets/yaru_widgets.dart';

class MyPackagesPage extends StatefulWidget {
const MyPackagesPage({Key? key}) : super(key: key);
Expand All @@ -31,19 +30,17 @@ class _MyPackagesPageState extends State<MyPackagesPage> {
@override
Widget build(BuildContext context) {
final model = context.watch<MyPackagesModel>();
return YaruPage(
children: [
if (model.packages.isNotEmpty)
GridView.builder(
return model.packages.isNotEmpty
? GridView.builder(
padding: const EdgeInsets.all(20.0),
gridDelegate: myAppsGridDelegate,
shrinkWrap: true,
itemCount: model.packages.length,
itemBuilder: (context, index) {
final packageId = model.packages.elementAt(index);
return PackageBanner.create(context, packageId);
},
),
],
);
)
: const SizedBox();
}
}
13 changes: 5 additions & 8 deletions lib/store_app/my_apps/my_snaps_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:software/store_app/my_apps/local_snap_banner.dart';
import 'package:software/store_app/my_apps/my_apps_page.dart';
import 'package:software/store_app/my_apps/my_snaps_model.dart';
import 'package:ubuntu_service/ubuntu_service.dart';
import 'package:yaru_widgets/yaru_widgets.dart';

class MySnapsPage extends StatefulWidget {
const MySnapsPage({Key? key, required this.online}) : super(key: key);
Expand Down Expand Up @@ -38,10 +37,9 @@ class _MySnapsPageState extends State<MySnapsPage> {
@override
Widget build(BuildContext context) {
final mySnapsModel = context.watch<MySnapsModel>();
return YaruPage(
children: [
if (mySnapsModel.localSnaps.isNotEmpty)
GridView.builder(
return mySnapsModel.localSnaps.isNotEmpty
? GridView.builder(
padding: const EdgeInsets.all(20.0),
gridDelegate: myAppsGridDelegate,
shrinkWrap: true,
itemCount: mySnapsModel.localSnaps.length,
Expand All @@ -53,8 +51,7 @@ class _MySnapsPageState extends State<MySnapsPage> {
widget.online,
);
},
),
],
);
)
: const SizedBox();
}
}
11 changes: 0 additions & 11 deletions lib/store_app/store_app.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:badges/badges.dart';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:software/l10n/l10n.dart';
Expand Down Expand Up @@ -45,7 +44,6 @@ class _StoreAppState extends State<StoreApp> {
return MaterialApp(
theme: yaru.variant?.theme ?? yaruLight,
darkTheme: yaru.variant?.darkTheme ?? yaruDark,
scrollBehavior: TouchMouseStylusScrollBehavior(),
debugShowCheckedModeBanner: false,
title: 'Ubuntu Software App',
localizationsDelegates: AppLocalizations.localizationsDelegates,
Expand Down Expand Up @@ -89,15 +87,6 @@ class _StoreAppState extends State<StoreApp> {
}
}

class TouchMouseStylusScrollBehavior extends MaterialScrollBehavior {
@override
Set<PointerDeviceKind> get dragDevices => {
PointerDeviceKind.touch,
PointerDeviceKind.mouse,
PointerDeviceKind.stylus
};
}

class _MyAppsIcon extends StatelessWidget {
// ignore: unused_element
const _MyAppsIcon({super.key, required this.count});
Expand Down
16 changes: 8 additions & 8 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,10 @@ packages:
description:
path: "."
ref: HEAD
resolved-ref: e0576c7d57d7adf17146d12e2187feca301f2b97
resolved-ref: "28636a98c53a9b0368f9712641c3b445e42d68a6"
url: "https://github.com/canonical/snapd.dart"
source: git
version: "0.4.2"
version: "0.4.3"
source_span:
dependency: transitive
description:
Expand Down Expand Up @@ -533,7 +533,7 @@ packages:
name: url_launcher_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.11"
version: "2.0.12"
url_launcher_windows:
dependency: transitive
description:
Expand All @@ -554,7 +554,7 @@ packages:
name: version
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.0.3"
win32:
dependency: transitive
description:
Expand Down Expand Up @@ -590,10 +590,10 @@ packages:
description:
path: "."
ref: HEAD
resolved-ref: "897b59237669bd29c4baf47b8332289a4b26b5fd"
resolved-ref: "97b74b4b905b4bf295280b931e31810a309be747"
url: "https://github.com/ubuntu/yaru.dart"
source: git
version: "0.3.2"
version: "0.3.3"
yaru_color_generator:
dependency: transitive
description:
Expand Down Expand Up @@ -622,10 +622,10 @@ packages:
description:
path: "."
ref: HEAD
resolved-ref: f33a5d5a9d625e2150fa3b9a4992f0960bdf4dd7
resolved-ref: "16fd0a235b190d617d17c4c3b8c827bd648f7e90"
url: "https://github.com/ubuntu/yaru_widgets.dart"
source: git
version: "1.0.13"
version: "1.1.0"
sdks:
dart: ">=2.17.0 <3.0.0"
flutter: ">=3.0.0"
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: An Ubuntu software app made with Flutter.

publish_to: "none"

version: 0.0.4-alpha
version: 0.0.5-alpha

environment:
sdk: ">=2.17.0 <3.0.0"
Expand Down

0 comments on commit e356cca

Please sign in to comment.