Rename everything filcnaplo-related to refilc

This commit is contained in:
Pearoo
2023-09-19 18:16:03 +02:00
parent 151e97b243
commit d1a9625d93
669 changed files with 39799 additions and 39481 deletions

View File

@@ -1,98 +0,0 @@
import 'package:filcnaplo/api/providers/user_provider.dart';
import 'package:filcnaplo/models/settings.dart';
import 'package:filcnaplo/models/user.dart';
import 'package:filcnaplo_kreta_api/client/client.dart';
import 'package:filcnaplo_kreta_api/providers/absence_provider.dart';
import 'package:filcnaplo_kreta_api/providers/event_provider.dart';
import 'package:filcnaplo_kreta_api/providers/exam_provider.dart';
import 'package:filcnaplo_kreta_api/providers/grade_provider.dart';
import 'package:filcnaplo_kreta_api/providers/homework_provider.dart';
import 'package:filcnaplo_kreta_api/providers/message_provider.dart';
import 'package:filcnaplo_kreta_api/providers/note_provider.dart';
import 'package:filcnaplo_kreta_api/providers/timetable_provider.dart';
import 'package:filcnaplo_mobile_ui/common/profile_image/profile_image.dart';
import 'package:filcnaplo_mobile_ui/screens/settings/settings_screen.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:wtf_sliding_sheet/wtf_sliding_sheet.dart';
class ProfileButton extends StatelessWidget {
const ProfileButton({Key? key, required this.child}) : super(key: key);
final ProfileImage child;
@override
Widget build(BuildContext context) {
final bool pMode =
Provider.of<SettingsProvider>(context, listen: false).presentationMode;
late UserProvider user;
late User? account;
Future<void> restore() => Future.wait([
Provider.of<GradeProvider>(context, listen: false).restore(),
Provider.of<TimetableProvider>(context, listen: false).restoreUser(),
Provider.of<ExamProvider>(context, listen: false).restore(),
Provider.of<HomeworkProvider>(context, listen: false).restore(),
Provider.of<MessageProvider>(context, listen: false).restore(),
Provider.of<NoteProvider>(context, listen: false).restore(),
Provider.of<EventProvider>(context, listen: false).restore(),
Provider.of<AbsenceProvider>(context, listen: false).restore(),
Provider.of<KretaClient>(context, listen: false).refreshLogin(),
]);
user = Provider.of<UserProvider>(context);
try {
user.getUsers().forEach((acc) {
if (user.name!.toLowerCase().replaceAll(' ', '') !=
acc.name.toLowerCase().replaceAll(' ', '')) {
account = acc;
}
});
} catch (err) {
account = null;
}
return ProfileImage(
backgroundColor: !pMode
? child.backgroundColor
: Theme.of(context).colorScheme.secondary,
heroTag: child.heroTag,
key: child.key,
name: !pMode ? child.name : "János",
radius: child.radius,
badge: child.badge,
role: child.role,
profilePictureString: child.profilePictureString,
onTap: () {
showSlidingBottomSheet(
context,
useRootNavigator: true,
builder: (context) => SlidingSheetDialog(
color: Theme.of(context).scaffoldBackgroundColor,
duration: const Duration(milliseconds: 400),
scrollSpec: const ScrollSpec.bouncingScroll(),
snapSpec: const SnapSpec(
snap: true,
snappings: [1.0],
initialSnap: 1.0,
positioning: SnapPositioning.relativeToSheetHeight,
),
cornerRadius: 16,
cornerRadiusOnFullscreen: 0,
builder: (context, state) => Material(
color: Theme.of(context).scaffoldBackgroundColor,
child: const SettingsScreen(),
),
),
);
},
onLongPress: () {
if (account != null) {
user.setUser(account!.id);
restore().then((_) => user.setUser(account!.id));
}
},
);
}
}

View File

@@ -1,253 +0,0 @@
import 'dart:convert';
import 'package:filcnaplo/models/user.dart';
import 'package:filcnaplo/theme/colors/colors.dart';
import 'package:filcnaplo_mobile_ui/common/new_content_indicator.dart';
import 'package:flutter/material.dart';
import 'package:filcnaplo/utils/color.dart';
class ProfileImage extends StatefulWidget {
const ProfileImage({
Key? key,
this.onTap,
this.onDoubleTap,
this.onLongPress,
this.name,
this.backgroundColor,
this.radius = 20.0,
this.heroTag,
this.badge = false,
this.role = Role.student,
this.censored = false,
this.profilePictureString = "",
}) : super(key: key);
final void Function()? onTap;
final void Function()? onDoubleTap;
final void Function()? onLongPress;
final String? name;
final Color? backgroundColor;
final double radius;
final String? heroTag;
final bool badge;
final Role? role;
final bool censored;
final String profilePictureString;
@override
State<ProfileImage> createState() => _ProfileImageState();
}
class _ProfileImageState extends State<ProfileImage> {
Image? profilePicture;
String? profPicSaved;
@override
void initState() {
super.initState();
updatePic();
}
void updatePic() {
profilePicture = widget.profilePictureString != ""
? Image.memory(
const Base64Decoder().convert(widget.profilePictureString),
fit: BoxFit.scaleDown,
gaplessPlayback: true)
: null;
profPicSaved = widget.profilePictureString;
}
@override
Widget build(BuildContext context) {
if (profPicSaved != widget.profilePictureString) updatePic();
if (widget.heroTag == null) {
return buildWithoutHero(context);
} else {
return buildWithHero(context);
}
}
Widget buildWithoutHero(BuildContext context) {
Color color = ColorUtils.foregroundColor(
widget.backgroundColor ?? Theme.of(context).scaffoldBackgroundColor);
Color roleColor;
if (Theme.of(context).brightness == Brightness.light) {
roleColor = const Color(0xFF444444);
} else {
roleColor = const Color(0xFF555555);
}
return Stack(
alignment: Alignment.center,
children: [
Material(
clipBehavior: Clip.hardEdge,
shape: const CircleBorder(),
color: widget.backgroundColor ??
AppColors.of(context).text.withOpacity(.15),
child: InkWell(
onTap: widget.onTap,
onDoubleTap: widget.onDoubleTap,
onLongPress: widget.onLongPress,
child: AnimatedContainer(
duration: const Duration(milliseconds: 200),
height: widget.radius * 2,
width: widget.radius * 2,
decoration: const BoxDecoration(
shape: BoxShape.circle,
),
child:
widget.name != null && (widget.name?.trim().length ?? 0) > 0
? Center(
child: widget.censored
? Container(
width: 15,
height: 15,
decoration: BoxDecoration(
color: color.withOpacity(.5),
borderRadius: BorderRadius.circular(8.0),
),
)
: profilePicture ??
Text(
(widget.name?.trim().length ?? 0) > 0
? (widget.name ?? "?").trim()[0]
: "?",
style: TextStyle(
color: color,
fontWeight: FontWeight.w600,
fontSize: 18.0 * (widget.radius / 20.0),
),
),
)
: Container(),
),
),
),
// Role indicator
if (widget.role == Role.parent)
SizedBox(
height: widget.radius * 2,
width: widget.radius * 2,
child: Container(
alignment: Alignment.bottomRight,
child: Icon(Icons.shield,
color: roleColor, size: widget.radius / 1.3),
),
),
],
);
}
Widget buildWithHero(BuildContext context) {
Color color = ColorUtils.foregroundColor(
widget.backgroundColor ?? Theme.of(context).scaffoldBackgroundColor);
Color roleColor;
if (Theme.of(context).brightness == Brightness.light) {
roleColor = const Color(0xFF444444);
} else {
roleColor = const Color(0xFF555555);
}
Widget child = FittedBox(
fit: BoxFit.fitHeight,
child: Text(
(widget.name?.trim().length ?? 0) > 0
? (widget.name ?? "?").trim()[0]
: "?",
style: TextStyle(
color: color,
fontWeight: FontWeight.w600,
fontSize: 18.0 * (widget.radius / 20.0),
),
),
);
return SizedBox(
height: widget.radius * 2,
width: widget.radius * 2,
child: Stack(
alignment: Alignment.center,
children: [
if (widget.name != null && (widget.name?.trim().length ?? 0) > 0)
Hero(
tag: widget.heroTag! + "background",
transitionOnUserGestures: true,
child: Material(
clipBehavior: Clip.hardEdge,
shape: const CircleBorder(),
color: profilePicture != null
? Colors.transparent
: widget.backgroundColor ??
AppColors.of(context).text.withOpacity(.15),
child: AnimatedContainer(
duration: const Duration(milliseconds: 200),
height: widget.radius * 2,
width: widget.radius * 2,
decoration: const BoxDecoration(
shape: BoxShape.circle,
),
child: profilePicture,
),
),
),
Hero(
tag: widget.heroTag! + "child",
transitionOnUserGestures: true,
child: Material(
clipBehavior: Clip.hardEdge,
shape: profilePicture != null ? const CircleBorder() : null,
child: profilePicture ?? child,
type: MaterialType.transparency,
),
),
// Badge
if (widget.badge)
Hero(
tag: widget.heroTag! + "new_content_indicator",
child: NewContentIndicator(size: widget.radius * 2),
),
// Role indicator
if (widget.role == Role.parent)
Hero(
tag: widget.heroTag! + "role_indicator",
child: FittedBox(
fit: BoxFit.fitHeight,
child: SizedBox(
height: widget.radius * 2,
width: widget.radius * 2,
child: Container(
alignment: Alignment.bottomRight,
child: Icon(Icons.shield,
color: roleColor, size: widget.radius / 1.3),
),
),
),
),
Material(
color: Colors.transparent,
clipBehavior: Clip.hardEdge,
shape: const CircleBorder(),
child: InkWell(
onTap: widget.onTap,
onDoubleTap: widget.onDoubleTap,
onLongPress: widget.onLongPress,
child: SizedBox(
height: widget.radius * 2,
width: widget.radius * 2,
),
),
),
],
),
);
}
}