-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(+) Login (+) Splash Screen
- Loading branch information
Showing
19 changed files
with
1,011 additions
and
140 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,27 @@ | ||
// app_widget.dart | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:flutter_modular/flutter_modular.dart'; | ||
import 'package:unord/blocs/auth_bloc.dart'; | ||
import 'package:unord/blocs/user_bloc.dart'; | ||
import 'package:unord/theme/styles.dart'; | ||
|
||
class AppWidget extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
initialRoute: "/", | ||
navigatorKey: Modular.navigatorKey, | ||
onGenerateRoute: Modular.generateRoute, | ||
themeMode: ThemeMode.light, | ||
theme: CustomTheme.lightTheme, | ||
darkTheme: CustomTheme.darkTheme, | ||
return MultiBlocProvider( | ||
providers: [ | ||
BlocProvider<AuthBloc>(create: (context) => Modular.get<AuthBloc>()), | ||
BlocProvider<UserBloc>(create: (context) => Modular.get<UserBloc>()), | ||
], | ||
child: MaterialApp( | ||
initialRoute: "/", | ||
navigatorKey: Modular.navigatorKey, | ||
onGenerateRoute: Modular.generateRoute, | ||
themeMode: ThemeMode.light, | ||
theme: CustomTheme.lightTheme, | ||
darkTheme: CustomTheme.darkTheme, | ||
), | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:hive/hive.dart'; | ||
import 'package:unord/data/constants.dart'; | ||
|
||
class AuthBloc extends Bloc<String, String> { | ||
@override | ||
String get initialState => | ||
Hive.box(boxName).get('access_token', defaultValue: null); | ||
|
||
@override | ||
Stream<String> mapEventToState(String event) async* { | ||
yield event; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:hive/hive.dart'; | ||
import 'package:unord/data/constants.dart'; | ||
|
||
class UserBloc extends Bloc<Map, Map> { | ||
@override | ||
Map get initialState => | ||
Hive.box(boxName).get('user_data', defaultValue: null); | ||
|
||
@override | ||
Stream<Map> mapEventToState(Map event) async* { | ||
yield event; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
mixin URLs { | ||
static const String host = 'http://192.168.43.233:1337/'; | ||
} | ||
|
||
mixin AppLimit { | ||
static const int REQUEST_TIME_OUT = 30000; | ||
static const int ALBUM_PAGE_SIZE = 18; | ||
static const int POST_PAGE_SIZE = 100; | ||
} | ||
|
||
const String sentryDSN = ''; | ||
const String appVersion = '0.0.1'; | ||
const String environment = 'Production'; | ||
|
||
const boxName = 'unord'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import 'package:hive/hive.dart'; | ||
import 'package:unord/data/constants.dart'; | ||
|
||
abstract class DatabaseHelper { | ||
DatabaseHelper() { | ||
box = Hive.box(boxName); | ||
} | ||
|
||
Box box; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import 'package:dio/dio.dart'; | ||
import 'package:unord/data/constants.dart'; | ||
|
||
class NetworkHelper { | ||
NetworkHelper() { | ||
_dio = Dio(BaseOptions( | ||
baseUrl: URLs.host, | ||
connectTimeout: AppLimit.REQUEST_TIME_OUT, | ||
receiveTimeout: AppLimit.REQUEST_TIME_OUT, | ||
sendTimeout: AppLimit.REQUEST_TIME_OUT, | ||
headers: { | ||
// 'Authorization': 'Bearer ' + | ||
// 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiaWF0IjoxNjAwNzAwMDA4LCJleHAiOjE2MDMyOTIwMDh9.nOpjJC_uPITttSp8kji_NTnoFvpiJzbIoJ-Rib0UJtQ', | ||
"Content-Type": "multipart/form-data" | ||
}, | ||
validateStatus: (status) { | ||
return status < 500; | ||
}, | ||
)); | ||
} | ||
|
||
Dio _dio; | ||
|
||
Future<dynamic> get(String url) async { | ||
dynamic response; | ||
try { | ||
response = await _dio.get<dynamic>(url); | ||
} catch (err) { | ||
rethrow; | ||
} | ||
return response; | ||
} | ||
|
||
Future<dynamic> post(String url, dynamic data) async { | ||
dynamic response; | ||
try { | ||
response = await _dio.post<dynamic>(url, data: data); | ||
} on DioError catch (err) { | ||
if (err is DioError) { | ||
} else {} | ||
} | ||
return response; | ||
} | ||
|
||
Future<dynamic> put(String url, dynamic data) async { | ||
dynamic response; | ||
try { | ||
response = await _dio.put<dynamic>(url, data: data); | ||
} catch (err) { | ||
rethrow; | ||
} | ||
return response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,16 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_modular/flutter_modular.dart'; | ||
import 'package:hive/hive.dart'; | ||
import 'package:path_provider/path_provider.dart'; | ||
import 'package:unord/data/constants.dart'; | ||
|
||
import 'app/app_module.dart'; | ||
|
||
void main() => runApp(ModularApp(module: AppModule())); | ||
void main() async { | ||
WidgetsFlutterBinding.ensureInitialized(); | ||
|
||
Hive..init((await getApplicationDocumentsDirectory()).path); | ||
await Hive.openBox(boxName); | ||
|
||
runApp(ModularApp(module: AppModule())); | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.