2022-08-06 14:13:28 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2022-08-08 00:40:48 +02:00
|
|
|
import 'package:flutter_i18n/flutter_i18n.dart';
|
2022-08-21 12:47:44 +02:00
|
|
|
import 'package:revanced_manager/ui/widgets/appSelectorView/installed_app_item.dart';
|
|
|
|
import 'package:revanced_manager/ui/widgets/shared/search_bar.dart';
|
2022-09-02 19:12:16 +02:00
|
|
|
import 'package:revanced_manager/ui/widgets/appSelectorView/app_skeleton_loader.dart';
|
|
|
|
import 'package:stacked/stacked.dart' hide SkeletonLoader;
|
2022-08-07 02:13:27 +02:00
|
|
|
import 'package:revanced_manager/ui/views/app_selector/app_selector_viewmodel.dart';
|
2022-08-06 14:13:28 +02:00
|
|
|
|
|
|
|
class AppSelectorView extends StatefulWidget {
|
|
|
|
const AppSelectorView({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<AppSelectorView> createState() => _AppSelectorViewState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _AppSelectorViewState extends State<AppSelectorView> {
|
2022-08-18 16:33:33 +02:00
|
|
|
String _query = '';
|
2022-08-06 14:13:28 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-08-09 01:01:06 +02:00
|
|
|
return ViewModelBuilder<AppSelectorViewModel>.reactive(
|
2022-08-13 11:56:30 +02:00
|
|
|
onModelReady: (model) => model.initialize(),
|
2022-08-18 16:33:33 +02:00
|
|
|
viewModelBuilder: () => AppSelectorViewModel(),
|
2022-08-06 14:13:28 +02:00
|
|
|
builder: (context, model, child) => Scaffold(
|
2022-09-08 13:57:51 +02:00
|
|
|
resizeToAvoidBottomInset: false,
|
2022-08-13 11:56:30 +02:00
|
|
|
floatingActionButton: FloatingActionButton.extended(
|
2022-08-31 10:32:10 +02:00
|
|
|
label: I18nText('appSelectorView.storageButton'),
|
|
|
|
icon: const Icon(Icons.sd_storage),
|
2022-08-13 11:56:30 +02:00
|
|
|
onPressed: () {
|
|
|
|
model.selectAppFromStorage(context);
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
|
|
|
),
|
2022-08-06 14:13:28 +02:00
|
|
|
body: SafeArea(
|
|
|
|
child: Padding(
|
|
|
|
padding:
|
|
|
|
const EdgeInsets.symmetric(vertical: 4.0, horizontal: 12.0),
|
2022-09-12 01:36:18 +02:00
|
|
|
child: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
SearchBar(
|
|
|
|
showSelectIcon: false,
|
|
|
|
hintText: FlutterI18n.translate(
|
|
|
|
context,
|
|
|
|
'appSelectorView.searchBarHint',
|
|
|
|
),
|
|
|
|
onQueryChanged: (searchQuery) {
|
|
|
|
setState(() {
|
|
|
|
_query = searchQuery;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
),
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
Expanded(
|
|
|
|
child: model.noApps
|
|
|
|
? Center(
|
|
|
|
child: I18nText('appSelectorCard.noAppsLabel'),
|
|
|
|
)
|
|
|
|
: model.apps.isEmpty
|
|
|
|
? const AppSkeletonLoader()
|
|
|
|
: ListView(
|
2022-09-01 02:25:19 +02:00
|
|
|
padding: const EdgeInsets.only(bottom: 80),
|
2022-08-24 17:07:40 +02:00
|
|
|
children: model
|
|
|
|
.getFilteredApps(_query)
|
|
|
|
.map((app) => InkWell(
|
|
|
|
onTap: () {
|
|
|
|
model.selectApp(app);
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
|
|
|
child: InstalledAppItem(
|
|
|
|
name: app.appName,
|
|
|
|
pkgName: app.packageName,
|
|
|
|
icon: app.icon,
|
|
|
|
),
|
|
|
|
))
|
|
|
|
.toList(),
|
|
|
|
),
|
2022-09-12 01:36:18 +02:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-08-06 14:13:28 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2022-08-09 02:16:33 +02:00
|
|
|
);
|
|
|
|
}
|
2022-08-06 14:13:28 +02:00
|
|
|
}
|