Initial Commit
This commit is contained in:
144
web_native/lib/api/api_provider.dart
Normal file
144
web_native/lib/api/api_provider.dart
Normal file
@@ -0,0 +1,144 @@
|
||||
import 'dart:async';
|
||||
|
||||
// ignore: uri_does_not_exist
|
||||
import 'cookie_client_stub.dart'
|
||||
// ignore: uri_does_not_exist
|
||||
if (dart.library.html) 'browser_cookie_client.dart'
|
||||
// ignore: uri_does_not_exist
|
||||
if (dart.library.io) 'io_cookie_client.dart';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:graphql_flutter/graphql_flutter.dart';
|
||||
import 'package:imagini/graphql/imagini_graphql.dart';
|
||||
|
||||
class APIProvider{
|
||||
String _server, _accessToken, _refreshToken;
|
||||
|
||||
GraphQLClient _client;
|
||||
HttpLink httpLink;
|
||||
// CookieLink cookieLink;
|
||||
static const String _GRAPHQL_ENDPOINT = "/query";
|
||||
|
||||
APIProvider({
|
||||
@required String server,
|
||||
String accessToken,
|
||||
String refreshToken
|
||||
}) {
|
||||
_server = server;
|
||||
_accessToken = accessToken;
|
||||
_refreshToken = refreshToken;
|
||||
httpLink = HttpLink(_server + _GRAPHQL_ENDPOINT,
|
||||
httpClient: getCookieClient(),
|
||||
);
|
||||
|
||||
// cookieLink = CookieLink(_updateAccessToken, _updateRefreshToken);
|
||||
_client = GraphQLClient(
|
||||
cache: GraphQLCache(),
|
||||
link: httpLink,
|
||||
);
|
||||
}
|
||||
|
||||
// void _updateAccessToken(_accessToken) {
|
||||
// print("Updating Access Token: $_accessToken");
|
||||
// this._accessToken = _accessToken;
|
||||
// }
|
||||
|
||||
// void _updateRefreshToken(_refreshToken) {
|
||||
// print("Updating Refresh Token: $_accessToken");
|
||||
// this._refreshToken = _refreshToken;
|
||||
// }
|
||||
|
||||
Future<Login$Query$AuthResponse> login([
|
||||
String username,
|
||||
String password,
|
||||
]) async {
|
||||
assert(
|
||||
(username != null && password != null)
|
||||
);
|
||||
|
||||
QueryResult response = await _client.query(
|
||||
QueryOptions(
|
||||
document: LoginQuery().document,
|
||||
variables: {
|
||||
"user": username,
|
||||
"password": password
|
||||
},
|
||||
)
|
||||
);
|
||||
|
||||
final loginResponse = Login$Query.fromJson(response.data);
|
||||
return loginResponse.login;
|
||||
}
|
||||
|
||||
Future<Me$Query$User> me() async {
|
||||
QueryResult response = await _client.query(
|
||||
QueryOptions(
|
||||
document: MeQuery().document,
|
||||
)
|
||||
);
|
||||
|
||||
final meResponse = Me$Query.fromJson(response.data);
|
||||
return meResponse.me;
|
||||
}
|
||||
|
||||
Future<String> mediaItems([
|
||||
String startDate,
|
||||
String endDate,
|
||||
String albumID,
|
||||
List<String> tagID,
|
||||
String type, // TODO: Make enum
|
||||
int page,
|
||||
]) async {
|
||||
// Query:
|
||||
// /api/v1/MediaItems
|
||||
// Derive Params:
|
||||
// startDate:
|
||||
// &createdAt=>2020-10-10T10:10:10
|
||||
// endDate:
|
||||
// &createdAt=<2020-10-10T10:10:10
|
||||
// albumID:
|
||||
// &albumID=9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d
|
||||
// tagID:
|
||||
// &tagID=9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d,9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d
|
||||
// type:
|
||||
// &type=Photos
|
||||
// &type=Videos
|
||||
// page:
|
||||
// &page=4
|
||||
|
||||
// Returns:
|
||||
// {
|
||||
//
|
||||
// }
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<String> tags([
|
||||
int page
|
||||
]) async {
|
||||
// Query:
|
||||
// /api/v1/Tags
|
||||
// Derive Params:
|
||||
// page:
|
||||
// &page=4
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<String> albums([
|
||||
int page
|
||||
]) async {
|
||||
// Query:
|
||||
// /api/v1/Albums
|
||||
// Derive Params:
|
||||
// page:
|
||||
// &page=4
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<String> me() async {
|
||||
return null;
|
||||
}
|
||||
|
||||
void dispose() {}
|
||||
}
|
||||
30
web_native/lib/api/browser_cookie_client.dart
Normal file
30
web_native/lib/api/browser_cookie_client.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
import 'package:http/browser_client.dart';
|
||||
import "package:http/http.dart";
|
||||
|
||||
BaseClient getCookieClient() => ClientWithCookies();
|
||||
|
||||
class ClientWithCookies extends BrowserClient {
|
||||
String _accessToken = "asdasdasd";
|
||||
String _refreshToken;
|
||||
|
||||
@override
|
||||
Future<StreamedResponse> send(BaseRequest request) async {
|
||||
request.headers.addAll({
|
||||
'X-Imagini-AccessToken': _accessToken,
|
||||
'X-Imagini-RefreshToken': _refreshToken,
|
||||
});
|
||||
|
||||
return super.send(request).then((response) {
|
||||
if (response.headers.containsKey("x-imagini-accesstoken")) {
|
||||
this._accessToken = response.headers["x-imagini-accesstoken"];
|
||||
}
|
||||
if (response.headers.containsKey("x-imagini-refreshtoken")) {
|
||||
this._refreshToken = response.headers["x-imagini-refreshtoken"];
|
||||
}
|
||||
|
||||
print("Access Token: $_accessToken");
|
||||
print("Refresh Token: $_refreshToken");
|
||||
return response;
|
||||
});
|
||||
}
|
||||
}
|
||||
4
web_native/lib/api/cookie_client_stub.dart
Normal file
4
web_native/lib/api/cookie_client_stub.dart
Normal file
@@ -0,0 +1,4 @@
|
||||
import 'package:http/http.dart';
|
||||
|
||||
BaseClient getCookieClient() => throw UnsupportedError(
|
||||
'Cannot create a client without dart:html or dart:io.');
|
||||
12
web_native/lib/api/imagini_api_repository.dart
Normal file
12
web_native/lib/api/imagini_api_repository.dart
Normal file
@@ -0,0 +1,12 @@
|
||||
import 'package:imagini/api/api_provider.dart';
|
||||
import 'package:imagini/graphql/imagini_graphql.dart';
|
||||
|
||||
class ImaginiAPIRepository {
|
||||
APIProvider _apiProvider;
|
||||
|
||||
ImaginiAPIRepository(this._apiProvider);
|
||||
|
||||
Stream<Login$Query$AuthResponse> login(String user, password) {
|
||||
return Stream.fromFuture(_apiProvider.login(user, password));
|
||||
}
|
||||
}
|
||||
28
web_native/lib/api/io_cookie_client.dart
Normal file
28
web_native/lib/api/io_cookie_client.dart
Normal file
@@ -0,0 +1,28 @@
|
||||
import 'package:http/io_client.dart';
|
||||
import "package:http/http.dart";
|
||||
|
||||
BaseClient getCookieClient() => IOClientWithCookies();
|
||||
|
||||
class IOClientWithCookies extends IOClient {
|
||||
String _accessToken;
|
||||
String _refreshToken;
|
||||
|
||||
@override
|
||||
Future<IOStreamedResponse> send(BaseRequest request) async {
|
||||
// String cookie = await getCookie();
|
||||
// String getCookieString(String _) => cookie;
|
||||
// request.headers.update('cookie', getCookieString);
|
||||
return super.send(request).then((response) {
|
||||
if (response.headers.containsKey("x-imagini-accesstoken")) {
|
||||
this._accessToken = response.headers["x-imagini-accesstoken"];
|
||||
}
|
||||
if (response.headers.containsKey("x-imagini-refreshtoken")) {
|
||||
this._refreshToken = response.headers["x-imagini-refreshtoken"];
|
||||
}
|
||||
|
||||
print("Access Token: $_accessToken");
|
||||
print("Refresh Token: $_refreshToken");
|
||||
return response;
|
||||
});
|
||||
}
|
||||
}
|
||||
36
web_native/lib/blocs/splash_bloc.dart
Normal file
36
web_native/lib/blocs/splash_bloc.dart
Normal file
@@ -0,0 +1,36 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:imagini/core/imagini_application.dart';
|
||||
import 'package:imagini/api/imagini_api_repository.dart';
|
||||
import 'package:imagini/graphql/imagini_graphql.dart';
|
||||
|
||||
class SplashBloc{
|
||||
|
||||
final ImaginiApplication _application;
|
||||
|
||||
final _loginController = StreamController<Login$Query$AuthResponse>();
|
||||
Stream<Login$Query$AuthResponse> get loginResult => _loginController.stream;
|
||||
|
||||
SplashBloc(this._application){
|
||||
_init();
|
||||
}
|
||||
|
||||
void _init(){
|
||||
// Do Initial Load
|
||||
initializeLogin();
|
||||
}
|
||||
|
||||
void dispose(){
|
||||
_loginController.close();
|
||||
}
|
||||
|
||||
initializeLogin(){
|
||||
ImaginiAPIRepository imaginiAPI = _application.imaginiAPI;
|
||||
|
||||
// TODO: This should actually attempt to load the existing Tokens, not login
|
||||
_loginController.addStream(imaginiAPI.login("admin", "admin"));
|
||||
|
||||
// imaginiAPI.login("admin", "admin1").listen((LoginResponse lr) {
|
||||
// });
|
||||
}
|
||||
}
|
||||
48
web_native/lib/core/app_component.dart
Normal file
48
web_native/lib/core/app_component.dart
Normal file
@@ -0,0 +1,48 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:imagini/core/env.dart';
|
||||
import 'package:imagini/core/app_provider.dart';
|
||||
import 'package:imagini/core/imagini_application.dart';
|
||||
|
||||
class AppComponent extends StatefulWidget {
|
||||
|
||||
final ImaginiApplication _application;
|
||||
|
||||
AppComponent(this._application);
|
||||
|
||||
@override
|
||||
State createState() {
|
||||
return new AppComponentState(_application);
|
||||
}
|
||||
}
|
||||
|
||||
class AppComponentState extends State<AppComponent> {
|
||||
|
||||
final ImaginiApplication _application;
|
||||
|
||||
AppComponentState(this._application);
|
||||
|
||||
@override
|
||||
void dispose() async {
|
||||
// Log.info('dispose');
|
||||
super.dispose();
|
||||
await _application.onTerminate();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
final app = new MaterialApp(
|
||||
title: Env.value.appName,
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: new ThemeData(
|
||||
primarySwatch: Colors.blue,
|
||||
),
|
||||
onGenerateRoute: _application.router.generator,
|
||||
);
|
||||
print('initial core.route = ${app.initialRoute}');
|
||||
|
||||
final appProvider = AppProvider(child: app, application: _application);
|
||||
return appProvider;
|
||||
}
|
||||
}
|
||||
27
web_native/lib/core/app_provider.dart
Normal file
27
web_native/lib/core/app_provider.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluro/fluro.dart';
|
||||
|
||||
import 'package:imagini/core/imagini_application.dart';
|
||||
|
||||
class AppProvider extends InheritedWidget {
|
||||
|
||||
final ImaginiApplication application;
|
||||
|
||||
AppProvider({Key key, Widget child, this.application})
|
||||
: super(key: key, child: child);
|
||||
|
||||
bool updateShouldNotify(_) => true;
|
||||
|
||||
static AppProvider of(BuildContext context) {
|
||||
return context.dependOnInheritedWidgetOfExactType<AppProvider>();
|
||||
}
|
||||
|
||||
static FluroRouter getRouter(BuildContext context) {
|
||||
return context.dependOnInheritedWidgetOfExactType<AppProvider>().application.router;
|
||||
}
|
||||
|
||||
static ImaginiApplication getApplication(BuildContext context) {
|
||||
return context.dependOnInheritedWidgetOfExactType<AppProvider>().application;
|
||||
}
|
||||
|
||||
}
|
||||
50
web_native/lib/core/app_routes.dart
Normal file
50
web_native/lib/core/app_routes.dart
Normal file
@@ -0,0 +1,50 @@
|
||||
import 'package:fluro/fluro.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:imagini/screens/home_screen.dart';
|
||||
import 'package:imagini/screens/login_screen.dart';
|
||||
import 'package:imagini/screens/splash_screen.dart';
|
||||
|
||||
var splashHandler = new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
return SplashScreen();
|
||||
}
|
||||
);
|
||||
|
||||
var loginHandler = new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
return LoginScreen();
|
||||
}
|
||||
);
|
||||
|
||||
var homeHandler = new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
return HomeScreen();
|
||||
}
|
||||
);
|
||||
|
||||
// var appDetailRouteHandler = new Handler(
|
||||
// handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
// String appId = params['appId']?.first;
|
||||
// String heroTag = params['heroTag']?.first;
|
||||
// String title = params['title']?.first;
|
||||
// String url = params['url']?.first;
|
||||
// String titleTag = params['titleTag']?.first;
|
||||
//
|
||||
// return new AppDetailPage(appId: num.parse(appId), heroTag:heroTag,title: title, url: url, titleTag: titleTag);
|
||||
// });
|
||||
|
||||
class AppRoutes {
|
||||
static void configureRoutes(FluroRouter router) {
|
||||
router.notFoundHandler = new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
print('ROUTE WAS NOT FOUND !!!');
|
||||
return;
|
||||
}
|
||||
);
|
||||
router.define(SplashScreen.PATH, handler: splashHandler);
|
||||
router.define(LoginScreen.PATH, handler: loginHandler);
|
||||
router.define(HomeScreen.PATH, handler: homeHandler);
|
||||
// router.define(AppDetailPage.PATH, handler: appDetailRouteHandler);
|
||||
}
|
||||
}
|
||||
21
web_native/lib/core/env.dart
Normal file
21
web_native/lib/core/env.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:imagini/core/app_component.dart';
|
||||
import 'package:imagini/core/imagini_application.dart';
|
||||
|
||||
class Env {
|
||||
static Env value;
|
||||
String appName;
|
||||
|
||||
Env() {
|
||||
value = this;
|
||||
_init();
|
||||
}
|
||||
|
||||
_init() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
var application = ImaginiApplication();
|
||||
await application.onCreate();
|
||||
runApp(AppComponent(application));
|
||||
}
|
||||
}
|
||||
27
web_native/lib/core/imagini_application.dart
Normal file
27
web_native/lib/core/imagini_application.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
import 'package:fluro/fluro.dart';
|
||||
|
||||
import 'package:imagini/core/app_routes.dart';
|
||||
import 'package:imagini/api/api_provider.dart';
|
||||
import 'package:imagini/api/imagini_api_repository.dart';
|
||||
|
||||
class ImaginiApplication {
|
||||
FluroRouter router;
|
||||
ImaginiAPIRepository imaginiAPI;
|
||||
|
||||
Future<void> onCreate() async {
|
||||
_initRouter();
|
||||
_initAPIRepository();
|
||||
}
|
||||
|
||||
Future<void> onTerminate() async {}
|
||||
|
||||
_initRouter() {
|
||||
router = new FluroRouter();
|
||||
AppRoutes.configureRoutes(router);
|
||||
}
|
||||
|
||||
_initAPIRepository() {
|
||||
APIProvider apiProvider = new APIProvider(server: "http://localhost:8484");
|
||||
imaginiAPI = ImaginiAPIRepository(apiProvider);
|
||||
}
|
||||
}
|
||||
2
web_native/lib/graphql/imagini_graphql.dart
Normal file
2
web_native/lib/graphql/imagini_graphql.dart
Normal file
@@ -0,0 +1,2 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
export 'imagini_graphql.graphql.dart';
|
||||
510
web_native/lib/graphql/imagini_graphql.graphql.dart
Normal file
510
web_native/lib/graphql/imagini_graphql.graphql.dart
Normal file
@@ -0,0 +1,510 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:artemis/artemis.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:gql/ast.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:imagini/helpers/upload_serializer.dart';
|
||||
part 'imagini_graphql.graphql.g.dart';
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class Login$Query$AuthResponse$Device with EquatableMixin {
|
||||
Login$Query$AuthResponse$Device();
|
||||
|
||||
factory Login$Query$AuthResponse$Device.fromJson(Map<String, dynamic> json) =>
|
||||
_$Login$Query$AuthResponse$DeviceFromJson(json);
|
||||
|
||||
String id;
|
||||
|
||||
@override
|
||||
List<Object> get props => [id];
|
||||
Map<String, dynamic> toJson() =>
|
||||
_$Login$Query$AuthResponse$DeviceToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class Login$Query$AuthResponse with EquatableMixin {
|
||||
Login$Query$AuthResponse();
|
||||
|
||||
factory Login$Query$AuthResponse.fromJson(Map<String, dynamic> json) =>
|
||||
_$Login$Query$AuthResponseFromJson(json);
|
||||
|
||||
@JsonKey(unknownEnumValue: AuthResult.artemisUnknown)
|
||||
AuthResult result;
|
||||
|
||||
Login$Query$AuthResponse$Device device;
|
||||
|
||||
@override
|
||||
List<Object> get props => [result, device];
|
||||
Map<String, dynamic> toJson() => _$Login$Query$AuthResponseToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class Login$Query with EquatableMixin {
|
||||
Login$Query();
|
||||
|
||||
factory Login$Query.fromJson(Map<String, dynamic> json) =>
|
||||
_$Login$QueryFromJson(json);
|
||||
|
||||
Login$Query$AuthResponse login;
|
||||
|
||||
@override
|
||||
List<Object> get props => [login];
|
||||
Map<String, dynamic> toJson() => _$Login$QueryToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class CreateMediaItem$Mutation$MediaItem with EquatableMixin {
|
||||
CreateMediaItem$Mutation$MediaItem();
|
||||
|
||||
factory CreateMediaItem$Mutation$MediaItem.fromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$CreateMediaItem$Mutation$MediaItemFromJson(json);
|
||||
|
||||
String id;
|
||||
|
||||
DateTime createdAt;
|
||||
|
||||
DateTime updatedAt;
|
||||
|
||||
DateTime exifDate;
|
||||
|
||||
double latitude;
|
||||
|
||||
double longitude;
|
||||
|
||||
bool isVideo;
|
||||
|
||||
String fileName;
|
||||
|
||||
String origName;
|
||||
|
||||
String userID;
|
||||
|
||||
@override
|
||||
List<Object> get props => [
|
||||
id,
|
||||
createdAt,
|
||||
updatedAt,
|
||||
exifDate,
|
||||
latitude,
|
||||
longitude,
|
||||
isVideo,
|
||||
fileName,
|
||||
origName,
|
||||
userID
|
||||
];
|
||||
Map<String, dynamic> toJson() =>
|
||||
_$CreateMediaItem$Mutation$MediaItemToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class CreateMediaItem$Mutation with EquatableMixin {
|
||||
CreateMediaItem$Mutation();
|
||||
|
||||
factory CreateMediaItem$Mutation.fromJson(Map<String, dynamic> json) =>
|
||||
_$CreateMediaItem$MutationFromJson(json);
|
||||
|
||||
CreateMediaItem$Mutation$MediaItem createMediaItem;
|
||||
|
||||
@override
|
||||
List<Object> get props => [createMediaItem];
|
||||
Map<String, dynamic> toJson() => _$CreateMediaItem$MutationToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class Me$Query$User with EquatableMixin {
|
||||
Me$Query$User();
|
||||
|
||||
factory Me$Query$User.fromJson(Map<String, dynamic> json) =>
|
||||
_$Me$Query$UserFromJson(json);
|
||||
|
||||
String id;
|
||||
|
||||
DateTime createdAt;
|
||||
|
||||
DateTime updatedAt;
|
||||
|
||||
String email;
|
||||
|
||||
String username;
|
||||
|
||||
String firstName;
|
||||
|
||||
String lastName;
|
||||
|
||||
@JsonKey(unknownEnumValue: Role.artemisUnknown)
|
||||
Role role;
|
||||
|
||||
@JsonKey(unknownEnumValue: AuthType.artemisUnknown)
|
||||
AuthType authType;
|
||||
|
||||
@override
|
||||
List<Object> get props => [
|
||||
id,
|
||||
createdAt,
|
||||
updatedAt,
|
||||
email,
|
||||
username,
|
||||
firstName,
|
||||
lastName,
|
||||
role,
|
||||
authType
|
||||
];
|
||||
Map<String, dynamic> toJson() => _$Me$Query$UserToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class Me$Query with EquatableMixin {
|
||||
Me$Query();
|
||||
|
||||
factory Me$Query.fromJson(Map<String, dynamic> json) =>
|
||||
_$Me$QueryFromJson(json);
|
||||
|
||||
Me$Query$User me;
|
||||
|
||||
@override
|
||||
List<Object> get props => [me];
|
||||
Map<String, dynamic> toJson() => _$Me$QueryToJson(this);
|
||||
}
|
||||
|
||||
enum AuthResult {
|
||||
@JsonValue('Success')
|
||||
success,
|
||||
@JsonValue('Failure')
|
||||
failure,
|
||||
@JsonValue('ARTEMIS_UNKNOWN')
|
||||
artemisUnknown,
|
||||
}
|
||||
enum Role {
|
||||
@JsonValue('Admin')
|
||||
admin,
|
||||
@JsonValue('User')
|
||||
user,
|
||||
@JsonValue('ARTEMIS_UNKNOWN')
|
||||
artemisUnknown,
|
||||
}
|
||||
enum AuthType {
|
||||
@JsonValue('Local')
|
||||
local,
|
||||
@JsonValue('LDAP')
|
||||
ldap,
|
||||
@JsonValue('ARTEMIS_UNKNOWN')
|
||||
artemisUnknown,
|
||||
}
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class LoginArguments extends JsonSerializable with EquatableMixin {
|
||||
LoginArguments({@required this.user, @required this.password, this.deviceID});
|
||||
|
||||
@override
|
||||
factory LoginArguments.fromJson(Map<String, dynamic> json) =>
|
||||
_$LoginArgumentsFromJson(json);
|
||||
|
||||
final String user;
|
||||
|
||||
final String password;
|
||||
|
||||
final String deviceID;
|
||||
|
||||
@override
|
||||
List<Object> get props => [user, password, deviceID];
|
||||
@override
|
||||
Map<String, dynamic> toJson() => _$LoginArgumentsToJson(this);
|
||||
}
|
||||
|
||||
class LoginQuery extends GraphQLQuery<Login$Query, LoginArguments> {
|
||||
LoginQuery({this.variables});
|
||||
|
||||
@override
|
||||
final DocumentNode document = DocumentNode(definitions: [
|
||||
OperationDefinitionNode(
|
||||
type: OperationType.query,
|
||||
name: NameNode(value: 'login'),
|
||||
variableDefinitions: [
|
||||
VariableDefinitionNode(
|
||||
variable: VariableNode(name: NameNode(value: 'user')),
|
||||
type: NamedTypeNode(
|
||||
name: NameNode(value: 'String'), isNonNull: true),
|
||||
defaultValue: DefaultValueNode(value: null),
|
||||
directives: []),
|
||||
VariableDefinitionNode(
|
||||
variable: VariableNode(name: NameNode(value: 'password')),
|
||||
type: NamedTypeNode(
|
||||
name: NameNode(value: 'String'), isNonNull: true),
|
||||
defaultValue: DefaultValueNode(value: null),
|
||||
directives: []),
|
||||
VariableDefinitionNode(
|
||||
variable: VariableNode(name: NameNode(value: 'deviceID')),
|
||||
type:
|
||||
NamedTypeNode(name: NameNode(value: 'ID'), isNonNull: false),
|
||||
defaultValue: DefaultValueNode(value: null),
|
||||
directives: [])
|
||||
],
|
||||
directives: [],
|
||||
selectionSet: SelectionSetNode(selections: [
|
||||
FieldNode(
|
||||
name: NameNode(value: 'login'),
|
||||
alias: null,
|
||||
arguments: [
|
||||
ArgumentNode(
|
||||
name: NameNode(value: 'user'),
|
||||
value: VariableNode(name: NameNode(value: 'user'))),
|
||||
ArgumentNode(
|
||||
name: NameNode(value: 'password'),
|
||||
value: VariableNode(name: NameNode(value: 'password'))),
|
||||
ArgumentNode(
|
||||
name: NameNode(value: 'deviceID'),
|
||||
value: VariableNode(name: NameNode(value: 'deviceID')))
|
||||
],
|
||||
directives: [],
|
||||
selectionSet: SelectionSetNode(selections: [
|
||||
FieldNode(
|
||||
name: NameNode(value: 'result'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'device'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: SelectionSetNode(selections: [
|
||||
FieldNode(
|
||||
name: NameNode(value: 'id'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null)
|
||||
]))
|
||||
]))
|
||||
]))
|
||||
]);
|
||||
|
||||
@override
|
||||
final String operationName = 'login';
|
||||
|
||||
@override
|
||||
final LoginArguments variables;
|
||||
|
||||
@override
|
||||
List<Object> get props => [document, operationName, variables];
|
||||
@override
|
||||
Login$Query parse(Map<String, dynamic> json) => Login$Query.fromJson(json);
|
||||
}
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class CreateMediaItemArguments extends JsonSerializable with EquatableMixin {
|
||||
CreateMediaItemArguments({@required this.file});
|
||||
|
||||
@override
|
||||
factory CreateMediaItemArguments.fromJson(Map<String, dynamic> json) =>
|
||||
_$CreateMediaItemArgumentsFromJson(json);
|
||||
|
||||
@JsonKey(
|
||||
fromJson: fromGraphQLUploadToDartMultipartFile,
|
||||
toJson: fromDartMultipartFileToGraphQLUpload)
|
||||
final MultipartFile file;
|
||||
|
||||
@override
|
||||
List<Object> get props => [file];
|
||||
@override
|
||||
Map<String, dynamic> toJson() => _$CreateMediaItemArgumentsToJson(this);
|
||||
}
|
||||
|
||||
class CreateMediaItemMutation
|
||||
extends GraphQLQuery<CreateMediaItem$Mutation, CreateMediaItemArguments> {
|
||||
CreateMediaItemMutation({this.variables});
|
||||
|
||||
@override
|
||||
final DocumentNode document = DocumentNode(definitions: [
|
||||
OperationDefinitionNode(
|
||||
type: OperationType.mutation,
|
||||
name: NameNode(value: 'createMediaItem'),
|
||||
variableDefinitions: [
|
||||
VariableDefinitionNode(
|
||||
variable: VariableNode(name: NameNode(value: 'file')),
|
||||
type: NamedTypeNode(
|
||||
name: NameNode(value: 'Upload'), isNonNull: true),
|
||||
defaultValue: DefaultValueNode(value: null),
|
||||
directives: [])
|
||||
],
|
||||
directives: [],
|
||||
selectionSet: SelectionSetNode(selections: [
|
||||
FieldNode(
|
||||
name: NameNode(value: 'createMediaItem'),
|
||||
alias: null,
|
||||
arguments: [
|
||||
ArgumentNode(
|
||||
name: NameNode(value: 'input'),
|
||||
value: ObjectValueNode(fields: [
|
||||
ObjectFieldNode(
|
||||
name: NameNode(value: 'file'),
|
||||
value: VariableNode(name: NameNode(value: 'file')))
|
||||
]))
|
||||
],
|
||||
directives: [],
|
||||
selectionSet: SelectionSetNode(selections: [
|
||||
FieldNode(
|
||||
name: NameNode(value: 'id'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'createdAt'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'updatedAt'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'exifDate'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'latitude'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'longitude'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'isVideo'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'fileName'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'origName'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'userID'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null)
|
||||
]))
|
||||
]))
|
||||
]);
|
||||
|
||||
@override
|
||||
final String operationName = 'createMediaItem';
|
||||
|
||||
@override
|
||||
final CreateMediaItemArguments variables;
|
||||
|
||||
@override
|
||||
List<Object> get props => [document, operationName, variables];
|
||||
@override
|
||||
CreateMediaItem$Mutation parse(Map<String, dynamic> json) =>
|
||||
CreateMediaItem$Mutation.fromJson(json);
|
||||
}
|
||||
|
||||
class MeQuery extends GraphQLQuery<Me$Query, JsonSerializable> {
|
||||
MeQuery();
|
||||
|
||||
@override
|
||||
final DocumentNode document = DocumentNode(definitions: [
|
||||
OperationDefinitionNode(
|
||||
type: OperationType.query,
|
||||
name: NameNode(value: 'me'),
|
||||
variableDefinitions: [],
|
||||
directives: [],
|
||||
selectionSet: SelectionSetNode(selections: [
|
||||
FieldNode(
|
||||
name: NameNode(value: 'me'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: SelectionSetNode(selections: [
|
||||
FieldNode(
|
||||
name: NameNode(value: 'id'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'createdAt'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'updatedAt'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'email'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'username'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'firstName'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'lastName'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'role'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null),
|
||||
FieldNode(
|
||||
name: NameNode(value: 'authType'),
|
||||
alias: null,
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null)
|
||||
]))
|
||||
]))
|
||||
]);
|
||||
|
||||
@override
|
||||
final String operationName = 'me';
|
||||
|
||||
@override
|
||||
List<Object> get props => [document, operationName];
|
||||
@override
|
||||
Me$Query parse(Map<String, dynamic> json) => Me$Query.fromJson(json);
|
||||
}
|
||||
221
web_native/lib/graphql/imagini_graphql.graphql.g.dart
Normal file
221
web_native/lib/graphql/imagini_graphql.graphql.g.dart
Normal file
@@ -0,0 +1,221 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'imagini_graphql.graphql.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Login$Query$AuthResponse$Device _$Login$Query$AuthResponse$DeviceFromJson(
|
||||
Map<String, dynamic> json) {
|
||||
return Login$Query$AuthResponse$Device()..id = json['id'] as String;
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$Login$Query$AuthResponse$DeviceToJson(
|
||||
Login$Query$AuthResponse$Device instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
};
|
||||
|
||||
Login$Query$AuthResponse _$Login$Query$AuthResponseFromJson(
|
||||
Map<String, dynamic> json) {
|
||||
return Login$Query$AuthResponse()
|
||||
..result = _$enumDecodeNullable(_$AuthResultEnumMap, json['result'],
|
||||
unknownValue: AuthResult.artemisUnknown)
|
||||
..device = json['device'] == null
|
||||
? null
|
||||
: Login$Query$AuthResponse$Device.fromJson(
|
||||
json['device'] as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$Login$Query$AuthResponseToJson(
|
||||
Login$Query$AuthResponse instance) =>
|
||||
<String, dynamic>{
|
||||
'result': _$AuthResultEnumMap[instance.result],
|
||||
'device': instance.device?.toJson(),
|
||||
};
|
||||
|
||||
T _$enumDecode<T>(
|
||||
Map<T, dynamic> enumValues,
|
||||
dynamic source, {
|
||||
T unknownValue,
|
||||
}) {
|
||||
if (source == null) {
|
||||
throw ArgumentError('A value must be provided. Supported values: '
|
||||
'${enumValues.values.join(', ')}');
|
||||
}
|
||||
|
||||
final value = enumValues.entries
|
||||
.singleWhere((e) => e.value == source, orElse: () => null)
|
||||
?.key;
|
||||
|
||||
if (value == null && unknownValue == null) {
|
||||
throw ArgumentError('`$source` is not one of the supported values: '
|
||||
'${enumValues.values.join(', ')}');
|
||||
}
|
||||
return value ?? unknownValue;
|
||||
}
|
||||
|
||||
T _$enumDecodeNullable<T>(
|
||||
Map<T, dynamic> enumValues,
|
||||
dynamic source, {
|
||||
T unknownValue,
|
||||
}) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
return _$enumDecode<T>(enumValues, source, unknownValue: unknownValue);
|
||||
}
|
||||
|
||||
const _$AuthResultEnumMap = {
|
||||
AuthResult.success: 'Success',
|
||||
AuthResult.failure: 'Failure',
|
||||
AuthResult.artemisUnknown: 'ARTEMIS_UNKNOWN',
|
||||
};
|
||||
|
||||
Login$Query _$Login$QueryFromJson(Map<String, dynamic> json) {
|
||||
return Login$Query()
|
||||
..login = json['login'] == null
|
||||
? null
|
||||
: Login$Query$AuthResponse.fromJson(
|
||||
json['login'] as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$Login$QueryToJson(Login$Query instance) =>
|
||||
<String, dynamic>{
|
||||
'login': instance.login?.toJson(),
|
||||
};
|
||||
|
||||
CreateMediaItem$Mutation$MediaItem _$CreateMediaItem$Mutation$MediaItemFromJson(
|
||||
Map<String, dynamic> json) {
|
||||
return CreateMediaItem$Mutation$MediaItem()
|
||||
..id = json['id'] as String
|
||||
..createdAt = json['createdAt'] == null
|
||||
? null
|
||||
: DateTime.parse(json['createdAt'] as String)
|
||||
..updatedAt = json['updatedAt'] == null
|
||||
? null
|
||||
: DateTime.parse(json['updatedAt'] as String)
|
||||
..exifDate = json['exifDate'] == null
|
||||
? null
|
||||
: DateTime.parse(json['exifDate'] as String)
|
||||
..latitude = (json['latitude'] as num)?.toDouble()
|
||||
..longitude = (json['longitude'] as num)?.toDouble()
|
||||
..isVideo = json['isVideo'] as bool
|
||||
..fileName = json['fileName'] as String
|
||||
..origName = json['origName'] as String
|
||||
..userID = json['userID'] as String;
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$CreateMediaItem$Mutation$MediaItemToJson(
|
||||
CreateMediaItem$Mutation$MediaItem instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'createdAt': instance.createdAt?.toIso8601String(),
|
||||
'updatedAt': instance.updatedAt?.toIso8601String(),
|
||||
'exifDate': instance.exifDate?.toIso8601String(),
|
||||
'latitude': instance.latitude,
|
||||
'longitude': instance.longitude,
|
||||
'isVideo': instance.isVideo,
|
||||
'fileName': instance.fileName,
|
||||
'origName': instance.origName,
|
||||
'userID': instance.userID,
|
||||
};
|
||||
|
||||
CreateMediaItem$Mutation _$CreateMediaItem$MutationFromJson(
|
||||
Map<String, dynamic> json) {
|
||||
return CreateMediaItem$Mutation()
|
||||
..createMediaItem = json['createMediaItem'] == null
|
||||
? null
|
||||
: CreateMediaItem$Mutation$MediaItem.fromJson(
|
||||
json['createMediaItem'] as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$CreateMediaItem$MutationToJson(
|
||||
CreateMediaItem$Mutation instance) =>
|
||||
<String, dynamic>{
|
||||
'createMediaItem': instance.createMediaItem?.toJson(),
|
||||
};
|
||||
|
||||
Me$Query$User _$Me$Query$UserFromJson(Map<String, dynamic> json) {
|
||||
return Me$Query$User()
|
||||
..id = json['id'] as String
|
||||
..createdAt = json['createdAt'] == null
|
||||
? null
|
||||
: DateTime.parse(json['createdAt'] as String)
|
||||
..updatedAt = json['updatedAt'] == null
|
||||
? null
|
||||
: DateTime.parse(json['updatedAt'] as String)
|
||||
..email = json['email'] as String
|
||||
..username = json['username'] as String
|
||||
..firstName = json['firstName'] as String
|
||||
..lastName = json['lastName'] as String
|
||||
..role = _$enumDecodeNullable(_$RoleEnumMap, json['role'],
|
||||
unknownValue: Role.artemisUnknown)
|
||||
..authType = _$enumDecodeNullable(_$AuthTypeEnumMap, json['authType'],
|
||||
unknownValue: AuthType.artemisUnknown);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$Me$Query$UserToJson(Me$Query$User instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'createdAt': instance.createdAt?.toIso8601String(),
|
||||
'updatedAt': instance.updatedAt?.toIso8601String(),
|
||||
'email': instance.email,
|
||||
'username': instance.username,
|
||||
'firstName': instance.firstName,
|
||||
'lastName': instance.lastName,
|
||||
'role': _$RoleEnumMap[instance.role],
|
||||
'authType': _$AuthTypeEnumMap[instance.authType],
|
||||
};
|
||||
|
||||
const _$RoleEnumMap = {
|
||||
Role.admin: 'Admin',
|
||||
Role.user: 'User',
|
||||
Role.artemisUnknown: 'ARTEMIS_UNKNOWN',
|
||||
};
|
||||
|
||||
const _$AuthTypeEnumMap = {
|
||||
AuthType.local: 'Local',
|
||||
AuthType.ldap: 'LDAP',
|
||||
AuthType.artemisUnknown: 'ARTEMIS_UNKNOWN',
|
||||
};
|
||||
|
||||
Me$Query _$Me$QueryFromJson(Map<String, dynamic> json) {
|
||||
return Me$Query()
|
||||
..me = json['me'] == null
|
||||
? null
|
||||
: Me$Query$User.fromJson(json['me'] as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$Me$QueryToJson(Me$Query instance) => <String, dynamic>{
|
||||
'me': instance.me?.toJson(),
|
||||
};
|
||||
|
||||
LoginArguments _$LoginArgumentsFromJson(Map<String, dynamic> json) {
|
||||
return LoginArguments(
|
||||
user: json['user'] as String,
|
||||
password: json['password'] as String,
|
||||
deviceID: json['deviceID'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$LoginArgumentsToJson(LoginArguments instance) =>
|
||||
<String, dynamic>{
|
||||
'user': instance.user,
|
||||
'password': instance.password,
|
||||
'deviceID': instance.deviceID,
|
||||
};
|
||||
|
||||
CreateMediaItemArguments _$CreateMediaItemArgumentsFromJson(
|
||||
Map<String, dynamic> json) {
|
||||
return CreateMediaItemArguments(
|
||||
file: fromGraphQLUploadToDartMultipartFile(json['file'] as MultipartFile),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$CreateMediaItemArgumentsToJson(
|
||||
CreateMediaItemArguments instance) =>
|
||||
<String, dynamic>{
|
||||
'file': fromDartMultipartFileToGraphQLUpload(instance.file),
|
||||
};
|
||||
4
web_native/lib/helpers/upload_serializer.dart
Normal file
4
web_native/lib/helpers/upload_serializer.dart
Normal file
@@ -0,0 +1,4 @@
|
||||
import 'package:http/http.dart';
|
||||
|
||||
MultipartFile fromGraphQLUploadToDartMultipartFile(MultipartFile file) => file;
|
||||
MultipartFile fromDartMultipartFileToGraphQLUpload(MultipartFile file) => file;
|
||||
7
web_native/lib/main.dart
Normal file
7
web_native/lib/main.dart
Normal file
@@ -0,0 +1,7 @@
|
||||
import 'package:imagini/core/env.dart';
|
||||
|
||||
void main() => ProductionImagini();
|
||||
|
||||
class ProductionImagini extends Env {
|
||||
final String appName = "Imagini";
|
||||
}
|
||||
0
web_native/lib/models/api/album.dart
Normal file
0
web_native/lib/models/api/album.dart
Normal file
0
web_native/lib/models/api/media_item.dart
Normal file
0
web_native/lib/models/api/media_item.dart
Normal file
19
web_native/lib/models/api/response/login_response.dart
Normal file
19
web_native/lib/models/api/response/login_response.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
class LoginResponse {
|
||||
final String success;
|
||||
final String error;
|
||||
final String deviceUUID;
|
||||
|
||||
LoginResponse(this.success, this.error, this.deviceUUID);
|
||||
|
||||
LoginResponse.fromJson(Map<String, dynamic> json)
|
||||
: success = json['success'],
|
||||
error = json['error'],
|
||||
deviceUUID = json['deviceUUID'];
|
||||
|
||||
Map<String, dynamic> toJson() =>
|
||||
{
|
||||
'success': success,
|
||||
'error': error,
|
||||
'deviceUUID': deviceUUID,
|
||||
};
|
||||
}
|
||||
0
web_native/lib/models/api/tag.dart
Normal file
0
web_native/lib/models/api/tag.dart
Normal file
0
web_native/lib/models/api/user.dart
Normal file
0
web_native/lib/models/api/user.dart
Normal file
105
web_native/lib/screens/home_screen.dart
Normal file
105
web_native/lib/screens/home_screen.dart
Normal file
@@ -0,0 +1,105 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
|
||||
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
||||
|
||||
class HomeScreen extends StatefulWidget {
|
||||
static const String PATH = '/Home';
|
||||
|
||||
HomeScreen({Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_HomeScreenState createState() => _HomeScreenState();
|
||||
}
|
||||
|
||||
class _HomeScreenState extends State<HomeScreen> {
|
||||
|
||||
// HomeBloc bloc;
|
||||
|
||||
void _init(){
|
||||
// if(null == bloc){
|
||||
// bloc = HomeBloc(AppProvider.getApplication(context));
|
||||
// }
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
// bloc.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_init();
|
||||
|
||||
return PlatformScaffold(
|
||||
body: _buildGridView(),
|
||||
bottomNavBar: _buildNavBar()
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildNavBar() {
|
||||
return PlatformNavBar(
|
||||
currentIndex: 0,
|
||||
itemChanged: (index) => setState(
|
||||
() {
|
||||
// _selectedTabIndex = index;
|
||||
print(index);
|
||||
},
|
||||
),
|
||||
items: [
|
||||
BottomNavigationBarItem(
|
||||
label: "Gallery",
|
||||
icon: Icon(PlatformIcons(context).collections),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: "Me",
|
||||
icon: Icon(PlatformIcons(context).person),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: "Settings",
|
||||
icon: Icon(PlatformIcons(context).settings),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildGridView() {
|
||||
// return GridView.builder(
|
||||
// itemCount: 5,
|
||||
// gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(
|
||||
// childAspectRatio: (1 / 1),
|
||||
// crossAxisCount: 2),
|
||||
// itemBuilder: (BuildContext context, int index) {
|
||||
// return _buildCard("https://i.imgur.com/CgSGqUz.jpeg");
|
||||
// }
|
||||
// );
|
||||
|
||||
|
||||
return new StaggeredGridView.countBuilder(
|
||||
crossAxisCount: 4,
|
||||
itemCount: 80,
|
||||
itemBuilder: (BuildContext context, int index) => _buildCard("https://i.imgur.com/CgSGqUz.jpeg"),
|
||||
// itemBuilder: (BuildContext context, int index) => new Container(
|
||||
// color: Colors.green,
|
||||
// child: new Center(
|
||||
// child: new CircleAvatar(
|
||||
// backgroundColor: Colors.white,
|
||||
// child: new Text('$index'),
|
||||
// ),
|
||||
// )),
|
||||
staggeredTileBuilder: (int index) =>
|
||||
// new StaggeredTile.count(2, index.isEven ? 2 : 1),
|
||||
new StaggeredTile.fit(2),
|
||||
mainAxisSpacing: 4.0,
|
||||
crossAxisSpacing: 4.0,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCard(charImageUrl) {
|
||||
return new Image.network(
|
||||
charImageUrl,
|
||||
fit: BoxFit.contain,
|
||||
);
|
||||
}
|
||||
}
|
||||
94
web_native/lib/screens/login_screen.dart
Normal file
94
web_native/lib/screens/login_screen.dart
Normal file
@@ -0,0 +1,94 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:fluro/fluro.dart';
|
||||
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
|
||||
|
||||
import 'package:imagini/core/app_provider.dart';
|
||||
|
||||
class LoginScreen extends StatefulWidget {
|
||||
static const String PATH = '/Login';
|
||||
|
||||
LoginScreen({Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_LoginScreenState createState() => _LoginScreenState();
|
||||
}
|
||||
|
||||
class _LoginScreenState extends State<LoginScreen> {
|
||||
|
||||
// LoginBloc bloc;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
// bloc.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_init();
|
||||
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(maxWidth: 500),
|
||||
child: Container(
|
||||
margin: EdgeInsets.fromLTRB(50, 0, 50, 0),
|
||||
height: 500,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
child: FittedBox(
|
||||
fit: BoxFit.contain,
|
||||
child: const FlutterLogo(),
|
||||
),
|
||||
width: 175,
|
||||
margin: EdgeInsets.fromLTRB(0, 0, 0, 50),
|
||||
),
|
||||
Expanded(
|
||||
child: TextField(
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Server Address'
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: TextField(
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Username / Email'
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: TextField(
|
||||
obscureText: true,
|
||||
enableSuggestions: false,
|
||||
autocorrect: false,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Password'
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: PlatformButton(
|
||||
onPressed: () {
|
||||
AppProvider.getRouter(context).navigateTo(context, "/Home", transition: TransitionType.fadeIn);
|
||||
},
|
||||
child: Text('Login')
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _init(){
|
||||
// if(null == bloc){
|
||||
// bloc = LoginBloc(AppProvider.getApplication(context));
|
||||
// }
|
||||
}
|
||||
}
|
||||
70
web_native/lib/screens/splash_screen.dart
Normal file
70
web_native/lib/screens/splash_screen.dart
Normal file
@@ -0,0 +1,70 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
|
||||
import 'package:fluro/fluro.dart';
|
||||
|
||||
import 'package:imagini/core/app_provider.dart';
|
||||
import 'package:imagini/blocs/splash_bloc.dart';
|
||||
import 'package:imagini/graphql/imagini_graphql.dart';
|
||||
|
||||
class SplashScreen extends StatefulWidget {
|
||||
static const String PATH = '/';
|
||||
|
||||
SplashScreen({Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_SplashScreenState createState() => _SplashScreenState();
|
||||
}
|
||||
|
||||
class _SplashScreenState extends State<SplashScreen> {
|
||||
|
||||
SplashBloc bloc;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
bloc.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_init();
|
||||
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(maxWidth: 500),
|
||||
child: Container(
|
||||
margin: EdgeInsets.fromLTRB(50, 0, 50, 0),
|
||||
height: 270,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
child: FittedBox(
|
||||
fit: BoxFit.contain,
|
||||
child: const FlutterLogo(),
|
||||
),
|
||||
width: 175,
|
||||
margin: EdgeInsets.fromLTRB(0, 0, 0, 50),
|
||||
),
|
||||
PlatformCircularProgressIndicator()
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _init(){
|
||||
if(null == bloc){
|
||||
bloc = SplashBloc(AppProvider.getApplication(context));
|
||||
bloc.loginResult.listen((Login$Query$AuthResponse lr) {
|
||||
if (lr.result == AuthResult.success) {
|
||||
AppProvider.getRouter(context).navigateTo(context, "/Home", transition: TransitionType.fadeIn);
|
||||
} else {
|
||||
AppProvider.getRouter(context).navigateTo(context, "/Login", transition: TransitionType.fadeIn);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
38
web_native/lib/screens/template_screen.dart.template
Normal file
38
web_native/lib/screens/template_screen.dart.template
Normal file
@@ -0,0 +1,38 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class TemplatesScreen extends StatefulWidget {
|
||||
static const String PATH = '/Templates';
|
||||
|
||||
TemplatesScreen({Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_TemplatesScreenState createState() => _TemplatesScreenState();
|
||||
}
|
||||
|
||||
class _TemplatesScreenState extends State<TemplatesScreen> {
|
||||
|
||||
// TemplatesBloc bloc;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
// bloc.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_init();
|
||||
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: Text("Templates")
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _init(){
|
||||
// if(null == bloc){
|
||||
// bloc = TemplatesBloc(AppProvider.getApplication(context));
|
||||
// }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user