Skip to content

Commit

Permalink
add login and register
Browse files Browse the repository at this point in the history
  • Loading branch information
HubOl01 committed Apr 5, 2023
1 parent 82bb0f7 commit bb71ab1
Show file tree
Hide file tree
Showing 39 changed files with 2,113 additions and 1,080 deletions.
6 changes: 3 additions & 3 deletions mobile/student_simulator_app/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Student simulator
# Student's Life

Student Simulator, 2D, mobile app
Мобильное приложение — 2FA, мессенджера, платформа для доступа к игре
Expand All @@ -14,8 +14,8 @@ Student Simulator, 2D, mobile app
- Форумы/чаты
- Направленность, например, по кланам

### Дизайн приложения:
- [Настройки](https://github.com/ISUCT/2-147-January-May-2023/issues/25#issuecomment-1448242704)
<!-- ### APIs (откуда взято)
http://80.90.188.52:8080/docs/ -->

### Схема
![arch_app](https://user-images.githubusercontent.com/56484404/220780664-e614a975-c781-47e4-964b-49b768447bee.png)
Expand Down
Binary file added mobile/student_simulator_app/flutter_24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile/student_simulator_app/flutter_25.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions mobile/student_simulator_app/lib/APIs/get_news.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import 'dart:convert';

import 'package:http/http.dart' as http;
import '../news/Model/2/newsModel.dart';

var getResNews;
List<Datum> listNews= [];
List<Datum> listNewsImage = [];
bool isDataNews = true;
bool isDataNewsLoading = true;
Future getNews() async {
isDataNews = true;
String url = "http://80.90.188.52/api/news";
http.Response res = await http.get(Uri.parse(url));
try {
if (res.statusCode == 200) {
// var response = jsonDecode(res.body);
isDataNews = false;
isDataNewsLoading = false;

// List<NewsModel> tempList = [];
// var getn;
getResNews = newsModelFromJson(res.body);
listNews = getResNews.data;
// listNewsImage = lis;
// listNewsImage = List.generate(5, (index) => listNews[index], growable: true);

// for(var v in getResNews){
// tempList.add(v);
// }
// getResNews = response as List;
// print("getNews: ${getResNews[0].id}");
print("getNews: ${res.statusCode}");
print("resNews: ${getResNews.data.first.idNews.toString()}");
print("resListNews: ${listNews.first.idNews.toString()}");
// Future.delayed(Duration(seconds: 3), () {
// getn = getResNews;
// });
// return NewsModel.newsSnapshot(tempList).toList();
return listNews;
} else {
isDataNews = true;
isDataNewsLoading = true;
print("Not getNews");
// return [];
}
} catch (e) {
isDataNews = true;
isDataNewsLoading = true;
print("excep(getNews) = $e");
print("Recorted(getNews): ${res.statusCode}");
// return [];
// return [];
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import 'package:http/http.dart' as http;

Future postFGuide(String url_f, String type, String guide_id, String thumbnail) async {
bool isPostFGuide = false;
Future postFGuide(
String url_f, String type, String guide_id, String thumbnail) async {
// isPostFGuide = false;
String url = "http://94.154.11.154/api/posts/FGuide.php";
var res = await http.post(Uri.parse(url), body: {
"url_f": url_f,
Expand All @@ -10,22 +13,23 @@ Future postFGuide(String url_f, String type, String guide_id, String thumbnail)
});
try {
if (res.statusCode == 201) {
isPostFGuide = true;
print("PostFGuide: ${res.statusCode.toString()}");
} else {
isPostFGuide = false;
print("Not PostFGuide: ${res.statusCode.toString()}");
}
} catch (e) {
} catch (e) {
isPostFGuide = false;
print("excep(PostFGuide) = $e");
print("Recorted(PostFGuide): ${res.statusCode}");
}
}

Future deleteFGuide(int id) async {
String url = "http://94.154.11.154/api/posts/deleteFGuide.php";
var res = await http.post(Uri.parse(url), body: {
'id': id
});
try {
var res = await http.post(Uri.parse(url), body: {'id': id});
try {
if (res.statusCode == 202) {
print("deleteFGuide: ${res.statusCode.toString()}");
} else {
Expand All @@ -39,11 +43,8 @@ Future deleteFGuide(int id) async {

Future updateFGuide(String id, String url_f, String thumbnail) async {
String url = "http://94.154.11.154/api/posts/updateFGuide.php";
var res = await http.post(Uri.parse(url), body: {
"id": id,
"url_f": url_f,
"thumbnail": thumbnail
});
var res = await http.post(Uri.parse(url),
body: {"id": id, "url_f": url_f, "thumbnail": thumbnail});
try {
if (res.statusCode == 202) {
print("updateFGuide: ${res.statusCode.toString()}");
Expand All @@ -54,4 +55,4 @@ Future updateFGuide(String id, String url_f, String thumbnail) async {
print("excep(updateFGuide) = $e");
print("Recorted(updateFGuide): ${res.statusCode}");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import 'package:http/http.dart' as http;

bool isPostFNews = false;
Future postFNews(
String url_f, String type, String news_id, String thumbnail) async {
// isPostFNews = false;
String url = "http://94.154.11.154/api/posts/FNews.php";
var res = await http.post(Uri.parse(url), body: {
"url_f": url_f,
Expand All @@ -12,10 +13,13 @@ Future postFNews(
try {
if (res.statusCode == 201) {
print("PostFNews: ${res.statusCode.toString()}");
isPostFNews = true;
} else {
isPostFNews = false;
print("Not PostFNews: ${res.statusCode.toString()}");
}
} catch (e) {
isPostFNews = false;
print("excep(PostFNews) = $e");
print("Recorted(PostFNews): ${res.statusCode}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var getResGuide;
var response;
bool isData = false;
Future getGuide() async {
// isData = false;
String url = "http://94.154.11.154/api/posts/Guide.php";
var res = await http.get(Uri.parse(url));
try {
Expand All @@ -28,6 +29,7 @@ Future getGuide() async {
}
}

bool isPostGuide = false;
Future postGuide(String name, String desc) async {
String url = "http://94.154.11.154/api/posts/Guide.php";
var res = await http.post(Uri.parse(url), body: {
Expand All @@ -36,11 +38,14 @@ Future postGuide(String name, String desc) async {
});
try {
if (res.statusCode == 201) {
isPostGuide = true;
print("PostGuide: ${res.statusCode.toString()}");
} else {
isPostGuide = false;
print("Not PostGuide: ${res.statusCode.toString()}");
}
} catch (e) {
isPostGuide = false;
print("excep(PostGuide) = $e");
print("Recorted(PostGuide): ${res.statusCode}");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
import '../news/Model/newsModel.dart';
import '../news/Model/1/newsModel.dart';

List<NewsModel> getResNews = [];
bool isDataNews = true;
bool isDataNewsLoading = true;
Future <List<NewsModel>> getNews() async {
isDataNews = true;
String url = "http://94.154.11.154/api/posts/News.php";
var res = await http.get(Uri.parse(url));
try {
if (res.statusCode == 200) {
// var response = jsonDecode(res.body);
isDataNews = false;
isDataNewsLoading = false;
// List<NewsModel> tempList = [];
getResNews = newsModelFromJson(res.body);
// for(var v in getResNews){
Expand All @@ -19,16 +22,19 @@ Future <List<NewsModel>> getNews() async {
// getResNews = response as List;
// print("getNews: ${getResNews[0].id}");
print("getNews: ${res.statusCode}");
print("resNews: ${getResNews.first.toJson()}");
// return NewsModel.newsSnapshot(tempList).toList();
return getResNews;
} else {
isDataNews = true;
isDataNewsLoading = true;
print("Not getNews");
// return [];
return [];
}
} catch (e) {
isDataNews = true;
isDataNewsLoading = true;
print("excep(getNews) = $e");
print("Recorted(getNews): ${res.statusCode}");
// return [];
Expand Down Expand Up @@ -58,8 +64,9 @@ Future getNewsImage() async {
print("Recorted(getNewsImage): ${res.statusCode}");
}
}

bool isPostNews = false;
Future postNews(String name, String desc) async {
isPostNews = false;
String url = "http://94.154.11.154/api/posts/News.php";
var res = await http.post(Uri.parse(url), body: {
"name_n": name,
Expand All @@ -68,11 +75,14 @@ Future postNews(String name, String desc) async {
});
try {
if (res.statusCode == 201) {
isPostNews = true;
print("PostNews: ${res.statusCode.toString()}");
} else {
isPostNews = false;
print("Not PostNews: ${res.statusCode.toString()}");
}
} catch (e) {
isPostNews = false;
print("excep(PostNews) = $e");
print("Recorted(PostNews): ${res.statusCode}");
}
Expand Down
14 changes: 9 additions & 5 deletions mobile/student_simulator_app/lib/Styles/Themes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class Themes {
}),
trackColor: MaterialStateProperty.all(Colors.blue.withOpacity(0.2)),
),
dialogTheme: DialogTheme(titleTextStyle: TextStyle(color: textColorDark, fontSize: 25, fontWeight: FontWeight.bold)),
);


Expand All @@ -90,6 +91,7 @@ class Themes {
bodySmall: TextStyle(backgroundColor: subColor)),
backgroundColor: backgroundColor,
dialogBackgroundColor: backgroundColor,
dialogTheme: DialogTheme(titleTextStyle: TextStyle(color: textColor, fontSize: 25, fontWeight: FontWeight.bold)),
// colorSchemeSeed: Colors.black,
// colorScheme: ColorScheme(
// brightness: Brightness.light,
Expand Down Expand Up @@ -135,11 +137,13 @@ class Themes {
);
}

class ThemeProvider extends ChangeNotifier {
ThemeMode themeMode = ThemeMode.system;
bool get isDarkMode => themeMode == ThemeMode.dark;
void toggleTheme(dynamic isOn) {
themeMode = isOn == 2 ? ThemeMode.dark : isOn == 1 ? ThemeMode.light : ThemeMode.system;
class ThemeProvider with ChangeNotifier {
ThemeMode _themeMode = ThemeMode.system;
ThemeMode get themeMode => _themeMode;
// bool get isDarkMode => themeMode == ThemeMode.dark;
void toggleTheme(themeMode) {
// themeMode = isOn == 2 ? ThemeMode.dark : isOn == 1 ? ThemeMode.light : ThemeMode.system;
_themeMode = themeMode;
notifyListeners();
}
// bool isOn = false;
Expand Down
Loading

0 comments on commit bb71ab1

Please sign in to comment.