diff --git a/lib/models/app.dart b/lib/models/app.dart index b790e43..254caeb 100644 --- a/lib/models/app.dart +++ b/lib/models/app.dart @@ -39,7 +39,7 @@ class App extends Event with BaseApp { // final androidInfo = await deviceInfo.androidInfo; // return androidInfo.architecture; // e.g. "arm64-v8a" // } - return releases.latest?.artifacts + return releases.ordered.firstOrNull?.artifacts .where((a) => a.mimeType == 'application/vnd.android.package-archive' && a.architectures.contains('arm64-v8a')) diff --git a/lib/models/release.dart b/lib/models/release.dart index 44527ec..143d3ab 100644 --- a/lib/models/release.dart +++ b/lib/models/release.dart @@ -36,6 +36,6 @@ mixin ReleaseAdapter on Adapter { } extension HasManyReleaseX on HasMany { - Release? get latest => - toList().sorted((a, b) => a.createdAt.compareTo(b.createdAt)).firstOrNull; + List get ordered => + toList().sorted((a, b) => b.createdAt.compareTo(a.createdAt)); } diff --git a/lib/models/user.dart b/lib/models/user.dart index 2ee8e0f..0de7814 100644 --- a/lib/models/user.dart +++ b/lib/models/user.dart @@ -4,7 +4,6 @@ import 'package:collection/collection.dart'; import 'package:flutter_data/flutter_data.dart'; import 'package:json_annotation/json_annotation.dart'; import 'package:purplebase/purplebase.dart'; -import 'package:zapstore/main.data.dart'; import 'package:zapstore/models/nostr_adapter.dart'; part 'user.g.dart'; diff --git a/lib/screens/app_detail_screen.dart b/lib/screens/app_detail_screen.dart index 1558df9..b62d849 100644 --- a/lib/screens/app_detail_screen.dart +++ b/lib/screens/app_detail_screen.dart @@ -8,7 +8,6 @@ import 'package:flutter_markdown/flutter_markdown.dart'; import 'package:gap/gap.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:intl/intl.dart'; -import 'package:purplebase/purplebase.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:zapstore/main.dart'; import 'package:zapstore/main.data.dart'; @@ -37,142 +36,150 @@ class AppDetailScreen extends HookConsumerWidget { final app = state.model ?? model; - return Column( - children: [ - Expanded( - child: CustomScrollView( - slivers: [ - // SliverAppBar( - // pinned: true, - // leading: IconButton( - // icon: Icon(Icons.arrow_back), - // onPressed: () { - // context.pop(); - // }, - // ), - // ), - SliverList( - delegate: SliverChildListDelegate( - [ - VersionedAppHeader(app: app), - Gap(16), - if (app.images.isNotEmpty) - Scrollbar( - controller: scrollController, - interactive: true, - trackVisibility: true, - child: SingleChildScrollView( + return RefreshIndicator( + onRefresh: () => ref.apps.findOne(model.id!), + child: Column( + children: [ + Expanded( + child: CustomScrollView( + slivers: [ + // SliverAppBar( + // pinned: true, + // leading: IconButton( + // icon: Icon(Icons.arrow_back), + // onPressed: () { + // context.pop(); + // }, + // ), + // ), + SliverList( + delegate: SliverChildListDelegate( + [ + VersionedAppHeader(app: app), + Gap(16), + if (app.images.isNotEmpty) + Scrollbar( controller: scrollController, - scrollDirection: Axis.horizontal, - child: SizedBox( - height: 320, - child: Row( - children: [ - for (final i in app.images) - Padding( - padding: const EdgeInsets.only(right: 12), - child: CachedNetworkImage(imageUrl: i), - ), - ], + interactive: true, + trackVisibility: true, + child: SingleChildScrollView( + controller: scrollController, + scrollDirection: Axis.horizontal, + child: SizedBox( + height: 320, + child: Row( + children: [ + for (final i in app.images) + Padding( + padding: const EdgeInsets.only(right: 12), + child: CachedNetworkImage(imageUrl: i), + ), + ], + ), ), ), ), + Divider(height: 24), + MarkdownBody( + styleSheet: MarkdownStyleSheet( + h1: TextStyle(fontWeight: FontWeight.bold), + h2: TextStyle(fontWeight: FontWeight.bold), + p: TextStyle( + fontSize: 18, fontWeight: FontWeight.w300), + ), + selectable: false, + data: app.content, ), - Divider(height: 24), - MarkdownBody( - styleSheet: MarkdownStyleSheet( - h1: TextStyle(fontWeight: FontWeight.bold), - h2: TextStyle(fontWeight: FontWeight.bold), - p: TextStyle(fontSize: 18, fontWeight: FontWeight.w300), + Gap(10), + Padding( + padding: const EdgeInsets.only(right: 14), + child: SignerAndDeveloperRow(app: app), ), - selectable: false, - data: app.content, - ), - Gap(10), - Padding( - padding: const EdgeInsets.only(right: 14), - child: SignerAndDeveloperRow(app: app), - ), - Gap(30), - Container( - padding: EdgeInsets.all(10), - decoration: BoxDecoration( - color: Colors.grey[900], - borderRadius: BorderRadius.circular(10), - ), - child: Column( - children: [ - Padding( - padding: const EdgeInsets.all(8), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - SizedBox(child: Text('Source')), - Flexible( - child: AutoSizeText( - app.repository!, - minFontSize: 11, - maxLines: 1, - overflow: TextOverflow.ellipsis, + Gap(30), + Container( + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + color: Colors.grey[900], + borderRadius: BorderRadius.circular(10), + ), + child: Column( + children: [ + Padding( + padding: const EdgeInsets.all(8), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + SizedBox(child: Text('Source')), + Flexible( + child: AutoSizeText( + app.repository!, + minFontSize: 11, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), ), - ), - ], + ], + ), ), - ), - Padding( - padding: const EdgeInsets.all(8), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text('Github stars'), - Text(app.githubStars) - ], + Padding( + padding: const EdgeInsets.all(8), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text('Github stars'), + Text(app.githubStars) + ], + ), ), - ), - Padding( - padding: const EdgeInsets.all(8), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text('Github forks'), - Text(app.githubForks) - ], + Padding( + padding: const EdgeInsets.all(8), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text('Github forks'), + Text(app.githubForks) + ], + ), ), - ), - Padding( - padding: const EdgeInsets.all(8), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [Text('License'), Text(app.license)], + Padding( + padding: const EdgeInsets.all(8), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [Text('License'), Text(app.license)], + ), ), - ), - ], + ], + ), ), - ), - Divider(height: 50), - Text( - 'Releases'.toUpperCase(), - style: TextStyle( - fontSize: 16, - letterSpacing: 3, - fontWeight: FontWeight.w300, + Divider(height: 50), + Text( + 'Releases'.toUpperCase(), + style: TextStyle( + fontSize: 16, + letterSpacing: 3, + fontWeight: FontWeight.w300, + ), ), - ), - for (final release in app.releases.toList()) - ReleaseCard(release: release), - ], + for (final release in app.releases.ordered) + ReleaseCard(release: release), + ], + ), ), - ), - ], + ], + ), ), - ), - SizedBox( - height: 50, - child: Center( - child: InstallButton(app: app), + SizedBox( + height: 50, + child: Center( + child: InstallButton(app: app), + ), ), - ), - ], + ], + ), ); } } @@ -312,7 +319,12 @@ class ReleaseCard extends StatelessWidget { Text(release.version, style: TextStyle(fontSize: 26, fontWeight: FontWeight.bold)), Gap(10), - MarkdownBody(data: release.content), + Container( + constraints: BoxConstraints( + maxHeight: 260, + ), + child: Markdown(data: release.content), + ), Gap(30), if (metadata != null) Padding( diff --git a/lib/widgets/card.dart b/lib/widgets/card.dart index 2ce0f5f..49d228c 100644 --- a/lib/widgets/card.dart +++ b/lib/widgets/card.dart @@ -171,6 +171,7 @@ class CircularImage extends StatelessWidget { child: Icon( Icons.person, color: Colors.blueGrey, + size: size * 0.7, ), ); return ClipRRect( diff --git a/pubspec.yaml b/pubspec.yaml index 1405fd3..1b5dd08 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -25,7 +25,7 @@ dependencies: flutter: sdk: flutter cupertino_icons: ^1.0.2 - flutter_data: ^1.6.0 + flutter_data: ^2.0.0-rc3 hooks_riverpod: ^2.4.9 json_annotation: ^4.8.1 flutter_hooks: ^0.20.4 @@ -59,7 +59,9 @@ dependency_overrides: url: https://github.com/purplebase/purplebase ref: f6a6a7 flutter_data: - path: ../flutter_data + git: + url: https://github.com/flutterdata/flutter_data + ref: e54a2e dev_dependencies: flutter_test: