mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-06-12 04:37:37 +02:00
refactor: migrate to stacked architecture.
* feat: mostly done stacked architecture. * refactor: migration to stacked architecture.
This commit is contained in:
14
lib/app/app.dart
Normal file
14
lib/app/app.dart
Normal file
@ -0,0 +1,14 @@
|
||||
import 'package:revanced_manager_flutter/ui/views/app_selector/app_selector_view.dart';
|
||||
import 'package:revanced_manager_flutter/ui/views/home/home_view.dart';
|
||||
import 'package:revanced_manager_flutter/ui/views/patcher/patcher_view.dart';
|
||||
import 'package:stacked/stacked_annotations.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
|
||||
@StackedApp(routes: [
|
||||
MaterialRoute(page: HomeView),
|
||||
MaterialRoute(page: AppSelectorView),
|
||||
MaterialRoute(page: PatcherView),
|
||||
], dependencies: [
|
||||
LazySingleton(classType: NavigationService),
|
||||
])
|
||||
class AppSetup {}
|
22
lib/app/app.locator.dart
Normal file
22
lib/app/app.locator.dart
Normal file
@ -0,0 +1,22 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
// **************************************************************************
|
||||
// StackedLocatorGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: public_member_api_docs
|
||||
|
||||
import 'package:stacked_core/stacked_core.dart';
|
||||
import 'package:stacked_services/src/navigation/navigation_service.dart';
|
||||
|
||||
final locator = StackedLocator.instance;
|
||||
|
||||
Future<void> setupLocator(
|
||||
{String? environment, EnvironmentFilter? environmentFilter}) async {
|
||||
// Register environments
|
||||
locator.registerEnvironment(
|
||||
environment: environment, environmentFilter: environmentFilter);
|
||||
|
||||
// Register dependencies
|
||||
locator.registerLazySingleton(() => NavigationService());
|
||||
}
|
102
lib/app/app.router.dart
Normal file
102
lib/app/app.router.dart
Normal file
@ -0,0 +1,102 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
// **************************************************************************
|
||||
// StackedRouterGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// 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 _i5;
|
||||
|
||||
import '../ui/views/app_selector/app_selector_view.dart' as _i3;
|
||||
import '../ui/views/home/home_view.dart' as _i2;
|
||||
import '../ui/views/patcher/patcher_view.dart' as _i4;
|
||||
|
||||
class Routes {
|
||||
static const homeView = '/home-view';
|
||||
|
||||
static const appSelectorView = '/app-selector-view';
|
||||
|
||||
static const patcherView = '/patcher-view';
|
||||
|
||||
static const all = <String>{homeView, appSelectorView, patcherView};
|
||||
}
|
||||
|
||||
class StackedRouter extends _i1.RouterBase {
|
||||
final _routes = <_i1.RouteDef>[
|
||||
_i1.RouteDef(Routes.homeView, page: _i2.HomeView),
|
||||
_i1.RouteDef(Routes.appSelectorView, page: _i3.AppSelectorView),
|
||||
_i1.RouteDef(Routes.patcherView, page: _i4.PatcherView)
|
||||
];
|
||||
|
||||
final _pagesMap = <Type, _i1.StackedRouteFactory>{
|
||||
_i2.HomeView: (data) {
|
||||
return MaterialPageRoute<dynamic>(
|
||||
builder: (context) => const _i2.HomeView(),
|
||||
settings: data,
|
||||
);
|
||||
},
|
||||
_i3.AppSelectorView: (data) {
|
||||
return MaterialPageRoute<dynamic>(
|
||||
builder: (context) => const _i3.AppSelectorView(),
|
||||
settings: data,
|
||||
);
|
||||
},
|
||||
_i4.PatcherView: (data) {
|
||||
return MaterialPageRoute<dynamic>(
|
||||
builder: (context) => const _i4.PatcherView(),
|
||||
settings: data,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@override
|
||||
List<_i1.RouteDef> get routes => _routes;
|
||||
@override
|
||||
Map<Type, _i1.StackedRouteFactory> get pagesMap => _pagesMap;
|
||||
}
|
||||
|
||||
extension NavigatorStateExtension on _i5.NavigationService {
|
||||
Future<dynamic> navigateToHomeView(
|
||||
[int? routerId,
|
||||
bool preventDuplicates = true,
|
||||
Map<String, String>? parameters,
|
||||
Widget Function(
|
||||
BuildContext, Animation<double>, Animation<double>, Widget)?
|
||||
transition]) async {
|
||||
navigateTo(Routes.homeView,
|
||||
id: routerId,
|
||||
preventDuplicates: preventDuplicates,
|
||||
parameters: parameters,
|
||||
transition: transition);
|
||||
}
|
||||
|
||||
Future<dynamic> navigateToAppSelectorView(
|
||||
[int? routerId,
|
||||
bool preventDuplicates = true,
|
||||
Map<String, String>? parameters,
|
||||
Widget Function(
|
||||
BuildContext, Animation<double>, Animation<double>, Widget)?
|
||||
transition]) async {
|
||||
navigateTo(Routes.appSelectorView,
|
||||
id: routerId,
|
||||
preventDuplicates: preventDuplicates,
|
||||
parameters: parameters,
|
||||
transition: transition);
|
||||
}
|
||||
|
||||
Future<dynamic> navigateToPatcherView(
|
||||
[int? routerId,
|
||||
bool preventDuplicates = true,
|
||||
Map<String, String>? parameters,
|
||||
Widget Function(
|
||||
BuildContext, Animation<double>, Animation<double>, Widget)?
|
||||
transition]) async {
|
||||
navigateTo(Routes.patcherView,
|
||||
id: routerId,
|
||||
preventDuplicates: preventDuplicates,
|
||||
parameters: parameters,
|
||||
transition: transition);
|
||||
}
|
||||
}
|
@ -1,9 +1,16 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:revanced_manager_flutter/app/app.locator.dart';
|
||||
import 'package:revanced_manager_flutter/app/app.router.dart';
|
||||
import 'package:revanced_manager_flutter/main_viewmodel.dart';
|
||||
import 'package:revanced_manager_flutter/theme.dart';
|
||||
import 'package:revanced_manager_flutter/ui/screens/home_screen.dart';
|
||||
import 'package:revanced_manager_flutter/ui/screens/patcher_screen.dart';
|
||||
import 'package:revanced_manager_flutter/ui/views/home/home_view.dart';
|
||||
import 'package:revanced_manager_flutter/ui/views/patcher/patcher_view.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
|
||||
void main() {
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
setupLocator();
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
@ -17,47 +24,47 @@ class MyApp extends StatelessWidget {
|
||||
title: 'ReVanced Manager',
|
||||
theme: lightTheme,
|
||||
darkTheme: darkTheme,
|
||||
navigatorKey: StackedService.navigatorKey,
|
||||
onGenerateRoute: StackedRouter().onGenerateRoute,
|
||||
home: const Navigation(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Navigation extends StatefulWidget {
|
||||
class Navigation extends StatelessWidget {
|
||||
const Navigation({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<Navigation> createState() => _NavigationState();
|
||||
}
|
||||
|
||||
class _NavigationState extends State<Navigation> {
|
||||
int currentPageIndex = 0;
|
||||
final List<Widget> screens = [
|
||||
const HomeScreen(),
|
||||
const PatcherScreen(),
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: screens[currentPageIndex],
|
||||
bottomNavigationBar: NavigationBar(
|
||||
onDestinationSelected: (int index) {
|
||||
setState(() {
|
||||
currentPageIndex = index;
|
||||
});
|
||||
},
|
||||
selectedIndex: currentPageIndex,
|
||||
destinations: const <Widget>[
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.dashboard),
|
||||
label: "Dashboard",
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.build),
|
||||
label: "Patcher",
|
||||
),
|
||||
],
|
||||
return ViewModelBuilder<MainViewModel>.reactive(
|
||||
viewModelBuilder: () => MainViewModel(),
|
||||
builder: (context,MainViewModel model, child) => Scaffold(
|
||||
body: getViewForIndex(model.currentIndex),
|
||||
bottomNavigationBar: NavigationBar(
|
||||
onDestinationSelected: model.setIndex,
|
||||
selectedIndex: model.currentIndex,
|
||||
destinations: const <Widget>[
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.dashboard),
|
||||
label: "Dashboard",
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.build),
|
||||
label: "Patcher",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
Widget getViewForIndex(int index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return const HomeView();
|
||||
case 1:
|
||||
return const PatcherView();
|
||||
default:
|
||||
return const HomeView();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
6
lib/main_viewmodel.dart
Normal file
6
lib/main_viewmodel.dart
Normal file
@ -0,0 +1,6 @@
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
class MainViewModel extends IndexTrackingViewModel {
|
||||
|
||||
|
||||
}
|
@ -1,17 +1,14 @@
|
||||
import 'package:github/github.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
@lazySingleton
|
||||
class GithubAPI {
|
||||
var github = GitHub();
|
||||
|
||||
Future<String?> latestRelease(String org, repoName) async {
|
||||
var latestRelease = await github.repositories
|
||||
.getLatestRelease(RepositorySlug(org, repoName));
|
||||
var dlurl = latestRelease.assets
|
||||
?.firstWhere((element) =>
|
||||
element.browserDownloadUrl!.contains(".jar") ||
|
||||
element.browserDownloadUrl!.contains(".apk"))
|
||||
.browserDownloadUrl;
|
||||
print(dlurl);
|
||||
var dlurl = latestRelease.assets?.first.browserDownloadUrl;
|
||||
return dlurl;
|
||||
}
|
||||
|
||||
@ -27,15 +24,12 @@ class GithubAPI {
|
||||
|
||||
if (hours > 24) {
|
||||
var days = (commitTime.inDays).abs().toString();
|
||||
print("$days days");
|
||||
return "$days days";
|
||||
} else if (hours > 1 && hours < 24) {
|
||||
var hours = (commitTime.inHours).abs().toString();
|
||||
print("$hours hours");
|
||||
return "$hours hours";
|
||||
} else {
|
||||
var minutes = (commitTime.inMinutes).abs().toString();
|
||||
print("$minutes minutes");
|
||||
return "$minutes mins";
|
||||
}
|
||||
}
|
||||
@ -43,17 +37,7 @@ class GithubAPI {
|
||||
Future contributors(String org, repoName) async {
|
||||
var contributors =
|
||||
github.repositories.listContributors(RepositorySlug(org, repoName));
|
||||
contributors.forEach((contributor) {
|
||||
print(contributor.login);
|
||||
print(contributor.avatarUrl);
|
||||
});
|
||||
contributors.forEach((contributor) {});
|
||||
return contributors;
|
||||
}
|
||||
}
|
||||
|
||||
void main(List<String> args) {
|
||||
GithubAPI githubAPI = GithubAPI();
|
||||
githubAPI.latestRelease('revanced', 'revanced-patches');
|
||||
// githubAPI.latestCommitTime("revanced", "revanced-patches");
|
||||
// githubAPI.contributors("revanced", "revanced-manager");
|
||||
}
|
@ -1,11 +1,12 @@
|
||||
import 'dart:io';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import 'package:path_provider/path_provider.dart' as p;
|
||||
import 'package:revanced_manager_flutter/constants.dart';
|
||||
import 'github_api.dart';
|
||||
|
||||
// use path_provider to get the path of the storage directory
|
||||
|
||||
@lazySingleton
|
||||
class ManagerAPI {
|
||||
Dio dio = Dio();
|
||||
GithubAPI githubAPI = GithubAPI();
|
12
lib/services/third_party_services_modules.dart
Normal file
12
lib/services/third_party_services_modules.dart
Normal file
@ -0,0 +1,12 @@
|
||||
import 'package:injectable/injectable.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
|
||||
@module
|
||||
abstract class ThirdPartyServicesModule {
|
||||
@lazySingleton
|
||||
NavigationService get navigationService;
|
||||
@lazySingleton
|
||||
DialogService get dialogService;
|
||||
@lazySingleton
|
||||
SnackbarService get snackbarService;
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
import 'package:device_apps/device_apps.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:revanced_manager_flutter/ui/widgets/installed_app_item.dart';
|
||||
import 'package:revanced_manager_flutter/ui/widgets/search_bar.dart';
|
||||
|
||||
class AppSelectorScreen extends StatefulWidget {
|
||||
const AppSelectorScreen({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AppSelectorScreen> createState() => _AppSelectorScreenState();
|
||||
}
|
||||
|
||||
class _AppSelectorScreenState extends State<AppSelectorScreen> {
|
||||
List<Application> apps = [];
|
||||
String query = '';
|
||||
|
||||
void getApps() async {
|
||||
apps = await DeviceApps.getInstalledApplications();
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
getApps();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 12.0),
|
||||
child: Column(
|
||||
children: [
|
||||
SearchBar(
|
||||
onQueryChanged: (searchQuery) {
|
||||
setState(() {
|
||||
query = searchQuery;
|
||||
});
|
||||
},
|
||||
),
|
||||
if (query.isEmpty || query.length < 2)
|
||||
apps.isEmpty
|
||||
? const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: apps.length,
|
||||
itemBuilder: (context, index) {
|
||||
//sort alphabetically
|
||||
apps.sort((a, b) => a.appName.compareTo(b.appName));
|
||||
return InstalledAppItem(
|
||||
name: apps[index].appName,
|
||||
pkgName: apps[index].packageName,
|
||||
isSelected: false,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
if (query.isNotEmpty)
|
||||
apps.isEmpty
|
||||
? const Center(
|
||||
child: Text('No apps found'),
|
||||
)
|
||||
: Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: apps.length,
|
||||
itemBuilder: (context, index) {
|
||||
apps.sort((a, b) => a.appName.compareTo(b.appName));
|
||||
if (apps[index].appName.toLowerCase().contains(
|
||||
query.toLowerCase(),
|
||||
)) {
|
||||
return InstalledAppItem(
|
||||
name: apps[index].appName,
|
||||
pkgName: apps[index].packageName,
|
||||
isSelected: false,
|
||||
);
|
||||
} else {
|
||||
return SizedBox();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:revanced_manager_flutter/ui/widgets/available_updates_card.dart';
|
||||
import 'package:revanced_manager_flutter/ui/widgets/installed_apps_card.dart';
|
||||
import 'package:revanced_manager_flutter/ui/widgets/latest_commit_card.dart';
|
||||
|
||||
class HomeScreen extends StatelessWidget {
|
||||
const HomeScreen({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 0.0,
|
||||
horizontal: 20.0,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.topRight,
|
||||
child: IconButton(
|
||||
onPressed: () {},
|
||||
icon: const Icon(
|
||||
Icons.more_vert,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 60),
|
||||
Text(
|
||||
"Dashboard",
|
||||
style: GoogleFonts.inter(
|
||||
fontSize: 28,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 23),
|
||||
Text(
|
||||
"ReVanced Updates",
|
||||
style: GoogleFonts.inter(
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const LatestCommitCard(),
|
||||
const SizedBox(height: 14),
|
||||
Text(
|
||||
"Patched Applications",
|
||||
style: GoogleFonts.inter(
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
const AvailableUpdatesCard(),
|
||||
const SizedBox(height: 15),
|
||||
const InstalledAppsCard(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:revanced_manager_flutter/ui/screens/app_selector_screen.dart';
|
||||
import 'package:revanced_manager_flutter/ui/widgets/app_selector_card.dart';
|
||||
import 'package:revanced_manager_flutter/ui/widgets/patch_selector_card.dart';
|
||||
|
||||
class PatcherScreen extends StatelessWidget {
|
||||
const PatcherScreen({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () {},
|
||||
child: const Icon(
|
||||
Icons.build,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 12.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
"Patcher",
|
||||
style: GoogleFonts.inter(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 23),
|
||||
AppSelectorCard(
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const AppSelectorScreen()));
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const PatchSelectorCard(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
101
lib/ui/views/app_selector/app_selector_view.dart
Normal file
101
lib/ui/views/app_selector/app_selector_view.dart
Normal file
@ -0,0 +1,101 @@
|
||||
import 'package:device_apps/device_apps.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:revanced_manager_flutter/ui/widgets/installed_app_item.dart';
|
||||
import 'package:revanced_manager_flutter/ui/widgets/search_bar.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import 'app_selector_viewmodel.dart';
|
||||
|
||||
class AppSelectorView extends StatefulWidget {
|
||||
const AppSelectorView({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AppSelectorView> createState() => _AppSelectorViewState();
|
||||
}
|
||||
|
||||
class _AppSelectorViewState extends State<AppSelectorView> {
|
||||
List<Application> apps = [];
|
||||
String query = '';
|
||||
|
||||
void getApps() async {
|
||||
apps = await DeviceApps.getInstalledApplications();
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
getApps();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder.reactive(
|
||||
builder: (context, model, child) => Scaffold(
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 4.0, horizontal: 12.0),
|
||||
child: Column(
|
||||
children: [
|
||||
SearchBar(
|
||||
onQueryChanged: (searchQuery) {
|
||||
setState(() {
|
||||
query = searchQuery;
|
||||
});
|
||||
},
|
||||
),
|
||||
if (query.isEmpty || query.length < 2)
|
||||
apps.isEmpty
|
||||
? const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: apps.length,
|
||||
itemBuilder: (context, index) {
|
||||
//sort alphabetically
|
||||
apps.sort(
|
||||
(a, b) => a.appName.compareTo(b.appName));
|
||||
return InstalledAppItem(
|
||||
name: apps[index].appName,
|
||||
pkgName: apps[index].packageName,
|
||||
isSelected: false,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
if (query.isNotEmpty)
|
||||
apps.isEmpty
|
||||
? const Center(
|
||||
child: Text('No apps found'),
|
||||
)
|
||||
: Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: apps.length,
|
||||
itemBuilder: (context, index) {
|
||||
apps.sort(
|
||||
(a, b) => a.appName.compareTo(b.appName));
|
||||
if (apps[index].appName.toLowerCase().contains(
|
||||
query.toLowerCase(),
|
||||
)) {
|
||||
return InstalledAppItem(
|
||||
name: apps[index].appName,
|
||||
pkgName: apps[index].packageName,
|
||||
isSelected: false,
|
||||
);
|
||||
} else {
|
||||
return SizedBox();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
viewModelBuilder: () => AppSelectorViewModel(),
|
||||
);
|
||||
}
|
||||
}
|
15
lib/ui/views/app_selector/app_selector_viewmodel.dart
Normal file
15
lib/ui/views/app_selector/app_selector_viewmodel.dart
Normal file
@ -0,0 +1,15 @@
|
||||
import 'package:device_apps/device_apps.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
class AppSelectorViewModel extends BaseViewModel {
|
||||
List<Application> apps = [];
|
||||
String query = '';
|
||||
|
||||
void initialization() {
|
||||
getApps();
|
||||
}
|
||||
|
||||
void getApps() async {
|
||||
apps = await DeviceApps.getInstalledApplications();
|
||||
}
|
||||
}
|
71
lib/ui/views/home/home_view.dart
Normal file
71
lib/ui/views/home/home_view.dart
Normal file
@ -0,0 +1,71 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:revanced_manager_flutter/ui/widgets/available_updates_card.dart';
|
||||
import 'package:revanced_manager_flutter/ui/widgets/installed_apps_card.dart';
|
||||
import 'package:revanced_manager_flutter/ui/widgets/latest_commit_card.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'home_viewmodel.dart';
|
||||
|
||||
class HomeView extends StatelessWidget {
|
||||
const HomeView({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder.reactive(
|
||||
builder: (context, model, child) => Scaffold(
|
||||
body: SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 0.0,
|
||||
horizontal: 20.0,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.topRight,
|
||||
child: IconButton(
|
||||
onPressed: () {},
|
||||
icon: const Icon(
|
||||
Icons.more_vert,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 60),
|
||||
Text(
|
||||
"Dashboard",
|
||||
style: GoogleFonts.inter(
|
||||
fontSize: 28,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 23),
|
||||
Text(
|
||||
"ReVanced Updates",
|
||||
style: GoogleFonts.inter(
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const LatestCommitCard(),
|
||||
const SizedBox(height: 14),
|
||||
Text(
|
||||
"Patched Applications",
|
||||
style: GoogleFonts.inter(
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
const AvailableUpdatesCard(),
|
||||
const SizedBox(height: 15),
|
||||
const InstalledAppsCard(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
viewModelBuilder: () => HomeViewModel(),
|
||||
);
|
||||
}
|
||||
}
|
8
lib/ui/views/home/home_viewmodel.dart
Normal file
8
lib/ui/views/home/home_viewmodel.dart
Normal file
@ -0,0 +1,8 @@
|
||||
import 'package:revanced_manager_flutter/app/app.locator.dart';
|
||||
import 'package:revanced_manager_flutter/services/manager_api.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
class HomeViewModel extends BaseViewModel {
|
||||
Future downloadPatches() => locator<ManagerAPI>().downloadPatches();
|
||||
Future downloadIntegrations() => locator<ManagerAPI>().downloadIntegrations();
|
||||
}
|
53
lib/ui/views/patcher/patcher_view.dart
Normal file
53
lib/ui/views/patcher/patcher_view.dart
Normal file
@ -0,0 +1,53 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:revanced_manager_flutter/ui/views/app_selector/app_selector_view.dart';
|
||||
import 'package:revanced_manager_flutter/ui/widgets/app_selector_card.dart';
|
||||
import 'package:revanced_manager_flutter/ui/widgets/patch_selector_card.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import 'patcher_viewmodel.dart';
|
||||
|
||||
class PatcherView extends StatelessWidget {
|
||||
const PatcherView({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder.reactive(
|
||||
builder: (context, PatcherViewModel model, child) => Scaffold(
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () {},
|
||||
child: const Icon(
|
||||
Icons.build,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 12.0, horizontal: 12.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
"Patcher",
|
||||
style: GoogleFonts.inter(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 23),
|
||||
AppSelectorCard(
|
||||
onPressed: model.navigateToAppSelector,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const PatchSelectorCard(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
viewModelBuilder: () => PatcherViewModel(),
|
||||
);
|
||||
}
|
||||
}
|
12
lib/ui/views/patcher/patcher_viewmodel.dart
Normal file
12
lib/ui/views/patcher/patcher_viewmodel.dart
Normal file
@ -0,0 +1,12 @@
|
||||
import 'package:revanced_manager_flutter/app/app.locator.dart';
|
||||
import 'package:revanced_manager_flutter/app/app.router.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
|
||||
class PatcherViewModel extends BaseViewModel {
|
||||
final _naviagtionService = locator<NavigationService>();
|
||||
|
||||
void navigateToAppSelector() {
|
||||
_naviagtionService.navigateTo(Routes.appSelectorView);
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:revanced_manager_flutter/backend/api/github_api.dart';
|
||||
import 'package:revanced_manager_flutter/services/github_api.dart';
|
||||
import 'package:revanced_manager_flutter/constants.dart';
|
||||
import 'package:revanced_manager_flutter/ui/widgets/patch_text_button.dart';
|
||||
|
||||
|
Reference in New Issue
Block a user