changed everything from filcnaplo to refilc finally

This commit is contained in:
Kima
2024-02-24 20:12:25 +01:00
parent 0d1c7b7143
commit 1171e3aaaf
655 changed files with 38728 additions and 44967 deletions

View File

@@ -0,0 +1,32 @@
import 'package:refilc/models/release.dart';
import 'package:flutter/material.dart';
import 'package:refilc_mobile_ui/common/panel/panel_button.dart';
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
import 'update_tile.i18n.dart';
class UpdateTile extends StatelessWidget {
const UpdateTile(this.release, {super.key, this.onTap, this.padding});
final Release release;
final Function()? onTap;
final EdgeInsetsGeometry? padding;
@override
Widget build(BuildContext context) {
return Padding(
padding: padding ?? const EdgeInsets.symmetric(horizontal: 8.0),
child: PanelButton(
onPressed: onTap,
title: Text("update_available".i18n),
leading: const Icon(FeatherIcons.download),
trailing: Text(
release.tag,
style: TextStyle(
fontWeight: FontWeight.w500,
color: Theme.of(context).colorScheme.secondary,
),
),
),
);
}
}

View File

@@ -0,0 +1,21 @@
import 'package:i18n_extension/i18n_extension.dart';
extension Localization on String {
static final _t = Translations.byLocale("hu_hu") +
{
"en_en": {
"update_available": "Update Available",
},
"hu_hu": {
"update_available": "Frissítés elérhető",
},
"de_de": {
"update_available": "Update verfügbar",
},
};
String get i18n => localize(this, _t);
String fill(List<Object> params) => localizeFill(this, params);
String plural(int value) => localizePlural(value, this, _t);
String version(Object modifier) => localizeVersion(modifier, this, _t);
}

View File

@@ -0,0 +1,18 @@
import 'package:refilc/models/release.dart';
import 'package:refilc_mobile_ui/common/widgets/update/update_tile.dart';
import 'package:refilc_mobile_ui/common/widgets/update/updates_view.dart';
import 'package:flutter/material.dart';
class UpdateViewable extends StatelessWidget {
const UpdateViewable(this.release, {super.key});
final Release release;
@override
Widget build(BuildContext context) {
return UpdateTile(
release,
onTap: () => UpdateView.show(release, context: context),
);
}
}

View File

@@ -0,0 +1,183 @@
import 'package:refilc/api/providers/status_provider.dart';
import 'package:refilc/models/release.dart';
import 'package:refilc/theme/colors/colors.dart';
import 'package:refilc/utils/color.dart';
import 'package:refilc_mobile_ui/common/bottom_card.dart';
import 'package:refilc_mobile_ui/common/custom_snack_bar.dart';
import 'package:refilc_mobile_ui/common/material_action_button.dart';
import 'package:refilc/helpers/update_helper.dart';
import 'package:flutter/material.dart';
import 'package:flutter_custom_tabs/flutter_custom_tabs.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:provider/provider.dart';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'updates_view.i18n.dart';
class UpdateView extends StatefulWidget {
const UpdateView(this.release, {super.key});
final Release release;
static void show(Release release, {required BuildContext context}) =>
showBottomCard(context: context, child: UpdateView(release));
@override
UpdateViewState createState() => UpdateViewState();
}
class UpdateViewState extends State<UpdateView> {
double progress = 0.0;
UpdateState state = UpdateState.none;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"new_update".i18n,
style: const TextStyle(
fontWeight: FontWeight.w700, fontSize: 18.0),
),
Text(
"${widget.release.version}",
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 16.0,
color: AppColors.of(context).text.withOpacity(0.6),
),
),
],
),
ClipRRect(
borderRadius: BorderRadius.circular(18.0),
child: Image.asset(
"assets/icons/ic_launcher.png",
width: 64.0,
),
)
],
),
),
// Description
Container(
margin: const EdgeInsets.only(top: 8.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.0),
),
child: SizedBox(
height: 200.0,
child: Markdown(
padding: const EdgeInsets.symmetric(horizontal: 12.0),
physics: const BouncingScrollPhysics(),
data: widget.release.body,
onTapLink: (text, href, title) => launch(href ?? ""),
),
),
),
// Download button
Center(
child: MaterialActionButton(
backgroundColor: AppColors.of(context).filc,
onPressed:
state == UpdateState.none ? () => downloadPrecheck() : null,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (state == UpdateState.downloading ||
state == UpdateState.preparing)
Container(
height: 18.0,
width: 18.0,
margin: const EdgeInsets.only(right: 8.0),
child: CircularProgressIndicator(
value: progress > 0.05 ? progress : null,
color: ColorUtils.foregroundColor(
AppColors.of(context).filc),
),
),
Text([
"download".i18n,
"downloading".i18n,
"downloading".i18n,
"installing".i18n
][state.index]
.toUpperCase()),
],
),
),
),
],
),
);
}
String fmtSize() =>
"${(widget.release.downloads.first.size / 1024 / 1024).toStringAsFixed(1)} MB";
void downloadPrecheck() {
final status = Provider.of<StatusProvider>(context, listen: false);
if (status.networkType == ConnectivityResult.mobile) {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text("mobileAlertTitle".i18n),
content: Text("mobileAlertDesc".i18n.fill([fmtSize()])),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop(false);
},
child: Text("no".i18n),
),
TextButton(
onPressed: () {
Navigator.of(context).pop(true);
},
child: Text("yes".i18n),
),
],
),
).then((value) => value ? download() : null);
} else {
download();
}
}
void download() {
widget.release
.install(updateCallback: (p, s) {
if (mounted) {
setState(() {
progress = p;
state = s;
});
}
})
.then((_) => Navigator.of(context).maybePop())
.catchError((error, stackTrace) {
if (mounted) {
Navigator.of(context).maybePop();
ScaffoldMessenger.of(context).showSnackBar(CustomSnackBar(
context: context,
content: Text("error".i18n),
backgroundColor: AppColors.of(context).red,
));
setState(() => state = UpdateState.none);
}
return true;
});
}
}

View File

@@ -0,0 +1,46 @@
import 'package:i18n_extension/i18n_extension.dart';
extension Localization on String {
static final _t = Translations.byLocale("hu_hu") +
{
"en_en": {
"new_update": "New Update",
"download": "download",
"downloading": "downloading",
"installing": "installing",
"error": "Failed to install update!",
"no": "No",
"yes": "Yes",
"mobileAlertTitle": "Hold up!",
"mobileAlertDesc": "You're on mobile network trying to download a %s update. Are you sure you want to continue?"
},
"hu_hu": {
"new_update": "Új frissítés",
"download": "Letöltés",
"downloading": "Letöltés",
"installing": "Telepítés",
"error": "Nem sikerült telepíteni a frissítést!",
"no": "Nem",
"yes": "Igen",
"mobileAlertTitle": "Figyelem!",
"mobileAlertDesc": "Jelenleg mobil interneten vagy, és egy %s méretű frissítést próbálsz letölteni. Biztosan folytatod?"
},
"de_de": {
"new_update": "Neues Update",
"download": "herunterladen",
"downloading": "Herunterladen",
"installing": "Installation",
"error": "Update konnte nicht installiert werden!",
"no": "Nein",
"yes": "Ja",
"mobileAlertTitle": "Achtung!",
"mobileAlertDesc":
"Sie befinden sich gerade im mobilen Internet und versuchen, ein %s Update herunterzuladen. Sind Sie sicher, dass Sie weitermachen wollen?"
},
};
String get i18n => localize(this, _t);
String fill(List<Object> params) => localizeFill(this, params);
String plural(int value) => localizePlural(value, this, _t);
String version(Object modifier) => localizeVersion(modifier, this, _t);
}