Initial commit

This commit is contained in:
2023-01-22 19:44:38 +01:00
parent 021bc02992
commit 1baa8028fa
164 changed files with 6587 additions and 2 deletions

View File

@ -0,0 +1,93 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_login/flutter_login.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../data/accountModel.dart';
class Login extends StatefulWidget {
const Login({Key? key}) : super(key: key);
@override
State<Login> createState() => _LoginState();
}
class _LoginState extends State<Login> {
Duration get loginTime => const Duration(milliseconds: 2250);
final Future<SharedPreferences> _storage = SharedPreferences.getInstance();
String? checkInput(value){
return (value ?? "").length < 5 ? "Eingabe zu kurz" : null;
}
@override
Widget build(BuildContext context) {
return FlutterLogin(
logo: Image.file(File("assets/logo/icon.png")).image,
userValidator: checkInput,
passwordValidator: checkInput,
onLogin: _authUser,
onSignup: null,
onRecoverPassword: _recoverPassword,
theme: LoginTheme(
primaryColor: Theme.of(context).primaryColor,
cardTheme: const CardTheme(
elevation: 10,
shape: InputBorder.none,
),
),
messages: LoginMessages(
loginButton: "Anmelden",
userHint: "Nutzername",
passwordHint: "Passwort",
),
disableCustomPageTransformer: true,
headerWidget: const Padding(
padding: EdgeInsets.only(bottom: 10),
child: Center(
child: Text(
"Dies ist ein Inoffizieller Nextclient & Webuntis Client und wird nicht vom Marianum selbst betrieben.\nBitte bedenke, dass deine persönlichen Anmelde & Infodaten durch dritte, nicht vom Marianum betriebene, Systeme geleitet werden!",
textAlign: TextAlign.center,
),
),
),
footer: "Marianum Fulda - Die persönliche Schule!",
title: "Marianum",
hideForgotPasswordButton: true,
userType: LoginUserType.name,
);
}
Future<String?> _authUser(LoginData data) async {
final SharedPreferences preferences = await _storage;
preferences.setBool("loggedIn", true);
preferences.setString("username", data.name);
preferences.setString("password", data.password);
debugPrint('Name: ${data.name}, Password: ${data.password}');
return Future.delayed(loginTime).then((_) {
Provider.of<AccountModel>(context, listen: false).login();
return null;
});
}
Future<String> _recoverPassword(String name) {
return Future.delayed(loginTime).then((_) {
return "Diese Funktion steht nicht zur Verfügung!";
});
}
}

View File

@ -0,0 +1,271 @@
import 'package:flutter/material.dart';
import 'package:marianum_mobile/data/incommingPackets/fileListPacket.dart';
import 'package:marianum_mobile/widget/loadingPacket.dart';
import 'package:provider/provider.dart';
import 'package:webdav_client/webdav_client.dart';
import '../../../data/accountModel.dart';
import '../../../widget/loadingSpinner.dart';
class Files extends StatefulWidget {
const Files({Key? key}) : super(key: key);
@override
State<Files> createState() => _FilesState();
}
class _FilesState extends State<Files> {
// List<String> path = List<String>.empty(growable: true);
// List<File> files = List<File>.empty(growable: true);
//
// var client = newClient(
// "https://cloud.marianum-fulda.de/remote.php/dav/files/***REMOVED***/",
// user: "***REMOVED***",
// password: "***REMOVED***",
// );
@override
void initState() {
Provider.of<FileListPacket>(context, listen: false).invoke();
super.initState();
// client.setHeaders(
// {
// "Authorization": "Bearer",
// "User-Agent": "Marianum Fulda/Alpha0.1 (Development build) ; https://mhsl.eu/id.html",
// }
// );
//
// path.add("/");
// Future.delayed(Duration.zero).then((context) => updatePath());
}
// void homeFolder() {
// path.clear();
// path.add("/");
// updatePath();
// }
//
// void popFolder() {
// if(path.length == 1) return;
// path.removeLast();
// updatePath();
// }
//
// void enterFolder(String sub) {
// path.add(sub);
// updatePath();
// }
//
// void updatePath() {
//
// final files = client.readDir(path.join("/"));
//
// showDialog(
// context: context,
// barrierDismissible: false,
// builder: (BuildContext context) {
// return const LoadingSpinner();
// }
// );
//
// files.then((value) =>
// setState(() {
// Navigator.pop(context);
// this.files.clear();
// this.files = value;
// })
// );
// }
@override
Widget build(BuildContext context) {
// List<Widget> items = List<Widget>.empty(growable: true);
//
// var counter = 0;
// for (final file in files) {
// bool isDir = file.isDir ?? false;
// String name = file.name ?? "?";
//
// items.add(ListTile(
// title: Text(file.name ?? "?"),
// leading: Icon(isDir ? Icons.folder_outlined : Icons.file_copy),
// trailing: Icon(isDir ? Icons.arrow_right : null),
// onTap: () {
// enterFolder(file.name ?? "");
// },
// onLongPress: () {
// setState(() {
// items[counter] = ListTile(
// title: Text(file.name ?? "?"),
// trailing: const Icon(Icons.delete),
// );
// });
// },
// ));
//
// }
//
// items.insert(0, AppBar(
// leading: path.length == 1 ? null : IconButton(
// icon: const Icon(Icons.keyboard_arrow_left),
// onPressed: () {
// popFolder();
// },
// ),
// actions: [
// IconButton(
// icon: const Icon(Icons.home),
// onPressed: () {
// homeFolder();
// },
// ),
//
// IconButton(
// icon: const Icon(Icons.refresh),
// onPressed: () {
// updatePath();
// },
// )
// ],
//
// title: Text(path.length == 1 ? "Dateien" : path.last),
// ));
//
// return ListView(
// children: items,
// );
return Consumer<FileListPacket>(
builder: (context, data, child) {
List<ListTile> entries = List<ListTile>.empty(growable: true);
data.entries.forEach((element) {
entries.add(ListTile(
title: Text(element.name),
leading: Icon(element.isFolder ? Icons.folder : Icons.file_copy_outlined),
onTap: () {
if(element.isFolder) {
Provider.of<FileListPacket>(context, listen: false).invoke(
data: {
"path": element.path
},
indicateLoading: true,
);
} else {
// TODO: Open an File
}
},
onLongPress: () {
showModalBottomSheet<void>(
context: context,
builder: (context) {
return ListView(
children: [
ListTile(
leading: Icon(Icons.delete),
title: Text("'${element.name.replaceRange(20, element.name.length, " ...")}' Löschen"),
),
const ListTile(
leading: Icon(Icons.share),
title: Text("Teilen"),
)
],
);
},
);
},
));
});
return Scaffold(
appBar: AppBar(
leading: IconButton(
icon: const Icon(Icons.arrow_back_outlined),
onPressed: () {
Provider.of<FileListPacket>(context, listen: false).invoke(
data: {
"path": data.lastPath
},
indicateLoading: true,
);
}
),
title: Text(data.lastPath),
actions: [
IconButton(
onPressed: () {
Provider.of<FileListPacket>(context, listen: false).invoke(indicateLoading: true);
},
icon: const Icon(Icons.home)
),
PopupMenuButton(
icon: Icon(Icons.add),
itemBuilder: (context) {
return [
const PopupMenuItem<int>(
value: 0,
child: ListTile(
leading: Icon(Icons.folder),
title: Text("Ordner erstellen"),
),
),
const PopupMenuItem<int>(
value: 1,
child: ListTile(
leading: Icon(Icons.upload),
title: Text("Datei Hochladen"),
),
)
];
},
)
],
),
floatingActionButton: FloatingActionButton.small(
onPressed: () {
showModalBottomSheet(
isScrollControlled: true,
context: context,
backgroundColor: Colors.transparent,
builder: (context) {
return Container(
height: MediaQuery.of(context).size.height * 0.3,
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(25.0),
topRight: Radius.circular(25.0),
)
),
child: ListView(
children: const [
ListTile(
leading: Icon(Icons.create_new_folder_sharp),
title: Text("Neuer Ordner"),
),
ListTile(
leading: Icon(Icons.upload),
title: Text("Hochladen"),
)
],
),
);
},
);
},
backgroundColor: Theme.of(context).primaryColor,
child: const Icon(Icons.add),
),
body: LoadingPacket(packet: data, child: ListView(children: entries)),
);
},
);
}
}

View File

@ -0,0 +1,15 @@
import 'package:flutter/cupertino.dart';
class Message extends StatefulWidget {
const Message({Key? key}) : super(key: key);
@override
State<Message> createState() => _MessageState();
}
class _MessageState extends State<Message> {
@override
Widget build(BuildContext context) {
return const Text("Message");
}
}

View File

@ -0,0 +1,20 @@
import 'package:flutter/material.dart';
import 'package:marianum_mobile/screen/pages/more/roomplan/roomplan.dart';
import '../../../widget/ListItem.dart';
import 'message/message.dart';
class Overhang extends StatelessWidget {
const Overhang({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return ListView(
children: const [
ListItemNavigator(icon: Icons.newspaper, text: "Marianum Message", target: Message()),
ListItemNavigator(icon: Icons.room, text: "Raumplan", target: Roomplan()),
],
);
}
}

View File

@ -0,0 +1,10 @@
import 'package:flutter/cupertino.dart';
class Roomplan extends StatelessWidget {
const Roomplan({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const Text("asd");
}
}

View File

@ -0,0 +1,166 @@
import 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:marianum_mobile/data/outgoingPackets/talkContactsAskPacket.dart';
import 'package:marianum_mobile/widget/loadingPacket.dart';
import 'package:provider/provider.dart';
import '../../../data/accountModel.dart';
import '../../../data/incommingPackets/talkContactsPacket.dart';
import '../../../widget/loadingSpinner.dart';
import 'chatView.dart';
class Talk extends StatefulWidget {
const Talk({Key? key}) : super(key: key);
@override
State<Talk> createState() => _TalkState();
}
class _TalkState extends State<Talk> {
// List<ChatData> chats = List<ChatData>.empty(growable: true);
//
// Future<List<ChatData>> getChats() async {
// var url = Uri.https("***REMOVED***:***REMOVED***@mhsl.eu", "marianum/app/middleware/chat.php");
// var response = await http.get(
// url,
// headers: (
// {
// "Accept": "application/json",
// "OCS-APIRequest": "true",
// }
// ),
// );
//
// return compute(parseChats, response.body);
// }
@override
void initState() {
Provider.of<TalkContactsPaket>(context, listen: false).invoke();
//TalkContactsAskPacket().send();
super.initState();
// Future.delayed(Duration.zero).then((context) => updateChats());
// Provider.of<AccountModel>(context, listen: false).channel.sink.add("chat");
}
void updateChats() {
// var chats = getChats();
//
// showDialog(
// context: context,
// barrierDismissible: false,
// builder: (BuildContext context) {
// return const LoadingSpinner();
// }
// );
//
// chats.then((value) =>
// setState(() {
// Navigator.pop(context);
// this.chats.clear();
// this.chats = value;
// })
// );
}
@override
Widget build(BuildContext context) {
// List<ListTile> chats = List<ListTile>.empty(growable: true);
//
// for (var element in this.chats) {
// chats.add(
// ListTile(
// leading: element.type == 1 ? CircleAvatar(
// backgroundColor: Colors.grey,
// foregroundImage: Image.network(element.avatar).image,
// ) : const Icon(Icons.group),
// title: Text(element.name),
// subtitle: Text(
// "${element.lastMessageAuthor}: ${element.lastMessage.replaceAll("\n", "")}",
// overflow: TextOverflow.ellipsis,
// ),
// onTap: () {
// Navigator.push(context, MaterialPageRoute(builder: (builder) => const ChatView()));
// },
// trailing: element.unreadMessages > 0 ? const Icon(Icons.mark_chat_unread) : Text(element.lastActivity),
// )
// );
// }
//
// return ListView(
// children: chats,
// );
return Consumer<TalkContactsPaket>(
builder: (context, data, child) {
List<ListTile> chats = List<ListTile>.empty(growable: true);
for (var element in data.contacts) {
chats.add(ListTile(
title: Text(element.name),
subtitle: Text("${element.lastTime}: ${element.lastMessage}".replaceAll("\n", " "), overflow: TextOverflow.ellipsis),
trailing: element.unreadMessages ? const Icon(Icons.new_releases_outlined) : null,
leading: CircleAvatar(
foregroundImage: element.isGroup ? null : Image.network(element.profilePicture).image,
backgroundColor: Theme.of(context).primaryColor,
foregroundColor: Colors.white,
child: element.isGroup ? const Icon(Icons.group) : const Icon(Icons.person),
),
onTap: () {
Navigator.of(context).push(MaterialPageRoute(builder: (context) {
return ChatView(
userToken: element.userToken,
);
}));
},
));
}
return LoadingPacket(packet: data, child: ListView(children: chats));
},
);
}
}
//
// List<ChatData> parseChats(String json) {
// final parsed = jsonDecode(json).cast<Map<String, dynamic>>();
// return parsed.map<ChatData>((a) => ChatData.fromJson(a)).toList();
// }
//
// class ChatData {
// final String name;
// final String lastMessage;
// final String lastMessageAuthor;
// final String avatar;
// final int type;
// final String lastActivity;
// final int unreadMessages;
//
// const ChatData({
// required this.name,
// required this.lastMessage,
// required this.lastMessageAuthor,
// required this.avatar,
// required this.type,
// required this.lastActivity,
// required this.unreadMessages,
// });
//
// factory ChatData.fromJson(Map<String, dynamic> json) {
// return ChatData(
// name: json['name'] as String,
// lastMessage: json['last_message'] as String,
// lastMessageAuthor: json['last_message_author'] as String,
// avatar: json['avatar'] as String,
// type: json['type'] as int,
// lastActivity: json['lastActivity'] as String,
// unreadMessages: json['unreadMessages'] as int,
// );
// }
// }

View File

@ -0,0 +1,101 @@
import 'package:bubble/bubble.dart';
import 'package:flutter/material.dart';
import 'package:marianum_mobile/data/incommingPackets/talkChatPacket.dart';
import 'package:marianum_mobile/widget/loadingPacket.dart';
import 'package:provider/provider.dart';
class ChatView extends StatefulWidget {
final String userToken;
const ChatView({Key? key, required this.userToken}) : super(key: key);
@override
State<ChatView> createState() => _ChatViewState();
}
class _ChatViewState extends State<ChatView> {
static const styleSystem = BubbleStyle(
color: Color.fromRGBO(212, 234, 244, 1.0),
borderWidth: 1,
elevation: 2,
margin: BubbleEdges.only(top: 15),
alignment: Alignment.center,
);
static const styleOther = BubbleStyle(
nip: BubbleNip.leftBottom,
color: Colors.white,
borderWidth: 1,
elevation: 2,
margin: BubbleEdges.only(top: 15, left: 10),
alignment: Alignment.topLeft,
);
static const styleSelf = BubbleStyle(
nip: BubbleNip.rightBottom,
color: Color.fromRGBO(225, 255, 199, 1.0),
borderWidth: 1,
elevation: 2,
margin: BubbleEdges.only(top: 15, right: 10),
alignment: Alignment.topRight,
);
@override
void initState() {
super.initState();
Provider.of<TalkChatPacket>(context, listen: false).invoke(
data: {
"token": widget.userToken
},
indicateLoading: true,
allowNotifyListeners: false,
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey,
appBar: AppBar(
title: const Text("Chat mit jemandem"),
),
body: Consumer<TalkChatPacket>(
builder: (context, data, child) {
List<Bubble> messages = List<Bubble>.empty(growable: true);
data.messages.forEach((element) {
messages.add(Bubble(
style: styleSelf,
child: Text(element.content),
));
});
return LoadingPacket(packet: data, child: ListView(
children: [],
));
},
),
// ListView(
// children: [
// Bubble(
// style: styleSystem,
// child: const Text("Chat gestartet"),
// ),
// Bubble(
// style: styleOther,
// child: const Text("Hi, das ist ein Testtext"),
// ),
// Bubble(
// style: styleSelf,
// child: Text(widget.userToken),
// )
// ],
// ),
);
}
}

View File

@ -0,0 +1,27 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class Timetable extends StatefulWidget {
const Timetable({Key? key}) : super(key: key);
@override
State<Timetable> createState() => _TimetableState();
}
class _TimetableState extends State<Timetable> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
List<ListTile> chats = List<ListTile>.empty(growable: true);
return const Center(
child: Text("Not supported"),
);
}
}

View File

@ -0,0 +1,20 @@
import 'package:flutter/material.dart';
class About extends StatelessWidget {
const About({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Über diese App"),
),
body: const Card(
elevation: 1,
borderOnForeground: true,
child: Text("Marianum Fulda"),
),
);
}
}

View File

@ -0,0 +1,90 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../data/accountModel.dart';
import '../../data/incommingPackets/serverInfoPacket.dart';
import '../../widget/ListItem.dart';
class Settings extends StatefulWidget {
const Settings({Key? key}) : super(key: key);
@override
State<Settings> createState() => _SettingsState();
}
class _SettingsState extends State<Settings> {
@override
void initState() {
super.initState();
ServerInfoPacket().invoke();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Einstellungen"),
),
body: ListView(
children: [
const ListItemNavigator(icon: Icons.info, text: "Über diese App", target: AboutDialog(
applicationIcon: Icon(Icons.send_time_extension_outlined),
applicationLegalese: "Released under MIT-License",
applicationName: "Marianum Fulda",
applicationVersion: "ALPHA 0.1",
)),
ListTile(
leading: const Icon(Icons.logout),
title: const Text("Account abmelden"),
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (builder) => AlertDialog(
title: const Text("Abmelden?"),
content: const Text("Möchtest du dich wirklich abmelden?"),
actions: [
TextButton(
child: const Text("Abmelden"),
onPressed: () {
SharedPreferences.getInstance().then((value) => {
value.clear(),
}).then((value) => {
Provider.of<AccountModel>(context, listen: false).logout(),
Navigator.popUntil(context, (route) => !Navigator.canPop(context)),
});
}
),
TextButton(
child: const Text("Abbrechen"),
onPressed: () {
Navigator.pop(context);
},
),
],
)));
},
),
Consumer<ServerInfoPacket>(
builder: (context, serverInfo, child) {
return ListTile(
leading: const Icon(Icons.home_work_outlined),
title: Text("Server: ${serverInfo.serverName}"),
subtitle: Text(
"Betreiber: ${serverInfo.serverOwner}\n"
"Serverversion: ${serverInfo.serverVersion}\n"
"Rechtliche hinweise: ${serverInfo.legal}\n"
),
);
},
)
],
),
);
}
}