mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2024-11-10 01:01:56 +01:00
feat: wip contributors screen.
This commit is contained in:
parent
4d3ea65d7f
commit
739673dd8f
13 changed files with 271 additions and 7 deletions
|
@ -1,6 +1,7 @@
|
|||
import 'package:revanced_manager/services/patcher_api.dart';
|
||||
import 'package:revanced_manager/ui/views/app_selector/app_selector_view.dart';
|
||||
import 'package:revanced_manager/ui/views/app_selector/app_selector_viewmodel.dart';
|
||||
import 'package:revanced_manager/ui/views/contributors/contributors_view.dart';
|
||||
import 'package:revanced_manager/ui/views/home/home_view.dart';
|
||||
import 'package:revanced_manager/ui/views/patcher/patcher_view.dart';
|
||||
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
|
||||
|
@ -17,7 +18,8 @@ import 'package:stacked_themes/stacked_themes.dart';
|
|||
MaterialRoute(page: AppSelectorView),
|
||||
MaterialRoute(page: PatcherView),
|
||||
MaterialRoute(page: PatchesSelectorView),
|
||||
MaterialRoute(page: SettingsView)
|
||||
MaterialRoute(page: SettingsView),
|
||||
MaterialRoute(page: ContributorsView)
|
||||
],
|
||||
dependencies: [
|
||||
LazySingleton(classType: NavigationService),
|
||||
|
|
|
@ -7,9 +7,10 @@
|
|||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart' as _i1;
|
||||
import 'package:stacked_services/stacked_services.dart' as _i7;
|
||||
import 'package:stacked_services/stacked_services.dart' as _i8;
|
||||
|
||||
import '../ui/views/app_selector/app_selector_view.dart' as _i3;
|
||||
import '../ui/views/contributors/contributors_view.dart' as _i7;
|
||||
import '../ui/views/home/home_view.dart' as _i2;
|
||||
import '../ui/views/patcher/patcher_view.dart' as _i4;
|
||||
import '../ui/views/patches_selector/patches_selector_view.dart' as _i5;
|
||||
|
@ -26,12 +27,15 @@ class Routes {
|
|||
|
||||
static const settingsView = '/settings-view';
|
||||
|
||||
static const contributorsView = '/contributors-view';
|
||||
|
||||
static const all = <String>{
|
||||
homeView,
|
||||
appSelectorView,
|
||||
patcherView,
|
||||
patchesSelectorView,
|
||||
settingsView
|
||||
settingsView,
|
||||
contributorsView
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -41,7 +45,8 @@ class StackedRouter extends _i1.RouterBase {
|
|||
_i1.RouteDef(Routes.appSelectorView, page: _i3.AppSelectorView),
|
||||
_i1.RouteDef(Routes.patcherView, page: _i4.PatcherView),
|
||||
_i1.RouteDef(Routes.patchesSelectorView, page: _i5.PatchesSelectorView),
|
||||
_i1.RouteDef(Routes.settingsView, page: _i6.SettingsView)
|
||||
_i1.RouteDef(Routes.settingsView, page: _i6.SettingsView),
|
||||
_i1.RouteDef(Routes.contributorsView, page: _i7.ContributorsView)
|
||||
];
|
||||
|
||||
final _pagesMap = <Type, _i1.StackedRouteFactory>{
|
||||
|
@ -74,6 +79,12 @@ class StackedRouter extends _i1.RouterBase {
|
|||
builder: (context) => const _i6.SettingsView(),
|
||||
settings: data,
|
||||
);
|
||||
},
|
||||
_i7.ContributorsView: (data) {
|
||||
return MaterialPageRoute<dynamic>(
|
||||
builder: (context) => const _i7.ContributorsView(),
|
||||
settings: data,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -83,7 +94,7 @@ class StackedRouter extends _i1.RouterBase {
|
|||
Map<Type, _i1.StackedRouteFactory> get pagesMap => _pagesMap;
|
||||
}
|
||||
|
||||
extension NavigatorStateExtension on _i7.NavigationService {
|
||||
extension NavigatorStateExtension on _i8.NavigationService {
|
||||
Future<dynamic> navigateToHomeView(
|
||||
[int? routerId,
|
||||
bool preventDuplicates = true,
|
||||
|
@ -153,4 +164,18 @@ extension NavigatorStateExtension on _i7.NavigationService {
|
|||
parameters: parameters,
|
||||
transition: transition);
|
||||
}
|
||||
|
||||
Future<dynamic> navigateToContributorsView(
|
||||
[int? routerId,
|
||||
bool preventDuplicates = true,
|
||||
Map<String, String>? parameters,
|
||||
Widget Function(
|
||||
BuildContext, Animation<double>, Animation<double>, Widget)?
|
||||
transition]) async {
|
||||
navigateTo(Routes.contributorsView,
|
||||
id: routerId,
|
||||
preventDuplicates: preventDuplicates,
|
||||
parameters: parameters,
|
||||
transition: transition);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,3 +14,6 @@ final robotoTextStyle = GoogleFonts.roboto();
|
|||
const ghOrg = 'revanced';
|
||||
const patchesRepo = 'revanced-patches';
|
||||
const integrationsRepo = 'revanced-integrations';
|
||||
const patcherRepo = 'revanced-patcher';
|
||||
const cliRepo = 'revanced-cli';
|
||||
const managerRepo = 'revanced-manager';
|
||||
|
|
|
@ -15,7 +15,6 @@ import 'package:stacked_services/stacked_services.dart';
|
|||
import 'package:stacked_themes/stacked_themes.dart';
|
||||
|
||||
Future main() async {
|
||||
setupLocator();
|
||||
await ThemeManager.initialise();
|
||||
setupLocator();
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
|
|
@ -37,4 +37,16 @@ class GithubAPI {
|
|||
}
|
||||
return pushedAt;
|
||||
}
|
||||
|
||||
Future<List<Contributor>> getContributors(String org, repoName) async {
|
||||
try {
|
||||
var contributors = await github.repositories.listContributors(
|
||||
RepositorySlug(org, repoName),
|
||||
);
|
||||
return contributors.toList();
|
||||
} on Exception {
|
||||
print(Exception);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:revanced_manager/constants.dart';
|
||||
import 'package:stacked_themes/stacked_themes.dart';
|
||||
|
||||
import 'app/app.locator.dart';
|
||||
|
|
56
lib/ui/views/contributors/contributors_view.dart
Normal file
56
lib/ui/views/contributors/contributors_view.dart
Normal file
|
@ -0,0 +1,56 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:revanced_manager/ui/views/contributors/contributors_viewmodel.dart';
|
||||
import 'package:revanced_manager/ui/widgets/contributors_card.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
class ContributorsView extends StatelessWidget {
|
||||
const ContributorsView({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<ContributorsViewModel>.reactive(
|
||||
disposeViewModel: false,
|
||||
viewModelBuilder: () => ContributorsViewModel(),
|
||||
onModelReady: (model) => model.getContributors(),
|
||||
builder: (context, model, child) => Scaffold(
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () => model.getContributors(),
|
||||
child: const Icon(Icons.refresh),
|
||||
),
|
||||
body: SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
ContributorsCard(
|
||||
title: "Patcher Contributors",
|
||||
contributors: model.patcherContributors,
|
||||
height: 60,
|
||||
),
|
||||
ContributorsCard(
|
||||
title: "Patches Contributors",
|
||||
contributors: model.patchesContributors,
|
||||
height: 230,
|
||||
),
|
||||
ContributorsCard(
|
||||
title: "Integrations Contributors",
|
||||
contributors: model.integrationsContributors,
|
||||
height: 230,
|
||||
),
|
||||
ContributorsCard(
|
||||
title: "CLI Contributors",
|
||||
contributors: model.cliContributors,
|
||||
height: 180,
|
||||
),
|
||||
ContributorsCard(
|
||||
title: "Manager Contributors",
|
||||
contributors: model.managerContributors,
|
||||
height: 130,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
27
lib/ui/views/contributors/contributors_viewmodel.dart
Normal file
27
lib/ui/views/contributors/contributors_viewmodel.dart
Normal file
|
@ -0,0 +1,27 @@
|
|||
import 'package:github/github.dart';
|
||||
import 'package:revanced_manager/services/github_api.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
class ContributorsViewModel extends BaseViewModel {
|
||||
final GithubAPI githubAPI = GithubAPI();
|
||||
List<Contributor> patchesContributors = [];
|
||||
List<Contributor> integrationsContributors = [];
|
||||
List<Contributor> patcherContributors = [];
|
||||
List<Contributor> cliContributors = [];
|
||||
List<Contributor> managerContributors = [];
|
||||
|
||||
Future<List<Contributor>> getContributors() async {
|
||||
patchesContributors =
|
||||
await githubAPI.getContributors('revanced', 'revanced-patches');
|
||||
integrationsContributors =
|
||||
await githubAPI.getContributors('revanced', 'revanced-integrations');
|
||||
patcherContributors =
|
||||
await githubAPI.getContributors('revanced', 'revanced-patcher');
|
||||
cliContributors =
|
||||
await githubAPI.getContributors('revanced', 'revanced-cli');
|
||||
managerContributors =
|
||||
await githubAPI.getContributors('revanced', 'revanced-manager');
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
|
@ -77,6 +77,7 @@ class SettingsView extends StatelessWidget {
|
|||
),
|
||||
ListTile(
|
||||
title: I18nText('settingsView.contributorsLabel'),
|
||||
onTap: model.navigateToContributors,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
@ -1,7 +1,16 @@
|
|||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/app/app.router.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
|
||||
class SettingsViewModel extends BaseViewModel {
|
||||
final _navigationService = locator<NavigationService>();
|
||||
|
||||
void setLanguage(String language) {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void navigateToContributors() {
|
||||
_navigationService.navigateTo(Routes.contributorsView);
|
||||
}
|
||||
}
|
||||
|
|
74
lib/ui/widgets/contributors_card.dart
Normal file
74
lib/ui/widgets/contributors_card.dart
Normal file
|
@ -0,0 +1,74 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:github/github.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:revanced_manager/constants.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class ContributorsCard extends StatefulWidget {
|
||||
final String title;
|
||||
final List<Contributor> contributors;
|
||||
final double height;
|
||||
|
||||
const ContributorsCard({
|
||||
Key? key,
|
||||
required this.title,
|
||||
required this.contributors,
|
||||
this.height = 200,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<ContributorsCard> createState() => _ContributorsCardState();
|
||||
}
|
||||
|
||||
class _ContributorsCardState extends State<ContributorsCard> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 4.0),
|
||||
child: Text(
|
||||
widget.title,
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
margin: const EdgeInsets.all(8.0),
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.tertiary,
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
height: widget.height,
|
||||
child: GridView.builder(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 7,
|
||||
mainAxisSpacing: 8,
|
||||
crossAxisSpacing: 8,
|
||||
),
|
||||
itemCount: widget.contributors.length,
|
||||
itemBuilder: (context, index) {
|
||||
return ClipRRect(
|
||||
borderRadius: BorderRadius.circular(100),
|
||||
child: GestureDetector(
|
||||
onTap: () =>
|
||||
launchUrl(Uri.parse(widget.contributors[index].htmlUrl!)),
|
||||
child: Image.network(
|
||||
widget.contributors[index].avatarUrl!,
|
||||
height: 40,
|
||||
width: 40,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
56
pubspec.lock
56
pubspec.lock
|
@ -817,6 +817,62 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.4"
|
||||
url_launcher:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: url_launcher
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "6.1.5"
|
||||
url_launcher_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_android
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "6.0.17"
|
||||
url_launcher_ios:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_ios
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "6.0.17"
|
||||
url_launcher_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_linux
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.1"
|
||||
url_launcher_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_macos
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.1"
|
||||
url_launcher_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
url_launcher_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_web
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.13"
|
||||
url_launcher_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_windows
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.1"
|
||||
uuid:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -30,6 +30,7 @@ dependencies:
|
|||
stacked_services: ^0.9.3
|
||||
stacked_themes: ^0.3.9
|
||||
timeago: ^3.2.2
|
||||
url_launcher: ^6.1.5
|
||||
|
||||
dev_dependencies:
|
||||
build_runner: any
|
||||
|
|
Loading…
Reference in a new issue