own paints and public paints thingie
This commit is contained in:
parent
8b91e0e1d3
commit
18892c6156
@ -270,6 +270,21 @@ class FilcAPI {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future<List?> getAllSharedThemes(int count) async {
|
||||||
|
try {
|
||||||
|
http.Response res = await http.get(Uri.parse(allThemes));
|
||||||
|
|
||||||
|
if (res.statusCode == 200) {
|
||||||
|
return (jsonDecode(res.body) as List);
|
||||||
|
} else {
|
||||||
|
throw "HTTP ${res.statusCode}: ${res.body}";
|
||||||
|
}
|
||||||
|
} on Exception catch (error, stacktrace) {
|
||||||
|
log("ERROR: FilcAPI.getAllSharedThemes: $error $stacktrace");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
static Future<void> addSharedGradeColors(
|
static Future<void> addSharedGradeColors(
|
||||||
SharedGradeColors gradeColors) async {
|
SharedGradeColors gradeColors) async {
|
||||||
try {
|
try {
|
||||||
|
@ -11,6 +11,7 @@ class SharedTheme {
|
|||||||
Color iconColor;
|
Color iconColor;
|
||||||
bool shadowEffect;
|
bool shadowEffect;
|
||||||
SharedGradeColors gradeColors;
|
SharedGradeColors gradeColors;
|
||||||
|
String displayName;
|
||||||
|
|
||||||
SharedTheme({
|
SharedTheme({
|
||||||
required this.json,
|
required this.json,
|
||||||
@ -23,6 +24,7 @@ class SharedTheme {
|
|||||||
required this.iconColor,
|
required this.iconColor,
|
||||||
required this.shadowEffect,
|
required this.shadowEffect,
|
||||||
required this.gradeColors,
|
required this.gradeColors,
|
||||||
|
this.displayName = 'displayName',
|
||||||
});
|
});
|
||||||
|
|
||||||
factory SharedTheme.fromJson(Map json, SharedGradeColors gradeColors) {
|
factory SharedTheme.fromJson(Map json, SharedGradeColors gradeColors) {
|
||||||
|
@ -71,6 +71,32 @@ class ShareProvider extends ChangeNotifier {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<List<SharedTheme>> getAllPublicThemes(BuildContext context,
|
||||||
|
{int count = 0}) async {
|
||||||
|
List? themesJson = await FilcAPI.getAllSharedThemes(count);
|
||||||
|
|
||||||
|
List<SharedTheme> themes = [];
|
||||||
|
|
||||||
|
if (themesJson != null) {
|
||||||
|
for (var t in themesJson) {
|
||||||
|
if (t['public_id'].toString().replaceAll(' ', '') == '') continue;
|
||||||
|
if (t['grade_colors_id'].toString().replaceAll(' ', '') == '') continue;
|
||||||
|
|
||||||
|
Map? gradeColorsJson =
|
||||||
|
await FilcAPI.getSharedGradeColors(t['grade_colors_id']);
|
||||||
|
|
||||||
|
if (gradeColorsJson != null) {
|
||||||
|
SharedTheme theme = SharedTheme.fromJson(
|
||||||
|
t, SharedGradeColors.fromJson(gradeColorsJson));
|
||||||
|
|
||||||
|
themes.add(theme);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return themes;
|
||||||
|
}
|
||||||
|
|
||||||
// grade colors
|
// grade colors
|
||||||
Future<SharedGradeColors> shareCurrentGradeColors(
|
Future<SharedGradeColors> shareCurrentGradeColors(
|
||||||
BuildContext context, {
|
BuildContext context, {
|
||||||
|
@ -14,6 +14,7 @@ class PanelButton extends StatelessWidget {
|
|||||||
this.background = false,
|
this.background = false,
|
||||||
this.trailingDivider = false,
|
this.trailingDivider = false,
|
||||||
this.borderRadius,
|
this.borderRadius,
|
||||||
|
this.longPressInstead = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
final void Function()? onPressed;
|
final void Function()? onPressed;
|
||||||
@ -24,11 +25,13 @@ class PanelButton extends StatelessWidget {
|
|||||||
final bool background;
|
final bool background;
|
||||||
final bool trailingDivider;
|
final bool trailingDivider;
|
||||||
final BorderRadius? borderRadius;
|
final BorderRadius? borderRadius;
|
||||||
|
final bool longPressInstead;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final button = RawMaterialButton(
|
final button = RawMaterialButton(
|
||||||
onPressed: onPressed,
|
onPressed: !longPressInstead ? onPressed : null,
|
||||||
|
onLongPress: longPressInstead ? onPressed : null,
|
||||||
padding: padding,
|
padding: padding,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: borderRadius ?? BorderRadius.circular(12.0)),
|
borderRadius: borderRadius ?? BorderRadius.circular(12.0)),
|
||||||
|
@ -39,6 +39,7 @@ import 'package:filcnaplo_mobile_ui/screens/settings/privacy_view.dart';
|
|||||||
import 'package:filcnaplo_mobile_ui/screens/settings/settings_helper.dart';
|
import 'package:filcnaplo_mobile_ui/screens/settings/settings_helper.dart';
|
||||||
import 'package:filcnaplo_mobile_ui/screens/settings/submenu/extras_screen.dart';
|
import 'package:filcnaplo_mobile_ui/screens/settings/submenu/extras_screen.dart';
|
||||||
import 'package:filcnaplo_mobile_ui/screens/settings/submenu/personalize_screen.dart';
|
import 'package:filcnaplo_mobile_ui/screens/settings/submenu/personalize_screen.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
// import 'package:refilc_plus/models/premium_scopes.dart';
|
// import 'package:refilc_plus/models/premium_scopes.dart';
|
||||||
import 'package:refilc_plus/providers/premium_provider.dart';
|
import 'package:refilc_plus/providers/premium_provider.dart';
|
||||||
// import 'package:refilc_plus/ui/mobile/premium/upsell.dart';
|
// import 'package:refilc_plus/ui/mobile/premium/upsell.dart';
|
||||||
@ -50,6 +51,7 @@ import 'package:flutter_custom_tabs/flutter_custom_tabs.dart' as tabs;
|
|||||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
import 'debug/subject_icon_gallery.dart';
|
||||||
import 'settings_screen.i18n.dart';
|
import 'settings_screen.i18n.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:filcnaplo_mobile_ui/screens/settings/user/nickname.dart';
|
import 'package:filcnaplo_mobile_ui/screens/settings/user/nickname.dart';
|
||||||
@ -732,18 +734,6 @@ class SettingsScreenState extends State<SettingsScreen>
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
// SplittedMenuOption(
|
|
||||||
// padding: const EdgeInsets.all(8.0),
|
|
||||||
// text: 'edit'.i18n,
|
|
||||||
// trailing: const Icon(
|
|
||||||
// FeatherIcons.edit2,
|
|
||||||
// size: 22.0,
|
|
||||||
// ),
|
|
||||||
// onTap: () {
|
|
||||||
// print('object');
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
),
|
),
|
||||||
// // general things
|
// // general things
|
||||||
// Padding(
|
// Padding(
|
||||||
@ -760,31 +750,31 @@ class SettingsScreenState extends State<SettingsScreen>
|
|||||||
// ),
|
// ),
|
||||||
|
|
||||||
// // icon gallery (debug mode)
|
// // icon gallery (debug mode)
|
||||||
// if (kDebugMode)
|
if (kDebugMode)
|
||||||
// Padding(
|
Padding(
|
||||||
// padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
// vertical: 12.0, horizontal: 24.0),
|
vertical: 12.0, horizontal: 24.0),
|
||||||
// child: Panel(
|
child: Panel(
|
||||||
// title: const Text("Debug"),
|
title: const Text("Debug"),
|
||||||
// child: Column(
|
child: Column(
|
||||||
// children: [
|
children: [
|
||||||
// PanelButton(
|
PanelButton(
|
||||||
// title: const Text("Subject Icon Gallery"),
|
title: const Text("Subject Icon Gallery"),
|
||||||
// leading:
|
leading:
|
||||||
// const Icon(CupertinoIcons.rectangle_3_offgrid_fill),
|
const Icon(CupertinoIcons.rectangle_3_offgrid_fill),
|
||||||
// trailing: const Icon(Icons.arrow_forward),
|
trailing: const Icon(Icons.arrow_forward),
|
||||||
// onPressed: () {
|
onPressed: () {
|
||||||
// Navigator.of(context, rootNavigator: true).push(
|
Navigator.of(context, rootNavigator: true).push(
|
||||||
// CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
// builder: (context) =>
|
builder: (context) =>
|
||||||
// const SubjectIconGallery()),
|
const SubjectIconGallery()),
|
||||||
// );
|
);
|
||||||
// },
|
},
|
||||||
// )
|
)
|
||||||
// ],
|
],
|
||||||
// ),
|
),
|
||||||
// ),
|
),
|
||||||
// ),
|
),
|
||||||
|
|
||||||
// // appearance things
|
// // appearance things
|
||||||
// Padding(
|
// Padding(
|
||||||
@ -822,40 +812,6 @@ class SettingsScreenState extends State<SettingsScreen>
|
|||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
|
|
||||||
// Material(
|
|
||||||
// type: MaterialType.transparency,
|
|
||||||
// child: SwitchListTile(
|
|
||||||
// contentPadding: const EdgeInsets.only(left: 14.0),
|
|
||||||
// shape: RoundedRectangleBorder(
|
|
||||||
// borderRadius: BorderRadius.circular(12.0)),
|
|
||||||
// title: Row(
|
|
||||||
// children: [
|
|
||||||
// Icon(
|
|
||||||
// FeatherIcons.moon,
|
|
||||||
// color: settings.shadowEffect
|
|
||||||
// ? Theme.of(context).colorScheme.secondary
|
|
||||||
// : AppColors.of(context).text.withOpacity(.25),
|
|
||||||
// ),
|
|
||||||
// const SizedBox(width: 14.0),
|
|
||||||
// Expanded(
|
|
||||||
// child: Text(
|
|
||||||
// "shadow_effect".i18n,
|
|
||||||
// style: TextStyle(
|
|
||||||
// fontWeight: FontWeight.w600,
|
|
||||||
// fontSize: 16.0,
|
|
||||||
// color: AppColors.of(context).text.withOpacity(
|
|
||||||
// settings.shadowEffect ? 1.0 : .5),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// onChanged: (v) => settings.update(shadowEffect: v),
|
|
||||||
// value: settings.shadowEffect,
|
|
||||||
// activeColor: Theme.of(context).colorScheme.secondary,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ],
|
// ],
|
||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
@ -945,12 +901,6 @@ class SettingsScreenState extends State<SettingsScreen>
|
|||||||
// activeColor: Theme.of(context).colorScheme.secondary,
|
// activeColor: Theme.of(context).colorScheme.secondary,
|
||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
// MenuRenamedSubjects(
|
|
||||||
// settings: settings,
|
|
||||||
// ),
|
|
||||||
// MenuRenamedTeachers(
|
|
||||||
// settings: settings,
|
|
||||||
// ),
|
|
||||||
// PremiumCustomAppIconMenu(
|
// PremiumCustomAppIconMenu(
|
||||||
// settings: settings,
|
// settings: settings,
|
||||||
// ),
|
// ),
|
||||||
@ -1130,107 +1080,6 @@ class SettingsScreenState extends State<SettingsScreen>
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
// Padding(
|
|
||||||
// padding:
|
|
||||||
// const EdgeInsets.symmetric(vertical: 12.0, horizontal: 24.0),
|
|
||||||
// child: Panel(
|
|
||||||
// title: Text("about".i18n),
|
|
||||||
// child: Column(children: [
|
|
||||||
// PanelButton(
|
|
||||||
// leading: const Icon(FeatherIcons.mail),
|
|
||||||
// title: Text("news".i18n),
|
|
||||||
// onPressed: () => _openNews(context),
|
|
||||||
// ),
|
|
||||||
// PanelButton(
|
|
||||||
// leading: const Icon(FeatherIcons.lock),
|
|
||||||
// title: Text("privacy".i18n),
|
|
||||||
// // onPressed: () => launchUrl(
|
|
||||||
// // Uri.parse("https://refilc.hu/privacy-policy"),
|
|
||||||
// // mode: LaunchMode.inAppWebView),
|
|
||||||
// onPressed: () => _openPrivacy(context),
|
|
||||||
// ),
|
|
||||||
// PanelButton(
|
|
||||||
// leading: const Icon(FeatherIcons.atSign),
|
|
||||||
// title: const Text("Discord"),
|
|
||||||
// onPressed: () => launchUrl(
|
|
||||||
// Uri.parse("https://dc.refilc.hu"),
|
|
||||||
// mode: LaunchMode.externalApplication),
|
|
||||||
// ),
|
|
||||||
// PanelButton(
|
|
||||||
// leading: const Icon(FeatherIcons.globe),
|
|
||||||
// title: const Text("www.refilc.hu"),
|
|
||||||
// onPressed: () => launchUrl(
|
|
||||||
// Uri.parse("https://www.refilc.hu"),
|
|
||||||
// mode: LaunchMode.externalApplication),
|
|
||||||
// ),
|
|
||||||
// PanelButton(
|
|
||||||
// leading: const Icon(FeatherIcons.github),
|
|
||||||
// title: const Text("Github"),
|
|
||||||
// onPressed: () => launchUrl(
|
|
||||||
// Uri.parse("https://github.com/refilc"),
|
|
||||||
// mode: LaunchMode.externalApplication),
|
|
||||||
// ),
|
|
||||||
// PanelButton(
|
|
||||||
// leading: const Icon(FeatherIcons.award),
|
|
||||||
// title: Text("licenses".i18n),
|
|
||||||
// onPressed: () => showLicensePage(context: context),
|
|
||||||
// ),
|
|
||||||
// Tooltip(
|
|
||||||
// message: "data_collected".i18n,
|
|
||||||
// padding: const EdgeInsets.all(4.0),
|
|
||||||
// textStyle: TextStyle(
|
|
||||||
// fontWeight: FontWeight.w500,
|
|
||||||
// color: AppColors.of(context).text),
|
|
||||||
// decoration: BoxDecoration(
|
|
||||||
// color: Theme.of(context).colorScheme.background),
|
|
||||||
// child: Material(
|
|
||||||
// type: MaterialType.transparency,
|
|
||||||
// child: SwitchListTile(
|
|
||||||
// contentPadding: const EdgeInsets.only(left: 12.0),
|
|
||||||
// shape: RoundedRectangleBorder(
|
|
||||||
// borderRadius: BorderRadius.circular(12.0)),
|
|
||||||
// secondary: Icon(
|
|
||||||
// FeatherIcons.barChart2,
|
|
||||||
// color: settings.xFilcId != "none"
|
|
||||||
// ? Theme.of(context).colorScheme.secondary
|
|
||||||
// : AppColors.of(context).text.withOpacity(.25),
|
|
||||||
// ),
|
|
||||||
// title: Text(
|
|
||||||
// "Analytics".i18n,
|
|
||||||
// style: TextStyle(
|
|
||||||
// fontWeight: FontWeight.w600,
|
|
||||||
// fontSize: 16.0,
|
|
||||||
// color: AppColors.of(context).text.withOpacity(
|
|
||||||
// settings.xFilcId != "none" ? 1.0 : .5),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// subtitle: Text(
|
|
||||||
// "Anonymous Usage Analytics".i18n,
|
|
||||||
// style: TextStyle(
|
|
||||||
// color: AppColors.of(context).text.withOpacity(
|
|
||||||
// settings.xFilcId != "none" ? .5 : .2),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// onChanged: (v) {
|
|
||||||
// String newId;
|
|
||||||
// if (v == false) {
|
|
||||||
// newId = "none";
|
|
||||||
// } else if (settings.xFilcId == "none") {
|
|
||||||
// newId = SettingsProvider.defaultSettings().xFilcId;
|
|
||||||
// } else {
|
|
||||||
// newId = settings.xFilcId;
|
|
||||||
// }
|
|
||||||
// settings.update(xFilcId: newId);
|
|
||||||
// },
|
|
||||||
// value: settings.xFilcId != "none",
|
|
||||||
// activeColor: Theme.of(context).colorScheme.secondary,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ]),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
|
|
||||||
// developer options
|
// developer options
|
||||||
if (settings.developerMode)
|
if (settings.developerMode)
|
||||||
SplittedPanel(
|
SplittedPanel(
|
||||||
|
@ -84,6 +84,10 @@ extension SettingsLocalization on String {
|
|||||||
"switch_account": "Switch Account",
|
"switch_account": "Switch Account",
|
||||||
"subjects": "Subjects",
|
"subjects": "Subjects",
|
||||||
"select_subject": "Select Subject",
|
"select_subject": "Select Subject",
|
||||||
|
"own_paints": "Own Paints",
|
||||||
|
"dl_paint": "Redeemed",
|
||||||
|
"public_paint": "Public Paints",
|
||||||
|
"no_pub_paint": "No Public Paints",
|
||||||
},
|
},
|
||||||
"hu_hu": {
|
"hu_hu": {
|
||||||
"personal_details": "Személyes információk",
|
"personal_details": "Személyes információk",
|
||||||
@ -166,6 +170,10 @@ extension SettingsLocalization on String {
|
|||||||
"switch_account": "Fiókváltás",
|
"switch_account": "Fiókváltás",
|
||||||
"subjects": "Tantárgyak",
|
"subjects": "Tantárgyak",
|
||||||
"select_subject": "Válassz tantárgyat",
|
"select_subject": "Válassz tantárgyat",
|
||||||
|
"own_paints": "Saját témák",
|
||||||
|
"dl_paint": "Beszerzett",
|
||||||
|
"public_paint": "Nyilvános témák",
|
||||||
|
"no_pub_paint": "Nincsenek nyilvános festékek",
|
||||||
},
|
},
|
||||||
"de_de": {
|
"de_de": {
|
||||||
"personal_details": "Persönliche Angaben",
|
"personal_details": "Persönliche Angaben",
|
||||||
@ -248,6 +256,10 @@ extension SettingsLocalization on String {
|
|||||||
"switch_account": "Benutzer wechseln",
|
"switch_account": "Benutzer wechseln",
|
||||||
"subjects": "Themen",
|
"subjects": "Themen",
|
||||||
"select_subject": "Fach auswählen",
|
"select_subject": "Fach auswählen",
|
||||||
|
"own_paints": "Meine Themen",
|
||||||
|
"dl_paint": "Eingelöst",
|
||||||
|
"public_paint": "Öffentliche Themen",
|
||||||
|
"no_pub_paint": "Keine öffentlichen Anstriche",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
342
filcnaplo_mobile_ui/lib/screens/settings/submenu/paint_list.dart
Normal file
342
filcnaplo_mobile_ui/lib/screens/settings/submenu/paint_list.dart
Normal file
@ -0,0 +1,342 @@
|
|||||||
|
// ignore_for_file: use_build_context_synchronously
|
||||||
|
|
||||||
|
import 'package:filcnaplo/api/providers/user_provider.dart';
|
||||||
|
import 'package:filcnaplo/models/settings.dart';
|
||||||
|
import 'package:filcnaplo/models/shared_theme.dart';
|
||||||
|
import 'package:filcnaplo/theme/colors/accent.dart';
|
||||||
|
import 'package:filcnaplo/theme/colors/colors.dart';
|
||||||
|
import 'package:filcnaplo_kreta_api/providers/share_provider.dart';
|
||||||
|
import 'package:filcnaplo_mobile_ui/common/empty.dart';
|
||||||
|
import 'package:filcnaplo_mobile_ui/common/panel/panel_button.dart';
|
||||||
|
import 'package:filcnaplo_mobile_ui/common/splitted_panel/splitted_panel.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:filcnaplo_mobile_ui/screens/settings/settings_screen.i18n.dart';
|
||||||
|
import 'package:share_plus/share_plus.dart';
|
||||||
|
|
||||||
|
class MenuPaintList extends StatelessWidget {
|
||||||
|
const MenuPaintList({
|
||||||
|
super.key,
|
||||||
|
this.borderRadius = const BorderRadius.vertical(
|
||||||
|
top: Radius.circular(4.0), bottom: Radius.circular(4.0)),
|
||||||
|
});
|
||||||
|
|
||||||
|
final BorderRadius borderRadius;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return PanelButton(
|
||||||
|
onPressed: () async {
|
||||||
|
List<SharedTheme> publicThemes =
|
||||||
|
await Provider.of<ShareProvider>(context, listen: false)
|
||||||
|
.getAllPublicThemes(context);
|
||||||
|
|
||||||
|
Navigator.of(context, rootNavigator: true).push(CupertinoPageRoute(
|
||||||
|
builder: (context) => PaintListScreen(publicThemes: publicThemes)));
|
||||||
|
},
|
||||||
|
title: Text(
|
||||||
|
"own_paints".i18n,
|
||||||
|
style: TextStyle(
|
||||||
|
color: AppColors.of(context).text.withOpacity(.95),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
leading: Icon(
|
||||||
|
FeatherIcons.list,
|
||||||
|
size: 22.0,
|
||||||
|
color: AppColors.of(context).text.withOpacity(.95),
|
||||||
|
),
|
||||||
|
trailing: Icon(
|
||||||
|
FeatherIcons.chevronRight,
|
||||||
|
size: 22.0,
|
||||||
|
color: AppColors.of(context).text.withOpacity(0.95),
|
||||||
|
),
|
||||||
|
borderRadius: borderRadius,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class PaintListScreen extends StatefulWidget {
|
||||||
|
const PaintListScreen({super.key, required this.publicThemes});
|
||||||
|
|
||||||
|
final List<SharedTheme> publicThemes;
|
||||||
|
|
||||||
|
@override
|
||||||
|
PaintListScreenState createState() => PaintListScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class PaintListScreenState extends State<PaintListScreen>
|
||||||
|
with SingleTickerProviderStateMixin {
|
||||||
|
late SettingsProvider settingsProvider;
|
||||||
|
late UserProvider user;
|
||||||
|
late ShareProvider shareProvider;
|
||||||
|
|
||||||
|
late AnimationController _hideContainersController;
|
||||||
|
|
||||||
|
late List<Widget> tiles;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
shareProvider = Provider.of<ShareProvider>(context, listen: false);
|
||||||
|
|
||||||
|
_hideContainersController = AnimationController(
|
||||||
|
vsync: this, duration: const Duration(milliseconds: 200));
|
||||||
|
}
|
||||||
|
|
||||||
|
void buildPublicPaintTiles() async {
|
||||||
|
List<Widget> subjectTiles = [];
|
||||||
|
|
||||||
|
var added = [];
|
||||||
|
var i = 0;
|
||||||
|
|
||||||
|
for (var t in widget.publicThemes) {
|
||||||
|
if (added.contains(t.id)) continue;
|
||||||
|
|
||||||
|
Widget w = PanelButton(
|
||||||
|
onPressed: () => {
|
||||||
|
// TODO: set theme
|
||||||
|
},
|
||||||
|
title: Column(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
t.displayName,
|
||||||
|
style: TextStyle(
|
||||||
|
color: AppColors.of(context).text.withOpacity(.95),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
t.nickname,
|
||||||
|
style: TextStyle(
|
||||||
|
color: AppColors.of(context).text.withOpacity(.75),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
trailing: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
margin: const EdgeInsets.only(left: 2.0),
|
||||||
|
width: 12.0,
|
||||||
|
height: 12.0,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
color: t.backgroundColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
margin: const EdgeInsets.only(left: 2.0),
|
||||||
|
width: 12.0,
|
||||||
|
height: 12.0,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
color: t.panelsColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
margin: const EdgeInsets.only(left: 2.0),
|
||||||
|
width: 12.0,
|
||||||
|
height: 12.0,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
color: t.accentColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.vertical(
|
||||||
|
top: Radius.circular(i == 0 ? 12.0 : 4.0),
|
||||||
|
bottom:
|
||||||
|
Radius.circular(i + 1 == widget.publicThemes.length ? 12.0 : 4.0),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
i += 1;
|
||||||
|
subjectTiles.add(w);
|
||||||
|
added.add(t.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (widget.publicThemes.isEmpty) {
|
||||||
|
subjectTiles.add(Empty(
|
||||||
|
subtitle: 'no_pub_paint'.i18n,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
tiles = subjectTiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
settingsProvider = Provider.of<SettingsProvider>(context);
|
||||||
|
user = Provider.of<UserProvider>(context);
|
||||||
|
|
||||||
|
buildPublicPaintTiles();
|
||||||
|
|
||||||
|
return AnimatedBuilder(
|
||||||
|
animation: _hideContainersController,
|
||||||
|
builder: (context, child) => Opacity(
|
||||||
|
opacity: 1 - _hideContainersController.value,
|
||||||
|
child: Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
surfaceTintColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
|
leading: BackButton(color: AppColors.of(context).text),
|
||||||
|
title: Text(
|
||||||
|
"own_paints".i18n,
|
||||||
|
style: TextStyle(color: AppColors.of(context).text),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
body: SingleChildScrollView(
|
||||||
|
child: Padding(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.symmetric(vertical: 16.0, horizontal: 24.0),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
// current paint
|
||||||
|
SplittedPanel(
|
||||||
|
title: Text('current_paint'.i18n),
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
cardPadding: const EdgeInsets.all(4.0),
|
||||||
|
children: [
|
||||||
|
PanelButton(
|
||||||
|
onPressed: () async {
|
||||||
|
SharedGradeColors gradeColors = await shareProvider
|
||||||
|
.shareCurrentGradeColors(context);
|
||||||
|
SharedTheme theme =
|
||||||
|
await shareProvider.shareCurrentTheme(
|
||||||
|
context,
|
||||||
|
gradeColors: gradeColors,
|
||||||
|
);
|
||||||
|
|
||||||
|
Share.share(
|
||||||
|
theme.id,
|
||||||
|
subject: 'share_subj_theme'.i18n,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
longPressInstead: true,
|
||||||
|
title: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
't.displayName',
|
||||||
|
style: TextStyle(
|
||||||
|
color:
|
||||||
|
AppColors.of(context).text.withOpacity(.95),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
user.nickname ?? 'Anonymous',
|
||||||
|
style: TextStyle(
|
||||||
|
color:
|
||||||
|
AppColors.of(context).text.withOpacity(.65),
|
||||||
|
fontSize: 15.0,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
trailing: Transform.translate(
|
||||||
|
offset: const Offset(8.0, 0.0),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
margin: const EdgeInsets.only(left: 2.0),
|
||||||
|
width: 14.0,
|
||||||
|
height: 14.0,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
color:
|
||||||
|
(settingsProvider.customBackgroundColor ??
|
||||||
|
SettingsProvider.defaultSettings()
|
||||||
|
.customBackgroundColor),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: AppColors.of(context)
|
||||||
|
.text
|
||||||
|
.withOpacity(0.15),
|
||||||
|
offset: const Offset(1, 2),
|
||||||
|
blurRadius: 3,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Transform.translate(
|
||||||
|
offset: const Offset(-4.0, 0.0),
|
||||||
|
child: Container(
|
||||||
|
margin: const EdgeInsets.only(left: 2.0),
|
||||||
|
width: 14.0,
|
||||||
|
height: 14.0,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
color: (settingsProvider
|
||||||
|
.customHighlightColor ??
|
||||||
|
SettingsProvider.defaultSettings()
|
||||||
|
.customHighlightColor),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: AppColors.of(context)
|
||||||
|
.text
|
||||||
|
.withOpacity(0.15),
|
||||||
|
offset: const Offset(1, 2),
|
||||||
|
blurRadius: 3,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Transform.translate(
|
||||||
|
offset: const Offset(-8.0, 0.0),
|
||||||
|
child: Container(
|
||||||
|
margin: const EdgeInsets.only(left: 2.0),
|
||||||
|
width: 14.0,
|
||||||
|
height: 14.0,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
color: settingsProvider.customAccentColor ??
|
||||||
|
accentColorMap[
|
||||||
|
settingsProvider.accentColor],
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: AppColors.of(context)
|
||||||
|
.text
|
||||||
|
.withOpacity(0.15),
|
||||||
|
offset: const Offset(1, 2),
|
||||||
|
blurRadius: 3,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
borderRadius: const BorderRadius.vertical(
|
||||||
|
top: Radius.circular(12),
|
||||||
|
bottom: Radius.circular(12),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(
|
||||||
|
height: 18.0,
|
||||||
|
),
|
||||||
|
// own paints
|
||||||
|
SplittedPanel(
|
||||||
|
title: Text('public_paint'.i18n),
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
cardPadding: const EdgeInsets.all(4.0),
|
||||||
|
children: tiles,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -14,6 +14,7 @@ import 'package:filcnaplo_mobile_ui/common/panel/panel_button.dart';
|
|||||||
import 'package:filcnaplo_mobile_ui/common/splitted_panel/splitted_panel.dart';
|
import 'package:filcnaplo_mobile_ui/common/splitted_panel/splitted_panel.dart';
|
||||||
import 'package:filcnaplo_mobile_ui/screens/settings/settings_helper.dart';
|
import 'package:filcnaplo_mobile_ui/screens/settings/settings_helper.dart';
|
||||||
import 'package:filcnaplo_mobile_ui/screens/settings/submenu/edit_subject.dart';
|
import 'package:filcnaplo_mobile_ui/screens/settings/submenu/edit_subject.dart';
|
||||||
|
import 'package:filcnaplo_mobile_ui/screens/settings/submenu/paint_list.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||||
@ -243,7 +244,7 @@ class PersonalizeSettingsScreenState extends State<PersonalizeSettingsScreen>
|
|||||||
SplittedPanel(
|
SplittedPanel(
|
||||||
padding: const EdgeInsets.only(top: 9.0),
|
padding: const EdgeInsets.only(top: 9.0),
|
||||||
cardPadding: const EdgeInsets.all(4.0),
|
cardPadding: const EdgeInsets.all(4.0),
|
||||||
isSeparated: true,
|
isSeparated: false,
|
||||||
children: [
|
children: [
|
||||||
PanelButton(
|
PanelButton(
|
||||||
padding: const EdgeInsets.only(left: 14.0, right: 14.0),
|
padding: const EdgeInsets.only(left: 14.0, right: 14.0),
|
||||||
@ -272,6 +273,55 @@ class PersonalizeSettingsScreenState extends State<PersonalizeSettingsScreen>
|
|||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
borderRadius: const BorderRadius.vertical(
|
||||||
|
top: Radius.circular(12.0),
|
||||||
|
bottom: Radius.circular(4.0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const MenuPaintList(
|
||||||
|
borderRadius: BorderRadius.vertical(
|
||||||
|
top: Radius.circular(4.0),
|
||||||
|
bottom: Radius.circular(12.0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
// shadow toggle
|
||||||
|
SplittedPanel(
|
||||||
|
padding: const EdgeInsets.only(top: 9.0),
|
||||||
|
cardPadding: const EdgeInsets.all(4.0),
|
||||||
|
isSeparated: true,
|
||||||
|
children: [
|
||||||
|
PanelButton(
|
||||||
|
padding: const EdgeInsets.only(left: 14.0, right: 6.0),
|
||||||
|
onPressed: () async {
|
||||||
|
settingsProvider.update(
|
||||||
|
shadowEffect: !settingsProvider.shadowEffect);
|
||||||
|
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
title: Text(
|
||||||
|
"shadow_effect".i18n,
|
||||||
|
style: TextStyle(
|
||||||
|
color: AppColors.of(context).text.withOpacity(
|
||||||
|
settingsProvider.shadowEffect ? .95 : .25),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
leading: Icon(
|
||||||
|
FeatherIcons.moon,
|
||||||
|
size: 22.0,
|
||||||
|
color: AppColors.of(context).text.withOpacity(
|
||||||
|
settingsProvider.shadowEffect ? .95 : .25),
|
||||||
|
),
|
||||||
|
trailing: Switch(
|
||||||
|
onChanged: (v) async {
|
||||||
|
settingsProvider.update(shadowEffect: v);
|
||||||
|
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
value: settingsProvider.shadowEffect,
|
||||||
|
activeColor: Theme.of(context).colorScheme.secondary,
|
||||||
|
),
|
||||||
borderRadius: const BorderRadius.vertical(
|
borderRadius: const BorderRadius.vertical(
|
||||||
top: Radius.circular(12.0),
|
top: Radius.circular(12.0),
|
||||||
bottom: Radius.circular(12.0),
|
bottom: Radius.circular(12.0),
|
||||||
@ -355,12 +405,13 @@ class PersonalizeSettingsScreenState extends State<PersonalizeSettingsScreen>
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
// rename subjects
|
// rename things
|
||||||
SplittedPanel(
|
SplittedPanel(
|
||||||
padding: const EdgeInsets.only(top: 9.0),
|
padding: const EdgeInsets.only(top: 9.0),
|
||||||
cardPadding: const EdgeInsets.all(4.0),
|
cardPadding: const EdgeInsets.all(4.0),
|
||||||
isSeparated: true,
|
isSeparated: false,
|
||||||
children: [
|
children: [
|
||||||
|
// rename subjects
|
||||||
PanelButton(
|
PanelButton(
|
||||||
padding: const EdgeInsets.only(left: 14.0, right: 6.0),
|
padding: const EdgeInsets.only(left: 14.0, right: 6.0),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
@ -416,17 +467,10 @@ class PersonalizeSettingsScreenState extends State<PersonalizeSettingsScreen>
|
|||||||
),
|
),
|
||||||
borderRadius: const BorderRadius.vertical(
|
borderRadius: const BorderRadius.vertical(
|
||||||
top: Radius.circular(12.0),
|
top: Radius.circular(12.0),
|
||||||
bottom: Radius.circular(12.0),
|
bottom: Radius.circular(4.0),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
// rename teachers
|
||||||
),
|
|
||||||
// rename teachers
|
|
||||||
SplittedPanel(
|
|
||||||
padding: const EdgeInsets.only(top: 9.0),
|
|
||||||
cardPadding: const EdgeInsets.all(4.0),
|
|
||||||
isSeparated: true,
|
|
||||||
children: [
|
|
||||||
PanelButton(
|
PanelButton(
|
||||||
padding: const EdgeInsets.only(left: 14.0, right: 6.0),
|
padding: const EdgeInsets.only(left: 14.0, right: 6.0),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
@ -481,12 +525,19 @@ class PersonalizeSettingsScreenState extends State<PersonalizeSettingsScreen>
|
|||||||
activeColor: Theme.of(context).colorScheme.secondary,
|
activeColor: Theme.of(context).colorScheme.secondary,
|
||||||
),
|
),
|
||||||
borderRadius: const BorderRadius.vertical(
|
borderRadius: const BorderRadius.vertical(
|
||||||
top: Radius.circular(12.0),
|
top: Radius.circular(4.0),
|
||||||
bottom: Radius.circular(12.0),
|
bottom: Radius.circular(12.0),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// SplittedPanel(
|
||||||
|
// padding: const EdgeInsets.only(top: 9.0),
|
||||||
|
// cardPadding: const EdgeInsets.all(4.0),
|
||||||
|
// isSeparated: true,
|
||||||
|
// children: [],
|
||||||
|
// ),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 18.0,
|
height: 18.0,
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user