forked from firka/student-legacy
theme sharing improvements
This commit is contained in:
parent
84537fdcef
commit
a319b26d82
@ -19,11 +19,13 @@ class ShareProvider extends ChangeNotifier {
|
||||
// }
|
||||
|
||||
// themes
|
||||
Future<SharedTheme> shareCurrentTheme(BuildContext context,
|
||||
{bool isPublic = false,
|
||||
bool shareNick = true,
|
||||
required SharedGradeColors gradeColors,
|
||||
String displayName = ''}) async {
|
||||
Future<SharedTheme> shareCurrentTheme(
|
||||
BuildContext context, {
|
||||
bool isPublic = false,
|
||||
bool shareNick = true,
|
||||
required SharedGradeColors gradeColors,
|
||||
String displayName = '',
|
||||
}) async {
|
||||
final SettingsProvider settings =
|
||||
Provider.of<SettingsProvider>(context, listen: false);
|
||||
|
||||
|
@ -16,6 +16,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:refilc_mobile_ui/screens/settings/settings_screen.i18n.dart';
|
||||
import 'package:refilc_mobile_ui/screens/settings/submenu/share_theme_popup.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
class MenuPaintList extends StatelessWidget {
|
||||
@ -251,18 +252,7 @@ class PaintListScreenState extends State<PaintListScreen>
|
||||
subject: 'share_subj_theme'.i18n,
|
||||
);
|
||||
} else {
|
||||
SharedGradeColors gradeColors = await shareProvider
|
||||
.shareCurrentGradeColors(context);
|
||||
SharedTheme theme =
|
||||
await shareProvider.shareCurrentTheme(
|
||||
context,
|
||||
gradeColors: gradeColors,
|
||||
);
|
||||
|
||||
Share.share(
|
||||
theme.id,
|
||||
subject: 'share_subj_theme'.i18n,
|
||||
);
|
||||
ShareThemeDialog.show(context);
|
||||
}
|
||||
},
|
||||
longPressInstead: true,
|
||||
|
@ -0,0 +1,160 @@
|
||||
// ignore_for_file: use_build_context_synchronously, deprecated_member_use
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
// import 'package:refilc/models/settings.dart';
|
||||
import 'package:refilc/models/shared_theme.dart';
|
||||
import 'package:refilc_kreta_api/providers/share_provider.dart';
|
||||
import 'package:refilc_mobile_ui/common/action_button.dart';
|
||||
import 'package:refilc_mobile_ui/common/splitted_panel/splitted_panel.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
import 'submenu_screen.i18n.dart';
|
||||
|
||||
class ShareThemeDialog extends StatefulWidget {
|
||||
const ShareThemeDialog({super.key});
|
||||
|
||||
static void show(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
shape:
|
||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)),
|
||||
title: Text("attention".i18n),
|
||||
content: Text("share_disclaimer".i18n),
|
||||
actions: [
|
||||
ActionButton(
|
||||
label: "understand".i18n,
|
||||
onTap: () async {
|
||||
Navigator.of(context).pop();
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => const ShareThemeDialog());
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
ShareThemeDialogState createState() => ShareThemeDialogState();
|
||||
}
|
||||
|
||||
class ShareThemeDialogState extends State<ShareThemeDialog> {
|
||||
final _title = TextEditingController();
|
||||
bool isPublic = false;
|
||||
|
||||
late ShareProvider shareProvider;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
shareProvider = Provider.of<ShareProvider>(context, listen: false);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(14.0))),
|
||||
contentPadding: const EdgeInsets.only(top: 10.0),
|
||||
title: Text("share_theme".i18n),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 12.0, horizontal: 24.0),
|
||||
child: TextField(
|
||||
controller: _title,
|
||||
onEditingComplete: () async {},
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(
|
||||
borderSide: const BorderSide(color: Colors.grey, width: 1.5),
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: const BorderSide(color: Colors.grey, width: 1.5),
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
),
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 12.0),
|
||||
hintText: 'paint_title'.i18n,
|
||||
suffixIcon: IconButton(
|
||||
icon: const Icon(
|
||||
FeatherIcons.x,
|
||||
color: Colors.grey,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_title.text = '';
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SplittedPanel(
|
||||
children: [
|
||||
SwitchListTile(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16.0),
|
||||
),
|
||||
value: isPublic,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
isPublic = value;
|
||||
});
|
||||
},
|
||||
title: Text("is_public".i18n),
|
||||
contentPadding: const EdgeInsets.only(left: 15.0, right: 10.0),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text(
|
||||
"cancel".i18n,
|
||||
style: const TextStyle(fontWeight: FontWeight.w500),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).maybePop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: Text(
|
||||
"share_it".i18n,
|
||||
style: const TextStyle(fontWeight: FontWeight.w500),
|
||||
),
|
||||
onPressed: () async {
|
||||
// share the fucking theme
|
||||
SharedGradeColors gradeColors =
|
||||
await shareProvider.shareCurrentGradeColors(context);
|
||||
SharedTheme theme = await shareProvider.shareCurrentTheme(
|
||||
context,
|
||||
gradeColors: gradeColors,
|
||||
isPublic: isPublic,
|
||||
displayName: _title.text,
|
||||
);
|
||||
|
||||
// save theme id in settings
|
||||
// Provider.of<SettingsProvider>(context, listen: false)
|
||||
// .update(currentThemeId: theme.id);
|
||||
|
||||
// close this popup shit
|
||||
Navigator.of(context).pop(true);
|
||||
|
||||
// show the share popup
|
||||
Share.share(
|
||||
theme.id,
|
||||
subject: 'share_subj_theme'.i18n,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
@ -19,6 +19,15 @@ extension SettingsLocalization on String {
|
||||
"legendary": "Legendary",
|
||||
// grade colors
|
||||
"grade_colors": "Grade Colors",
|
||||
// theme share popup
|
||||
"share_theme": "Share Paint",
|
||||
"paint_title": "Paint title...",
|
||||
"share_it": "Share it!",
|
||||
"is_public": "Public Paint",
|
||||
"attention": "Attention!",
|
||||
"share_disclaimer":
|
||||
"By sharing the theme, you agree that the nickname you set and all settings of the theme will be shared publicly.",
|
||||
"understand": "I understand",
|
||||
},
|
||||
"hu_hu": {
|
||||
"general": "Általános",
|
||||
@ -36,6 +45,15 @@ extension SettingsLocalization on String {
|
||||
"legendary": "Legendás",
|
||||
// grade colors
|
||||
"grade_colors": "Jegyek színei",
|
||||
// theme share popup
|
||||
"share_theme": "Téma megosztása",
|
||||
"paint_title": "Téma neve...",
|
||||
"share_it": "Megosztás!",
|
||||
"is_public": "Nyilvános téma",
|
||||
"attention": "Figyelem!",
|
||||
"share_disclaimer":
|
||||
"A téma megosztásával elfogadod, hogy az általad beállított becenév és a téma minden beállítása nyilvánosan megosztásra kerüljön.",
|
||||
"understand": "Értem",
|
||||
},
|
||||
"de_de": {
|
||||
"general": "Allgemeine",
|
||||
@ -53,6 +71,15 @@ extension SettingsLocalization on String {
|
||||
"legendary": "Legendär",
|
||||
// grade colors
|
||||
"grade_colors": "Notenfarben",
|
||||
// theme share popup
|
||||
"share_theme": "Thema teilen",
|
||||
"paint_title": "Thema Titel...",
|
||||
"share_it": "Teilen!",
|
||||
"is_public": "Öffentliches Thema",
|
||||
"attention": "Achtung!",
|
||||
"share_disclaimer":
|
||||
"Durch das Teilen des Themes erklären Sie sich damit einverstanden, dass der von Ihnen festgelegte Spitzname und alle Einstellungen des Themes öffentlich geteilt werden.",
|
||||
"understand": "Ich verstehe",
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
// ignore_for_file: use_build_context_synchronously, deprecated_member_use
|
||||
|
||||
import 'package:refilc/models/settings.dart';
|
||||
import 'package:refilc/models/shared_theme.dart';
|
||||
// import 'package:refilc/models/shared_theme.dart';
|
||||
import 'package:refilc/theme/colors/accent.dart';
|
||||
import 'package:refilc/theme/colors/colors.dart';
|
||||
import 'package:refilc/theme/observer.dart';
|
||||
@ -10,7 +10,7 @@ import 'package:refilc/ui/widgets/message/message_tile.dart';
|
||||
import 'package:refilc_kreta_api/models/grade.dart';
|
||||
import 'package:refilc_kreta_api/models/homework.dart';
|
||||
import 'package:refilc_kreta_api/models/message.dart';
|
||||
import 'package:refilc_mobile_ui/common/action_button.dart';
|
||||
// import 'package:refilc_mobile_ui/common/action_button.dart';
|
||||
import 'package:refilc_mobile_ui/common/filter_bar.dart';
|
||||
import 'package:refilc_mobile_ui/common/panel/panel.dart';
|
||||
import 'package:refilc_mobile_ui/common/widgets/grade/new_grades.dart';
|
||||
@ -24,6 +24,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:refilc_mobile_ui/screens/settings/submenu/share_theme_popup.dart';
|
||||
import 'theme_screen.i18n.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
@ -304,40 +305,48 @@ class _PremiumCustomAccentColorSettingState
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => WillPopScope(
|
||||
onWillPop: () async => false,
|
||||
child: AlertDialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12.0)),
|
||||
title: Text("attention".i18n),
|
||||
content: Text("share_disclaimer".i18n),
|
||||
actions: [
|
||||
ActionButton(
|
||||
label: "understand".i18n,
|
||||
onTap: () async {
|
||||
Navigator.of(context).pop();
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (context) => WillPopScope(
|
||||
// onWillPop: () async => false,
|
||||
// child: AlertDialog(
|
||||
// shape: RoundedRectangleBorder(
|
||||
// borderRadius: BorderRadius.circular(12.0)),
|
||||
// title: Text("attention".i18n),
|
||||
// content: Text("share_disclaimer".i18n),
|
||||
// actions: [
|
||||
// ActionButton(
|
||||
// label: "understand".i18n,
|
||||
// onTap: () async {
|
||||
// Navigator.of(context).pop();
|
||||
|
||||
SharedGradeColors gradeColors =
|
||||
await shareProvider
|
||||
.shareCurrentGradeColors(context);
|
||||
SharedTheme theme =
|
||||
await shareProvider.shareCurrentTheme(
|
||||
context,
|
||||
gradeColors: gradeColors,
|
||||
);
|
||||
// SharedGradeColors gradeColors =
|
||||
// await shareProvider
|
||||
// .shareCurrentGradeColors(context);
|
||||
// SharedTheme theme =
|
||||
// await shareProvider.shareCurrentTheme(
|
||||
// context,
|
||||
// gradeColors: gradeColors,
|
||||
// );
|
||||
|
||||
Share.share(
|
||||
theme.id,
|
||||
subject: 'share_subj_theme'.i18n,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
// Share.share(
|
||||
// theme.id,
|
||||
// subject: 'share_subj_theme'.i18n,
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
if (settings.currentThemeId != '') {
|
||||
Share.share(
|
||||
settings.currentThemeId,
|
||||
subject: 'share_subj_theme'.i18n,
|
||||
);
|
||||
} else {
|
||||
ShareThemeDialog.show(context);
|
||||
}
|
||||
},
|
||||
icon: const Icon(
|
||||
FeatherIcons.share2,
|
||||
|
Loading…
x
Reference in New Issue
Block a user