rand dart fix
This commit is contained in:
@@ -4,7 +4,6 @@ import 'tabs/master_detail_controller.dart';
|
||||
|
||||
import 'tabs/table_view_controller.dart';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
void main() => runApp(MyApp());
|
||||
|
||||
@@ -26,11 +25,11 @@ class CupertinoControllersApp extends StatelessWidget {
|
||||
items: [
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.list),
|
||||
title: Text("Table"),
|
||||
label: Text("Table"),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.layers),
|
||||
title: Text("Mater Detail"),
|
||||
label: Text("Mater Detail"),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -41,9 +40,9 @@ class CupertinoControllersApp extends StatelessWidget {
|
||||
];
|
||||
return CupertinoTabView(
|
||||
builder: (BuildContext context) {
|
||||
return pages[index]?.child;
|
||||
return pages[index].child;
|
||||
},
|
||||
defaultTitle: pages[index]?.title,
|
||||
defaultTitle: pages[index].title,
|
||||
);
|
||||
;
|
||||
},
|
||||
|
||||
@@ -80,7 +80,7 @@ class TableViewScreenState extends State<TableViewScreen>
|
||||
var _sections = <CupertinoTableViewSection>[];
|
||||
|
||||
_sections = _buildSections(context,
|
||||
data: _search != null && _search.isNotEmpty
|
||||
data: _search.isNotEmpty
|
||||
? _searchItems(context, search: _search)
|
||||
: contacts);
|
||||
|
||||
@@ -117,10 +117,9 @@ class TableViewScreenState extends State<TableViewScreen>
|
||||
});
|
||||
},
|
||||
onChanged: (String value) {
|
||||
if (value != null)
|
||||
setState(() {
|
||||
_search = value;
|
||||
});
|
||||
setState(() {
|
||||
_search = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -144,17 +143,15 @@ class TableViewScreenState extends State<TableViewScreen>
|
||||
},
|
||||
isEditing: _isEditing,
|
||||
onEditing: (bool value) {
|
||||
if (value != null) {
|
||||
setState(() {
|
||||
_isEditing = value;
|
||||
});
|
||||
if (!_isEditing) {
|
||||
setState(() {
|
||||
_isEditing = value;
|
||||
selected.clear();
|
||||
});
|
||||
if (!_isEditing) {
|
||||
setState(() {
|
||||
selected.clear();
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
isSearching: _isSearching,
|
||||
showEditingButtonLeft: true,
|
||||
);
|
||||
@@ -197,7 +194,7 @@ class TableViewScreenState extends State<TableViewScreen>
|
||||
}
|
||||
|
||||
Widget _buildListTile(BuildContext context, List<String> item) {
|
||||
final bool _selected = selected?.contains(item) ?? false;
|
||||
final bool _selected = selected.contains(item) ?? false;
|
||||
CupertinoEditingAction _action;
|
||||
switch (sharedValue) {
|
||||
case 0:
|
||||
|
||||
@@ -138,7 +138,7 @@ class CupertinoTableViewController extends StatelessWidget {
|
||||
}
|
||||
|
||||
return DefaultTextStyle(
|
||||
style: Theme.of(context).textTheme.title!,
|
||||
style: Theme.of(context).textTheme.titleLarge!,
|
||||
child: Scaffold(
|
||||
body: CustomScrollView(
|
||||
primary: true,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../widgets/text.dart';
|
||||
|
||||
|
||||
@@ -14,9 +14,7 @@ class CupertinoSearchBar extends AnimatedWidget {
|
||||
this.onClear,
|
||||
this.enabled = true,
|
||||
this.autoCorrect = true,
|
||||
}) : assert(controller != null),
|
||||
assert(focusNode != null),
|
||||
super(key: key, listenable: animation);
|
||||
}) : super(key: key, listenable: animation);
|
||||
|
||||
final TextEditingController controller;
|
||||
final FocusNode focusNode;
|
||||
@@ -68,7 +66,7 @@ class CupertinoSearchBar extends AnimatedWidget {
|
||||
style: new TextStyle(
|
||||
inherit: false,
|
||||
color: CupertinoColors.inactiveGray
|
||||
.withOpacity(_opacityTween.evaluate(animation)),
|
||||
.withValues(alpha: _opacityTween.evaluate(animation)),
|
||||
fontSize: _kFontSize,
|
||||
),
|
||||
),
|
||||
@@ -102,11 +100,10 @@ class CupertinoSearchBar extends AnimatedWidget {
|
||||
),
|
||||
),
|
||||
new CupertinoButton(
|
||||
minSize: 10.0,
|
||||
padding: const EdgeInsets.all(1.0),
|
||||
borderRadius: new BorderRadius.circular(30.0),
|
||||
color: CupertinoColors.inactiveGray.withOpacity(
|
||||
1.0 - _opacityTween.evaluate(animation),
|
||||
color: CupertinoColors.inactiveGray.withValues(
|
||||
alpha: 1.0 - _opacityTween.evaluate(animation),
|
||||
),
|
||||
child: new Icon(
|
||||
Icons.close,
|
||||
@@ -118,7 +115,7 @@ class CupertinoSearchBar extends AnimatedWidget {
|
||||
return;
|
||||
else
|
||||
onClear!();
|
||||
},
|
||||
}, minimumSize: Size(10.0, 10.0),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
enum CupertinoTextTheme { title, subtitle, detail, custom }
|
||||
|
||||
@@ -168,11 +168,6 @@ class _UsesExampleState extends State<UsesExample> {
|
||||
),
|
||||
body: Builder(
|
||||
builder: (_) {
|
||||
if (_users == null) {
|
||||
return Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
if (_users.isEmpty) {
|
||||
return Center(
|
||||
child: Text('No Users Found'),
|
||||
|
||||
@@ -49,9 +49,7 @@ class App {
|
||||
this.messagingSenderId,
|
||||
this.appId,
|
||||
String? database,
|
||||
}) : _name = database,
|
||||
assert(apiKey != null),
|
||||
assert(projectId != null);
|
||||
}) : _name = database;
|
||||
|
||||
factory App.fromJson(Map<String, dynamic> json) {
|
||||
return App(
|
||||
|
||||
@@ -14,7 +14,7 @@ class FirestoreClientImpl extends FirestoreHttpClient {
|
||||
|
||||
@override
|
||||
Future<dynamic> sendHttpRequest(Uri uri,
|
||||
{bool needsToken: true,
|
||||
{bool needsToken = true,
|
||||
String? extract,
|
||||
Map<String, dynamic>? body}) async {
|
||||
var request = new HttpRequest();
|
||||
|
||||
@@ -26,10 +26,6 @@ abstract class FirestoreHttpClient implements FirestoreClient {
|
||||
FirestoreAccessToken token;
|
||||
|
||||
bool isCurrentTokenValid(bool refreshable) {
|
||||
if (token == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (refreshable) {
|
||||
var now = DateTime.now();
|
||||
return token.expiresAt.difference(now).abs().inSeconds >= 60;
|
||||
@@ -81,13 +77,11 @@ abstract class FirestoreHttpClient implements FirestoreClient {
|
||||
|
||||
@override
|
||||
CollectionReference collection(String path) {
|
||||
assert(path != null);
|
||||
return CollectionReference(this, path.split('/'));
|
||||
}
|
||||
|
||||
@override
|
||||
DocumentReference document(String path) {
|
||||
assert(path != null);
|
||||
return DocumentReference(this, path.split('/'));
|
||||
}
|
||||
|
||||
@@ -99,22 +93,22 @@ abstract class FirestoreHttpClient implements FirestoreClient {
|
||||
|
||||
Future<Map<String, dynamic>?> getJsonMap(String url,
|
||||
{Map<String, dynamic>? body,
|
||||
String? extract: "response",
|
||||
bool standard: true}) async {
|
||||
String? extract = "response",
|
||||
bool standard = true}) async {
|
||||
return (await sendHttpRequest(_apiUrl(url, standard),
|
||||
body: body, extract: extract)) as Map<String, dynamic>?;
|
||||
}
|
||||
|
||||
Future<List<dynamic>?> getJsonList(String url,
|
||||
{Map<String, dynamic>? body,
|
||||
String extract: "response",
|
||||
bool standard: true}) async {
|
||||
String extract = "response",
|
||||
bool standard = true}) async {
|
||||
return (await sendHttpRequest(_apiUrl(url, standard),
|
||||
body: body, extract: extract)) as List<dynamic>?;
|
||||
}
|
||||
|
||||
Future<dynamic> sendHttpRequest(Uri uri,
|
||||
{bool needsToken: true, String? extract, Map<String, dynamic>? body});
|
||||
{bool needsToken = true, String? extract, Map<String, dynamic>? body});
|
||||
|
||||
Uri _apiUrl(String path, bool standard) {
|
||||
path = standard ? "$path" : path;
|
||||
|
||||
@@ -27,7 +27,7 @@ class FirestoreClientImpl extends FirestoreHttpClient {
|
||||
|
||||
@override
|
||||
Future<dynamic> sendHttpRequest(Uri uri,
|
||||
{bool needsToken: true,
|
||||
{bool needsToken = true,
|
||||
String? extract,
|
||||
Map<String, dynamic>? body}) async {
|
||||
if (endpoints.enableProxyMode) {
|
||||
|
||||
@@ -25,7 +25,6 @@ class DocumentReference implements FirestoreReference {
|
||||
/// Returns the reference of a collection contained inside of this
|
||||
/// document.
|
||||
CollectionReference collection(String collectionPath) {
|
||||
assert(collectionPath != null);
|
||||
return CollectionReference(client, <String>[path, collectionPath]);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,7 @@ const List<String> _passwordEnvVars = const <String>[
|
||||
String? _getEnvKey(List<String> possible) {
|
||||
for (var key in possible) {
|
||||
var dartEnvValue = new String.fromEnvironment(key);
|
||||
if (dartEnvValue != null) {
|
||||
return dartEnvValue;
|
||||
}
|
||||
return dartEnvValue;
|
||||
|
||||
if (Platform.environment.containsKey(key) &&
|
||||
Platform.environment[key]!.isNotEmpty) {
|
||||
|
||||
@@ -67,7 +67,7 @@ class TabState extends ChangeNotifier {
|
||||
|
||||
void changeTabOrder(List<String> _list) {
|
||||
List<String> _tabs = _list;
|
||||
if (_tabs != null && _tabs.isNotEmpty) {
|
||||
if (_tabs.isNotEmpty) {
|
||||
List<DynamicTab> _newOrder = [];
|
||||
for (var item in _tabs) {
|
||||
_newOrder.add(_items!.firstWhere((t) => t.tag == item));
|
||||
@@ -92,14 +92,12 @@ class TabState extends ChangeNotifier {
|
||||
void _loadIndex() {
|
||||
if (_persistIndex) {
|
||||
int _index = _storage.getInt(navKey);
|
||||
if (_index != null) {
|
||||
if (_index > _maxTabs) {
|
||||
_index = 0;
|
||||
}
|
||||
_currentIndex = _index;
|
||||
notifyListeners();
|
||||
if (_index > _maxTabs) {
|
||||
_index = 0;
|
||||
}
|
||||
_saveIndex();
|
||||
_currentIndex = _index;
|
||||
notifyListeners();
|
||||
_saveIndex();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class GridTabItem extends StatelessWidget {
|
||||
feedback: DefaultTextStyle(
|
||||
style: adaptive && defaultTargetPlatform == TargetPlatform.iOS
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.title!,
|
||||
: Theme.of(context).textTheme.titleLarge!,
|
||||
child: Container(
|
||||
width: 120.0,
|
||||
height: 80.0,
|
||||
|
||||
@@ -70,7 +70,7 @@ class _EditScreenState extends State<EditScreen> {
|
||||
));
|
||||
}
|
||||
return DefaultTextStyle(
|
||||
style: Theme.of(context).textTheme.display1!,
|
||||
style: Theme.of(context).textTheme.headlineMedium!,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
actions: <Widget>[
|
||||
@@ -118,7 +118,7 @@ class _EditScreenState extends State<EditScreen> {
|
||||
"Drag the icons to\norganize tabs.",
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.headline4!
|
||||
.headlineMedium!
|
||||
.copyWith(fontSize: 22.0),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
@@ -197,7 +197,7 @@ class _BottomEditableTabBarState extends State<BottomEditableTabBar> {
|
||||
// draggable: true,
|
||||
);
|
||||
},
|
||||
onWillAccept: (String? data) {
|
||||
onWillAcceptWithDetails: (String? data) {
|
||||
setState(() {
|
||||
_previewIndex = _targets.indexOf(t);
|
||||
});
|
||||
@@ -208,7 +208,7 @@ class _BottomEditableTabBarState extends State<BottomEditableTabBar> {
|
||||
_previewIndex = null;
|
||||
});
|
||||
},
|
||||
onAccept: (String data) {
|
||||
onAcceptWithDetails: (String data) {
|
||||
final DynamicTab _baseTab = _targets[_previewIndex!];
|
||||
final DynamicTab _newTab = _tabs!.firstWhere((t) => t.tag == data);
|
||||
final int _oldIndex = _tabs!.indexOf(_newTab);
|
||||
@@ -232,7 +232,7 @@ class _BottomEditableTabBarState extends State<BottomEditableTabBar> {
|
||||
child: Container(),
|
||||
tab: BottomNavigationBarItem(
|
||||
icon: Icon(Icons.more_horiz),
|
||||
title: Text("More"),
|
||||
label: Text("More"),
|
||||
),
|
||||
tag: "",
|
||||
),
|
||||
|
||||
@@ -183,7 +183,7 @@ class MaterialPage extends StatelessWidget {
|
||||
final i = model.extraTabs[index];
|
||||
return ListTile(
|
||||
leading: i.tab.icon,
|
||||
title: i.tab.title,
|
||||
title: i.tab.label,
|
||||
selected: expanded ? index == model.subIndex : false,
|
||||
trailing:
|
||||
!expanded ? Icon(Icons.keyboard_arrow_right) : null,
|
||||
@@ -245,7 +245,7 @@ class CupertinoPage extends StatelessWidget {
|
||||
(BuildContext context, int index) {
|
||||
final i = model.extraTabs[index];
|
||||
final Icon _icon = i.tab.icon as Icon;
|
||||
final Text _text = i.tab.title as Text;
|
||||
final Text _text = i.tab.label as Text;
|
||||
return DefaultTextStyle(
|
||||
style: CupertinoTheme.of(context).textTheme.textStyle,
|
||||
child: CupertinoListTile(
|
||||
|
||||
@@ -63,19 +63,19 @@ class _EasyGoogleMapsState extends State<EasyGoogleMaps> {
|
||||
return EasyWebView(
|
||||
src: _src,
|
||||
webAllowFullScreen: true,
|
||||
width: widget?.width,
|
||||
height: widget?.height,
|
||||
width: widget.width,
|
||||
height: widget.height,
|
||||
);
|
||||
}
|
||||
|
||||
return SizedBox(
|
||||
width: widget?.width,
|
||||
height: widget?.height,
|
||||
width: widget.width,
|
||||
height: widget.height,
|
||||
child: FutureBuilder<List<Placemark>>(
|
||||
future: geo.placemarkFromAddress(widget.address),
|
||||
builder: (_, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
final _place = snapshot?.data?.first;
|
||||
final _place = snapshot.data?.first;
|
||||
if (_place == null) {
|
||||
return Center(
|
||||
child: Text('Address not found!'),
|
||||
@@ -89,7 +89,7 @@ class _EasyGoogleMapsState extends State<EasyGoogleMaps> {
|
||||
markerId: MarkerId(widget.address.toString()),
|
||||
position: _latLang,
|
||||
infoWindow: InfoWindow(
|
||||
title: widget?.title ?? '',
|
||||
title: widget.title ?? '',
|
||||
snippet: widget.address,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:easy_web_view/easy_web_view.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class BasicExample extends StatefulWidget {
|
||||
const BasicExample({Key? key}) : super(key: key);
|
||||
const BasicExample({super.key});
|
||||
|
||||
@override
|
||||
_BasicExampleState createState() => _BasicExampleState();
|
||||
|
||||
@@ -10,7 +10,7 @@ import 'package:async/async.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class HtmlToPdfTest extends StatefulWidget {
|
||||
const HtmlToPdfTest({Key? key}) : super(key: key);
|
||||
const HtmlToPdfTest({super.key});
|
||||
|
||||
@override
|
||||
State<HtmlToPdfTest> createState() => _HtmlToPdfTestState();
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'examples/html_to_pdf.dart';
|
||||
void main() => runApp(const MyApp());
|
||||
|
||||
class MyApp extends StatefulWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
const MyApp({super.key});
|
||||
|
||||
@override
|
||||
State<MyApp> createState() => _MyAppState();
|
||||
|
||||
@@ -35,7 +35,7 @@ class _MyAppState extends State<MyApp> {
|
||||
@override
|
||||
void dispose() {
|
||||
_auth.close();
|
||||
_userChanged?.cancel();
|
||||
_userChanged.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,8 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void setTargetPlatformForDesktop({TargetPlatform platform}) {
|
||||
TargetPlatform targetPlatform;
|
||||
if (platform != null) {
|
||||
targetPlatform = platform;
|
||||
}
|
||||
if (targetPlatform == null) {
|
||||
if (Platform.isMacOS) {
|
||||
targetPlatform = TargetPlatform.iOS;
|
||||
} else if (Platform.isLinux || Platform.isWindows) {
|
||||
targetPlatform = TargetPlatform.android;
|
||||
}
|
||||
}
|
||||
targetPlatform = platform;
|
||||
debugDefaultTargetPlatformOverride = targetPlatform;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
final _user = await _auth.loginGoogle(
|
||||
idToken: event.idToken, accessToken: event.accessToken);
|
||||
if (_user != null) {
|
||||
if (saveUser != null) saveUser(_user);
|
||||
saveUser(_user);
|
||||
yield LoggedInState(_user);
|
||||
} else {
|
||||
yield LoggedOutState();
|
||||
@@ -82,37 +82,25 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
Stream<AuthState> _mapGuestToState(LoginGuest event) async* {
|
||||
yield AuthLoadingState();
|
||||
final _user = await _auth.startAsGuest();
|
||||
if (_user != null) {
|
||||
if (saveUser != null) saveUser(_user);
|
||||
yield LoggedInState(_user);
|
||||
} else {
|
||||
yield LoggedOutState();
|
||||
saveUser(_user);
|
||||
yield LoggedInState(_user);
|
||||
}
|
||||
}
|
||||
|
||||
Stream<AuthState> _mapCheckToState(CheckUser event) async* {
|
||||
yield AuthLoadingState();
|
||||
final _user = await _auth.currentUser();
|
||||
if (_user != null) {
|
||||
if (saveUser != null) saveUser(_user);
|
||||
yield LoggedInState(_user);
|
||||
} else {
|
||||
yield LoggedOutState();
|
||||
saveUser(_user);
|
||||
yield LoggedInState(_user);
|
||||
}
|
||||
}
|
||||
|
||||
Stream<AuthState> _mapCreateToState(CreateAccount event) async* {
|
||||
yield AuthLoadingState();
|
||||
try {
|
||||
AuthUser _user = await _auth.createAccount(event.username, event.password,
|
||||
displayName: event?.displayName, photoUrl: event?.photoUrl);
|
||||
if (_user != null) {
|
||||
if (saveUser != null) saveUser(_user);
|
||||
yield LoggedInState(_user);
|
||||
} else {
|
||||
yield AuthErrorState('Error creating user!');
|
||||
}
|
||||
} catch (e) {
|
||||
displayName: event.displayName, photoUrl: event.photoUrl);
|
||||
saveUser(_user);
|
||||
yield LoggedInState(_user);
|
||||
} catch (e) {
|
||||
yield AuthErrorState('Email already exists!');
|
||||
}
|
||||
}
|
||||
@@ -120,18 +108,14 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
Stream<AuthState> _mapLoginToState(LoginEvent event) async* {
|
||||
yield AuthLoadingState();
|
||||
final _user = await _auth.login(event.username, event.password);
|
||||
if (_user != null) {
|
||||
if (saveUser != null) saveUser(_user);
|
||||
yield LoggedInState(_user);
|
||||
} else {
|
||||
yield AuthErrorState('Username or Password Incorrect!');
|
||||
saveUser(_user);
|
||||
yield LoggedInState(_user);
|
||||
}
|
||||
}
|
||||
|
||||
Stream<AuthState> _mapLogoutToState(LogoutEvent event) async* {
|
||||
yield AuthLoadingState();
|
||||
await _auth.logout();
|
||||
if (deleteUser != null) deleteUser();
|
||||
deleteUser();
|
||||
yield LoggedOutState();
|
||||
}
|
||||
|
||||
@@ -142,20 +126,16 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
Stream<AuthState> _mapEditInfoToState(EditInfo event) async* {
|
||||
yield AuthLoadingState();
|
||||
await _auth.editInfo(
|
||||
displayName: event?.displayName, photoUrl: event?.photoUrl);
|
||||
displayName: event.displayName, photoUrl: event.photoUrl);
|
||||
final _user = await _auth.currentUser();
|
||||
if (saveUser != null) saveUser(_user);
|
||||
saveUser(_user);
|
||||
yield LoggedInState(_user);
|
||||
}
|
||||
|
||||
Stream<AuthState> _mapUpdateToState(UpdateUser event) async* {
|
||||
if (event?.user != null) {
|
||||
if (saveUser != null) saveUser(event.user);
|
||||
yield LoggedInState(event.user);
|
||||
} else {
|
||||
yield LoggedOutState();
|
||||
saveUser(event.user);
|
||||
yield LoggedInState(event.user);
|
||||
}
|
||||
}
|
||||
|
||||
Stream<AuthState> _mapForgotPasswordToState(ForgotPassword event) async* {
|
||||
await _auth.forgotPassword(event.email);
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import '../../classes/index.dart';
|
||||
import '../../utils/directory.dart';
|
||||
import '../mobile/sdk.dart';
|
||||
import '../rest_api/client.dart';
|
||||
import 'impl.dart';
|
||||
@@ -35,12 +34,8 @@ class FBAuth implements FBAuthImpl {
|
||||
},
|
||||
onSave: (data) async {
|
||||
try {
|
||||
if (data == null) {
|
||||
await _saveFile.delete();
|
||||
} else {
|
||||
await _saveFile.writeAsString(json.encode(data));
|
||||
}
|
||||
} catch (e) {}
|
||||
await _saveFile.writeAsString(json.encode(data));
|
||||
} catch (e) {}
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -50,10 +45,7 @@ class FBAuth implements FBAuthImpl {
|
||||
}
|
||||
|
||||
Future _loadFile() async {
|
||||
if (_saveFile == null) {
|
||||
final dir = await PathUtils.getDocumentDir();
|
||||
_saveFile = File('${dir.path}/fb_auth.json');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool get useClient => isDesktop || useRestClient;
|
||||
|
||||
@@ -115,8 +115,8 @@ class FBAuth implements FBAuthImpl {
|
||||
Future editInfo({String displayName, String photoUrl}) async {
|
||||
final _user = _auth.currentUser;
|
||||
final _info = UserProfile();
|
||||
if (displayName != null) _info.displayName = displayName;
|
||||
if (photoUrl != null) _info.photoURL = photoUrl;
|
||||
_info.displayName = displayName;
|
||||
_info.photoURL = photoUrl;
|
||||
try {
|
||||
await _user.updateProfile(_info);
|
||||
} catch (e) {
|
||||
|
||||
@@ -94,8 +94,8 @@ class FbSdk implements FBAuthImpl {
|
||||
Future editInfo({String displayName, String photoUrl}) async {
|
||||
final _user = await _auth.currentUser();
|
||||
final _info = UserUpdateInfo();
|
||||
if (displayName != null) _info.displayName = displayName;
|
||||
if (photoUrl != null) _info.photoUrl = photoUrl;
|
||||
_info.displayName = displayName;
|
||||
_info.photoUrl = photoUrl;
|
||||
try {
|
||||
await _user.updateProfile(_info);
|
||||
} catch (e) {
|
||||
|
||||
@@ -43,18 +43,16 @@ class FbClient implements FBAuthImpl {
|
||||
@override
|
||||
Future<AuthUser> currentUser() async {
|
||||
FirestoreJsonAccessToken token = await _loadToken();
|
||||
if (token != null) {
|
||||
var result = await http.post(
|
||||
'https://identitytoolkit.googleapis.com/v1/accounts:lookup?key=${app.apiKey}',
|
||||
body: json.encode({
|
||||
"idToken": token?.idToken,
|
||||
"returnSecureToken": true,
|
||||
}),
|
||||
);
|
||||
token = await _saveToken(result);
|
||||
return _getUser(token);
|
||||
}
|
||||
return null;
|
||||
var result = await http.post(
|
||||
'https://identitytoolkit.googleapis.com/v1/accounts:lookup?key=${app.apiKey}',
|
||||
body: json.encode({
|
||||
"idToken": token.idToken,
|
||||
"returnSecureToken": true,
|
||||
}),
|
||||
);
|
||||
token = await _saveToken(result);
|
||||
return _getUser(token);
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -63,16 +61,15 @@ class FbClient implements FBAuthImpl {
|
||||
final result = await http.post(
|
||||
'https://identitytoolkit.googleapis.com/v1/accounts:update?key=${app.apiKey}',
|
||||
body: json.encode({
|
||||
"idToken": token?.idToken,
|
||||
if (displayName != null) ...{
|
||||
'displayName': displayName,
|
||||
},
|
||||
if (photoUrl != null) ...{
|
||||
'photoUrl': photoUrl,
|
||||
},
|
||||
"idToken": token.idToken,
|
||||
...{
|
||||
'displayName': displayName,
|
||||
},
|
||||
...{
|
||||
'photoUrl': photoUrl,
|
||||
},
|
||||
"deleteAttribute": [
|
||||
if (displayName == null) 'DISPLAY_NAME',
|
||||
if (photoUrl == null) 'PHOTO_URL',
|
||||
|
||||
],
|
||||
"returnSecureToken": true,
|
||||
}),
|
||||
@@ -126,7 +123,7 @@ class FbClient implements FBAuthImpl {
|
||||
var result = await http.post(
|
||||
'https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode?key=${app.apiKey}',
|
||||
body: json.encode({
|
||||
"idToken": token?.idToken,
|
||||
"idToken": token.idToken,
|
||||
"requestType": 'VERIFY_EMAIL',
|
||||
}),
|
||||
);
|
||||
@@ -169,12 +166,12 @@ class FbClient implements FBAuthImpl {
|
||||
final _user = FirebaseUser(item, token.idToken);
|
||||
if (_user.uid == token.localId) {
|
||||
final _auth = AuthUser(
|
||||
displayName: _user?.displayName,
|
||||
email: _user?.email,
|
||||
isAnonymous: _user?.isAnonymous ?? true,
|
||||
isEmailVerified: _user?.isEmailVerified ?? false,
|
||||
displayName: _user.displayName,
|
||||
email: _user.email,
|
||||
isAnonymous: _user.isAnonymous ?? true,
|
||||
isEmailVerified: _user.isEmailVerified ?? false,
|
||||
photoUrl: _user.photoUrl,
|
||||
uid: _user?.uid,
|
||||
uid: _user.uid,
|
||||
);
|
||||
_onAuthChanged.add(_auth);
|
||||
return _auth;
|
||||
@@ -185,11 +182,9 @@ class FbClient implements FBAuthImpl {
|
||||
|
||||
Future<FirestoreJsonAccessToken> _loadToken() async {
|
||||
final _data = await onLoad();
|
||||
if (_data != null) {
|
||||
final token = FirestoreJsonAccessToken(_data, DateTime.now());
|
||||
return token;
|
||||
}
|
||||
return null;
|
||||
final token = FirestoreJsonAccessToken(_data, DateTime.now());
|
||||
return token;
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -24,7 +24,7 @@ class FirebaseUser {
|
||||
}).toList();
|
||||
}
|
||||
|
||||
bool get isAnonymous => email == null || email.isEmpty;
|
||||
bool get isAnonymous => email.isEmpty;
|
||||
|
||||
bool get isEmailVerified => json['emailVerified'];
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:fb_firestore/fb_firestore.dart';
|
||||
|
||||
void main() => runApp(MyApp());
|
||||
|
||||
@@ -77,7 +77,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
),
|
||||
Text(
|
||||
'$_counter',
|
||||
style: Theme.of(context).textTheme.headline4,
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
FeatureBuilder(
|
||||
feature: _counterFeature,
|
||||
|
||||
@@ -9,13 +9,11 @@ import 'package:image_picker/image_picker.dart';
|
||||
|
||||
Future<FileX> openFile() async {
|
||||
final _files = await _open(false, false);
|
||||
if (_files == null) return null;
|
||||
return _files.first;
|
||||
}
|
||||
|
||||
Future<List<FileX>> openFiles() async {
|
||||
final _files = await _open(true, false);
|
||||
if (_files == null) return null;
|
||||
return _files;
|
||||
}
|
||||
|
||||
@@ -30,7 +28,7 @@ Future<FileX> pickImage() async {
|
||||
fileExtensions: kImageExtensions,
|
||||
),
|
||||
]);
|
||||
if (_files == null || _files.isEmpty) return null;
|
||||
if (_files.isEmpty) return null;
|
||||
return _files.first;
|
||||
}
|
||||
|
||||
@@ -45,7 +43,7 @@ Future<FileX> pickVideo() async {
|
||||
fileExtensions: kVideoExtensions,
|
||||
),
|
||||
]);
|
||||
if (_files == null || _files.isEmpty) return null;
|
||||
if (_files.isEmpty) return null;
|
||||
return _files.first;
|
||||
}
|
||||
|
||||
@@ -68,13 +66,11 @@ Future<List<FileX>> _open(bool multiple, bool folders,
|
||||
final List<FileX> _files = [];
|
||||
if (multiple) {
|
||||
List<File> files = await FilePicker.getMultiFile();
|
||||
if (files == null) return null;
|
||||
for (final file in files) {
|
||||
_files.add(await _add(file));
|
||||
}
|
||||
} else {
|
||||
File file = await FilePicker.getFile();
|
||||
if (file == null) return null;
|
||||
_files.add(await _add(file));
|
||||
}
|
||||
return _files;
|
||||
|
||||
@@ -6,31 +6,30 @@ import 'dart:html' as html;
|
||||
|
||||
Future<FileX> pickImage() async {
|
||||
final _files = await _open(false, false, 'image/*');
|
||||
if (_files == null || _files.isEmpty) return null;
|
||||
if (_files.isEmpty) return null;
|
||||
return _files.first;
|
||||
}
|
||||
|
||||
Future<FileX> pickVideo() async {
|
||||
final _files = await _open(false, false, 'video/*');
|
||||
if (_files == null || _files.isEmpty) return null;
|
||||
if (_files.isEmpty) return null;
|
||||
return _files.first;
|
||||
}
|
||||
|
||||
Future<FileX> pickAudio() async {
|
||||
final _files = await _open(false, false, 'audio/*');
|
||||
if (_files == null || _files.isEmpty) return null;
|
||||
if (_files.isEmpty) return null;
|
||||
return _files.first;
|
||||
}
|
||||
|
||||
Future<FileX> openFile() async {
|
||||
final _files = await _open(false, false);
|
||||
if (_files == null || _files.isEmpty) return null;
|
||||
if (_files.isEmpty) return null;
|
||||
return _files.first;
|
||||
}
|
||||
|
||||
Future<List<FileX>> openFiles() async {
|
||||
final _files = await _open(true, false);
|
||||
if (_files == null) return null;
|
||||
return _files;
|
||||
}
|
||||
|
||||
@@ -46,7 +45,6 @@ Future<List<FileX>> _open(bool multiple, bool folders,
|
||||
}
|
||||
_upload.click();
|
||||
final _file = await _upload.onChange.first;
|
||||
if (_file == null) return null;
|
||||
List<html.File> files = (_file.target as dynamic).files;
|
||||
final List<FileX> _files = [];
|
||||
for (final f in files) {
|
||||
|
||||
@@ -25,9 +25,7 @@ void _setTargetPlatformForDesktop() {
|
||||
} else if (Platform.isLinux || Platform.isWindows) {
|
||||
targetPlatform = TargetPlatform.android;
|
||||
}
|
||||
if (targetPlatform != null) {
|
||||
debugDefaultTargetPlatformOverride = targetPlatform;
|
||||
}
|
||||
debugDefaultTargetPlatformOverride = targetPlatform;
|
||||
}
|
||||
|
||||
class MyApp extends StatefulWidget {
|
||||
|
||||
@@ -19,11 +19,7 @@ class SliverFloatingBar extends StatefulWidget {
|
||||
this.floating = false,
|
||||
this.pinned = false,
|
||||
this.snap = false,
|
||||
}) : assert(automaticallyImplyLeading != null),
|
||||
assert(floating != null),
|
||||
assert(pinned != null),
|
||||
assert(snap != null),
|
||||
assert(floating || !snap,
|
||||
}) : assert(floating || !snap,
|
||||
'The "snap" argument only makes sense for floating app bars.'),
|
||||
super(key: key);
|
||||
|
||||
@@ -224,35 +220,28 @@ class _FloatingAppBarState extends State<_FloatingAppBar> {
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
if (_position != null)
|
||||
_position.isScrollingNotifier.removeListener(_isScrollingListener);
|
||||
_position = Scrollable.of(context)?.position;
|
||||
if (_position != null)
|
||||
_position.isScrollingNotifier.addListener(_isScrollingListener);
|
||||
_position.isScrollingNotifier.removeListener(_isScrollingListener);
|
||||
_position = Scrollable.of(context).position;
|
||||
_position.isScrollingNotifier.addListener(_isScrollingListener);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
if (_position != null)
|
||||
_position.isScrollingNotifier.removeListener(_isScrollingListener);
|
||||
_position.isScrollingNotifier.removeListener(_isScrollingListener);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
RenderSliverFloatingPersistentHeader _headerRenderer() {
|
||||
return context.ancestorRenderObjectOfType(
|
||||
const TypeMatcher<RenderSliverFloatingPersistentHeader>());
|
||||
return context.findAncestorRenderObjectOfType<RenderSliverFloatingPersistentHeader>(
|
||||
);
|
||||
}
|
||||
|
||||
void _isScrollingListener() {
|
||||
if (_position == null) return;
|
||||
|
||||
// When a scroll stops, then maybe snap the appbar into view.
|
||||
// Similarly, when a scroll starts, then maybe stop the snap animation.
|
||||
final RenderSliverFloatingPersistentHeader header = _headerRenderer();
|
||||
if (_position.isScrollingNotifier.value)
|
||||
header?.maybeStopSnapAnimation(_position.userScrollDirection);
|
||||
header.maybeStopSnapAnimation(_position.userScrollDirection);
|
||||
else
|
||||
header?.maybeStartSnapAnimation(_position.userScrollDirection);
|
||||
header.maybeStartSnapAnimation(_position.userScrollDirection);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -132,7 +132,6 @@ void _processFile(
|
||||
if (item.isValid) {
|
||||
if (!cache.addName(item.name)) continue;
|
||||
final _template = _processClass(item, input);
|
||||
if (_template == null) continue;
|
||||
final name = ReCase(item.name).snakeCase;
|
||||
final _path = 'classes/' + name + '.dart';
|
||||
final _file = _getFile(output.path, _path);
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'src/index.dart';
|
||||
export 'src/index.dart';
|
||||
|
||||
DartResult parseSource(String source, [String path]) {
|
||||
assert(source != null && source.isNotEmpty);
|
||||
assert(source.isNotEmpty);
|
||||
final result = parseString(
|
||||
content: source,
|
||||
path: path,
|
||||
|
||||
@@ -25,10 +25,10 @@ extension ClauseDeclarationImplUtils on ClassDeclarationImpl {
|
||||
comments.add(item.toDartComment());
|
||||
}
|
||||
return base.copyWith(
|
||||
isAbstract: this?.abstractKeyword != null,
|
||||
extendsClause: this?.extendsClause?.toString(),
|
||||
implementsClause: this?.implementsClause?.toString(),
|
||||
withClause: this?.withClause?.toString(),
|
||||
isAbstract: this.abstractKeyword != null,
|
||||
extendsClause: this.extendsClause?.toString(),
|
||||
implementsClause: this.implementsClause?.toString(),
|
||||
withClause: this.withClause?.toString(),
|
||||
fields: fields,
|
||||
constructors: constructors,
|
||||
methods: methods,
|
||||
|
||||
@@ -51,12 +51,11 @@ extension DefaultFormalParameterImplUtils on DefaultFormalParameterImpl {
|
||||
base = base.copyWith(name: child.toString());
|
||||
}
|
||||
}
|
||||
if (fields != null)
|
||||
for (final field in fields) {
|
||||
if (field.name == base.name) {
|
||||
base = base.copyWith(type: field.type);
|
||||
}
|
||||
for (final field in fields) {
|
||||
if (field.name == base.name) {
|
||||
base = base.copyWith(type: field.type);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (node.runtimeType.toString() == 'SimpleToken' &&
|
||||
node.toString() == '=') {
|
||||
|
||||
@@ -38,22 +38,22 @@ class GenParser {
|
||||
|
||||
void merge(String source) {
|
||||
final DartResult result = parseSource(source);
|
||||
if (result?.file != null) {
|
||||
if (result?.file?.classes != null) {
|
||||
if (result.file != null) {
|
||||
if (result.file?.classes != null) {
|
||||
for (final item in result.file.classes) {
|
||||
this._classes.putIfAbsent(item.name, () => item);
|
||||
}
|
||||
}
|
||||
if (result?.file?.enums != null) {
|
||||
if (result.file?.enums != null) {
|
||||
this._enums.addAll(result.file.enums);
|
||||
}
|
||||
if (result?.file?.fields != null) {
|
||||
if (result.file?.fields != null) {
|
||||
this._fields.addAll(result.file.fields);
|
||||
}
|
||||
if (result?.file?.methods != null) {
|
||||
if (result.file?.methods != null) {
|
||||
this._methods.addAll(result.file.methods);
|
||||
}
|
||||
if (result?.file?.imports != null) {
|
||||
if (result.file?.imports != null) {
|
||||
this._imports.addAll(result.file.imports);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ abstract class NgDartCommand extends Command {
|
||||
String readArg(String errorMessage) {
|
||||
var args = argResults.rest;
|
||||
|
||||
if (args == null || args.length == 0) {
|
||||
if (args.length == 0) {
|
||||
// Usage is provided by command runner.
|
||||
throw new UsageException(errorMessage, '');
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ class FileReader {
|
||||
|
||||
FileReader._();
|
||||
|
||||
String readAsString(String filePath, {Encoding encoding: utf8}) =>
|
||||
String readAsString(String filePath, {Encoding encoding = utf8}) =>
|
||||
new File(filePath).readAsStringSync(encoding: encoding);
|
||||
|
||||
List<String> readAsLines(String filePath, {Encoding encoding: utf8}) =>
|
||||
List<String> readAsLines(String filePath, {Encoding encoding = utf8}) =>
|
||||
new File(filePath).readAsLinesSync(encoding: encoding);
|
||||
}
|
||||
|
||||
@@ -42,8 +42,6 @@ class PackageUriResolver {
|
||||
|
||||
/// Resolves a package URI to a file path.
|
||||
String resolve(String packageUri) {
|
||||
if (_packageMap == null) _buildPackageMap();
|
||||
|
||||
var packageName = getPackageName(packageUri);
|
||||
|
||||
if (_packageMap[packageName] == null) {
|
||||
|
||||
@@ -81,7 +81,7 @@ class _Selector {
|
||||
return new _Selector('ByTagName', element.localName);
|
||||
}
|
||||
|
||||
_Selector(this.type, this.name, [this.value]);
|
||||
_Selector(this.type, this.name);
|
||||
|
||||
@override
|
||||
String toString() => "@$type('${value ?? name}')";
|
||||
@@ -99,9 +99,6 @@ class _Variable implements Comparable<_Variable> {
|
||||
|
||||
factory _Variable.fromElement(Element element) {
|
||||
var selector = new _Selector.fromElement(element);
|
||||
if (selector == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var type = new DartClassInfo(
|
||||
'PageLoaderElement', 'package:pageloader/objects.dart');
|
||||
|
||||
@@ -49,7 +49,7 @@ class ProjectModel {
|
||||
this.componentClassUri, this.dartClasses, this.components, this.modules);
|
||||
|
||||
/// Whether providers are needed when generating test.
|
||||
bool get needProviders => serviceClasses != null && serviceClasses.isNotEmpty;
|
||||
bool get needProviders => serviceClasses.isNotEmpty;
|
||||
|
||||
/// Uris for service classes used.
|
||||
List<String> get referencedUris => serviceClasses
|
||||
@@ -84,10 +84,6 @@ class ProjectModel {
|
||||
file, out, asts.publicUris, _getBindingVariables(components))));
|
||||
|
||||
var componentClassName = className;
|
||||
if (componentClassName == null) {
|
||||
componentClassName =
|
||||
_getComponentClassName(componentClassUri, components);
|
||||
}
|
||||
|
||||
var serviceClasses = _getServiceClasses(
|
||||
componentClassName, dartClasses, components, modules);
|
||||
@@ -125,8 +121,6 @@ Set<String> _getBindingVariables(Map<String, ComponentInfo> components) {
|
||||
var result = new Set<String>();
|
||||
|
||||
for (var component in components.values) {
|
||||
if (component.module == null) continue;
|
||||
|
||||
for (var binding in component.module.directChildren) {
|
||||
if (binding is String) result.add(binding);
|
||||
}
|
||||
@@ -159,17 +153,14 @@ List<String> _getServiceClasses(
|
||||
var dependencies = <String>[];
|
||||
for (var parameter in dartClasses[componentClassName].constructorParameters) {
|
||||
var service = parameter.dependency;
|
||||
if (dartClasses[service].uri == null) continue;
|
||||
|
||||
dependencies.add(service);
|
||||
}
|
||||
|
||||
var module = components[componentClassName].module;
|
||||
if (module != null) {
|
||||
for (var binding in module.getAllBindingInstances(modules)) {
|
||||
if (dependencies.contains(binding.className)) {
|
||||
dependencies.remove(binding.className);
|
||||
}
|
||||
for (var binding in module.getAllBindingInstances(modules)) {
|
||||
if (dependencies.contains(binding.className)) {
|
||||
dependencies.remove(binding.className);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ void processBindingElement(Expression node, ModuleInfo module) {
|
||||
throw new UnsupportedError('Unable to handle $node.');
|
||||
}
|
||||
|
||||
if (binding != null) module.directChildren.add(binding);
|
||||
module.directChildren.add(binding);
|
||||
}
|
||||
|
||||
/// Extracts binding information from instance creation expression [node].
|
||||
@@ -107,10 +107,8 @@ BindingInstance _buildBindingInstance(
|
||||
binding = new BindingInstance(token.value, creationExpression);
|
||||
}
|
||||
|
||||
if (binding != null) {
|
||||
_handleBindingArgs(args, binding);
|
||||
return binding;
|
||||
}
|
||||
_handleBindingArgs(args, binding);
|
||||
return binding;
|
||||
|
||||
throw new UnsupportedError('Unable to handle $token '
|
||||
'(${token.runtimeType}) in $creationExpression');
|
||||
|
||||
@@ -53,9 +53,7 @@ class ModuleInfo extends BindingInfo {
|
||||
/// Expands binding information in this module.
|
||||
List<BindingInstance> getAllBindingInstances(
|
||||
Map<String, ModuleInfo> allModules) {
|
||||
if (_allBindingInstances != null) {
|
||||
return _allBindingInstances;
|
||||
}
|
||||
return _allBindingInstances;
|
||||
|
||||
_allBindingInstances = [];
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ class DartClassVisitor extends RecursiveAstVisitor {
|
||||
var classInfo = _getClass(className(classDeclaration));
|
||||
|
||||
// Only first appeared class is used to get more accurate matching.
|
||||
if (classInfo.uri != null) return;
|
||||
return;
|
||||
|
||||
classInfo.uri = _publicUris[_uri];
|
||||
|
||||
|
||||
@@ -97,13 +97,13 @@ var _dotPackages = ['a:a/lib/', 'b:b/lib/'];
|
||||
|
||||
class FileReaderMock implements FileReader {
|
||||
@override
|
||||
List<String> readAsLines(String filePath, {Encoding encoding: utf8}) {
|
||||
List<String> readAsLines(String filePath, {Encoding encoding = utf8}) {
|
||||
if (filePath == '.packages') return _dotPackages;
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
String readAsString(String filePath, {Encoding encoding: utf8}) {
|
||||
String readAsString(String filePath, {Encoding encoding = utf8}) {
|
||||
for (var file in _files) {
|
||||
if (file['path'] == filePath) return file['content'];
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ var _pubSpec = ['name: hello_flutter'];
|
||||
|
||||
class FileReaderMock implements FileReader {
|
||||
@override
|
||||
List<String> readAsLines(String filePath, {Encoding encoding: utf8}) {
|
||||
List<String> readAsLines(String filePath, {Encoding encoding = utf8}) {
|
||||
if (filePath == '.packages') {
|
||||
return _dotPackages;
|
||||
} else if (filePath == 'pubspec.yaml') {
|
||||
@@ -111,7 +111,7 @@ class FileReaderMock implements FileReader {
|
||||
}
|
||||
|
||||
@override
|
||||
String readAsString(String filePath, {Encoding encoding: utf8}) {
|
||||
String readAsString(String filePath, {Encoding encoding = utf8}) {
|
||||
for (var file in _files) {
|
||||
if (file['path'] == filePath) return file['content'];
|
||||
}
|
||||
|
||||
@@ -60,11 +60,11 @@ class FileReaderMock implements FileReader {
|
||||
];
|
||||
|
||||
@override
|
||||
List<String> readAsLines(Object uri, {Encoding encoding: utf8}) {
|
||||
List<String> readAsLines(Object uri, {Encoding encoding = utf8}) {
|
||||
if (uri is String && uri == '.packages') return _dotPackages;
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
String readAsString(Object uri, {Encoding encoding: utf8}) => null;
|
||||
String readAsString(Object uri, {Encoding encoding = utf8}) => null;
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ var _pubSpec = ['name: a'];
|
||||
|
||||
class FileReaderMock implements FileReader {
|
||||
@override
|
||||
List<String> readAsLines(String filePath, {Encoding encoding: utf8}) {
|
||||
List<String> readAsLines(String filePath, {Encoding encoding = utf8}) {
|
||||
if (filePath == '.packages') {
|
||||
return _dotPackages;
|
||||
} else if (filePath == 'pubspec.yaml') {
|
||||
@@ -118,7 +118,7 @@ class FileReaderMock implements FileReader {
|
||||
}
|
||||
|
||||
@override
|
||||
String readAsString(String filePath, {Encoding encoding: utf8}) {
|
||||
String readAsString(String filePath, {Encoding encoding = utf8}) {
|
||||
for (var file in _files) {
|
||||
if (file['path'] == filePath) return file['content'];
|
||||
}
|
||||
|
||||
@@ -51,10 +51,8 @@ class _TaggedDataViewState<T> extends State<TaggedDataView<T>> {
|
||||
final allTags = [...folders, ...other].toSet().toList();
|
||||
allTags.sort();
|
||||
final emptyBuilder = () {
|
||||
if (widget?.emptyBuilder != null) {
|
||||
return widget.emptyBuilder(context);
|
||||
}
|
||||
return Scaffold(
|
||||
return widget.emptyBuilder(context);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: false,
|
||||
title: Text('Details'),
|
||||
@@ -66,10 +64,8 @@ class _TaggedDataViewState<T> extends State<TaggedDataView<T>> {
|
||||
};
|
||||
final detailBuilder = (int index) {
|
||||
final T item = widget.dataSource.items[index];
|
||||
if (widget?.detailBuilder != null) {
|
||||
return widget.detailBuilder(context, item, index);
|
||||
}
|
||||
return Scaffold(
|
||||
return widget.detailBuilder(context, item, index);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: false,
|
||||
title: Text('Details'),
|
||||
|
||||
@@ -30,7 +30,6 @@ abstract class TaggedDataTableSource<T> extends DataSource<T> {
|
||||
}
|
||||
return Icons.info;
|
||||
};
|
||||
if (iconData() == null) return null;
|
||||
return Icon(iconData());
|
||||
}
|
||||
|
||||
@@ -64,16 +63,12 @@ abstract class TaggedDataTableSource<T> extends DataSource<T> {
|
||||
final _results = <int, DataRow>{};
|
||||
for (var i = 0; i < rowCount; i++) {
|
||||
final tags = getTagsForRow(i);
|
||||
if (_selected == null) {
|
||||
_results[i] = getRow(i);
|
||||
} else {
|
||||
for (final tag in tags) {
|
||||
if (tag.contains(_selected)) {
|
||||
_results[i] = getRow(i);
|
||||
}
|
||||
for (final tag in tags) {
|
||||
if (tag.contains(_selected)) {
|
||||
_results[i] = getRow(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
final search = this.search.toLowerCase();
|
||||
if (search.isEmpty) return _results;
|
||||
_results.clear();
|
||||
|
||||
@@ -74,37 +74,33 @@ class __WidgetAcceptState extends State<_WidgetAccept> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.child != null) {
|
||||
return widget.child;
|
||||
}
|
||||
if (!widget.scope.isDragging) {
|
||||
return widget.child;
|
||||
if (!widget.scope.isDragging) {
|
||||
return SizedBox.fromSize(
|
||||
size: widget.sizeOnlyDragging ? null : widget.size,
|
||||
child: Container(),
|
||||
);
|
||||
}
|
||||
return SizedBox(
|
||||
height: widget?.size?.height,
|
||||
width: widget?.size?.width,
|
||||
height: widget.size.height,
|
||||
width: widget.size.width,
|
||||
child: DragTarget<Map<String, dynamic>>(
|
||||
onAccept: (val) {
|
||||
onAcceptWithDetails: (val) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_accepting = false;
|
||||
});
|
||||
}
|
||||
if (val != null) {
|
||||
final _data = val;
|
||||
_data['id'] = StringGen.id;
|
||||
if (_data['name'] == 'Text') {
|
||||
_data['params']['style']['id'] = StringGen.id;
|
||||
}
|
||||
if (_data['name'] == 'Icon') {
|
||||
_data['params']['0']['id'] = StringGen.id;
|
||||
}
|
||||
widget.onAccept(context, _data);
|
||||
final _data = val;
|
||||
_data['id'] = StringGen.id;
|
||||
if (_data['name'] == 'Text') {
|
||||
_data['params']['style']['id'] = StringGen.id;
|
||||
}
|
||||
},
|
||||
if (_data['name'] == 'Icon') {
|
||||
_data['params']['0']['id'] = StringGen.id;
|
||||
}
|
||||
widget.onAccept(context, _data);
|
||||
},
|
||||
onLeave: (val) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
@@ -112,7 +108,7 @@ class __WidgetAcceptState extends State<_WidgetAccept> {
|
||||
});
|
||||
}
|
||||
},
|
||||
onWillAccept: (val) {
|
||||
onWillAcceptWithDetails: (val) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_accepting = true;
|
||||
@@ -123,11 +119,11 @@ class __WidgetAcceptState extends State<_WidgetAccept> {
|
||||
builder: (context, accepted, rejected) {
|
||||
return Center(
|
||||
child: Container(
|
||||
width: widget?.size?.width,
|
||||
height: widget?.size?.height,
|
||||
width: widget.size.width,
|
||||
height: widget.size.height,
|
||||
child: Placeholder(
|
||||
color:
|
||||
!_accepting ? Colors.grey : Theme.of(context).accentColor,
|
||||
!_accepting ? Colors.grey : Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -143,13 +139,9 @@ Map<String, dynamic> modifyAccept(Map<String, dynamic> val,
|
||||
_data['id'] = StringGen.id;
|
||||
switch (_data['name']) {
|
||||
case 'Container':
|
||||
if (height != null) {
|
||||
_data['params']['height'] = height;
|
||||
}
|
||||
if (width != null) {
|
||||
_data['params']['width'] = width;
|
||||
}
|
||||
break;
|
||||
_data['params']['height'] = height;
|
||||
_data['params']['width'] = width;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
return _data;
|
||||
|
||||
@@ -25,104 +25,95 @@ class DynamicWidget extends StatelessWidget implements WidgetLibrary {
|
||||
}
|
||||
|
||||
WidgetConfig get base {
|
||||
if (data != null) {
|
||||
if (library[data['name']] != null) {
|
||||
final _base = library[data['name']];
|
||||
if (_base != null) {
|
||||
return _base;
|
||||
}
|
||||
if (library[data['name']] != null) {
|
||||
final _base = library[data['name']];
|
||||
if (_base != null) {
|
||||
return _base;
|
||||
}
|
||||
}
|
||||
if (unknownWidgetBuilder != null) {
|
||||
return unknownWidgetBuilder(data);
|
||||
}
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
static void onAction(BuildContext context, String val) {
|
||||
final data = val;
|
||||
if (data == null) return null;
|
||||
if (data is String) {
|
||||
if (data.isEmpty) return null;
|
||||
final _data = data.replaceAll('#', '');
|
||||
if (_data.startsWith('message')) {
|
||||
final _message = _data
|
||||
.replaceAll('message(', '')
|
||||
.replaceAll('(', '')
|
||||
.replaceAll(')', '');
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
content: Text(_message),
|
||||
));
|
||||
return;
|
||||
}
|
||||
if (_data.startsWith('navigate')) {
|
||||
final _route = _data
|
||||
.replaceAll('navigate(', '')
|
||||
.replaceAll('(', '')
|
||||
.replaceAll(')', '');
|
||||
Navigator.of(context).pushNamed(_route);
|
||||
return;
|
||||
}
|
||||
if (_data.startsWith('pop')) {
|
||||
final _route = _data
|
||||
.replaceAll('pop(', '')
|
||||
.replaceAll('(', '')
|
||||
.replaceAll(')', '');
|
||||
if (_route.isNotEmpty) {
|
||||
Navigator.popUntil(context, ModalRoute.withName(_route));
|
||||
} else {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (_data.startsWith('maybePop')) {
|
||||
Navigator.of(context).maybePop();
|
||||
return;
|
||||
}
|
||||
if (_data.startsWith('launch')) {
|
||||
final _url = _data
|
||||
.replaceAll("launch(", '')
|
||||
.replaceAll('(', '')
|
||||
.replaceAll(')', '')
|
||||
.replaceAll("\'", '');
|
||||
launch('$_url');
|
||||
return;
|
||||
}
|
||||
if (_data.startsWith('alert')) {
|
||||
final _message = _data
|
||||
.replaceAll('alert(', '')
|
||||
.replaceAll('(', '')
|
||||
.replaceAll(')', '');
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text('Info'),
|
||||
content: Text(_message),
|
||||
actions: [
|
||||
FlatButton(
|
||||
child: Text('Ok'),
|
||||
onPressed: () => Navigator.maybePop(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (data.isEmpty) return null;
|
||||
final _data = data.replaceAll('#', '');
|
||||
if (_data.startsWith('message')) {
|
||||
final _message = _data
|
||||
.replaceAll('message(', '')
|
||||
.replaceAll('(', '')
|
||||
.replaceAll(')', '');
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
content: Text(_message),
|
||||
));
|
||||
return;
|
||||
}
|
||||
return null;
|
||||
if (_data.startsWith('navigate')) {
|
||||
final _route = _data
|
||||
.replaceAll('navigate(', '')
|
||||
.replaceAll('(', '')
|
||||
.replaceAll(')', '');
|
||||
Navigator.of(context).pushNamed(_route);
|
||||
return;
|
||||
}
|
||||
if (_data.startsWith('pop')) {
|
||||
final _route = _data
|
||||
.replaceAll('pop(', '')
|
||||
.replaceAll('(', '')
|
||||
.replaceAll(')', '');
|
||||
if (_route.isNotEmpty) {
|
||||
Navigator.popUntil(context, ModalRoute.withName(_route));
|
||||
} else {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (_data.startsWith('maybePop')) {
|
||||
Navigator.of(context).maybePop();
|
||||
return;
|
||||
}
|
||||
if (_data.startsWith('launch')) {
|
||||
final _url = _data
|
||||
.replaceAll("launch(", '')
|
||||
.replaceAll('(', '')
|
||||
.replaceAll(')', '')
|
||||
.replaceAll("\'", '');
|
||||
launch('$_url');
|
||||
return;
|
||||
}
|
||||
if (_data.startsWith('alert')) {
|
||||
final _message = _data
|
||||
.replaceAll('alert(', '')
|
||||
.replaceAll('(', '')
|
||||
.replaceAll(')', '');
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text('Info'),
|
||||
content: Text(_message),
|
||||
actions: [
|
||||
FlatButton(
|
||||
child: Text('Ok'),
|
||||
onPressed: () => Navigator.maybePop(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Widget render(BuildContext context, [bool nullOk = false]) {
|
||||
if (base != null) {
|
||||
if (base is WidgetBase) {
|
||||
return Builder(
|
||||
builder: (context) {
|
||||
return (base as WidgetBase)?.build(context);
|
||||
},
|
||||
);
|
||||
}
|
||||
if (base is WidgetBase) {
|
||||
return Builder(
|
||||
builder: (context) {
|
||||
return (base as WidgetBase).build(context);
|
||||
},
|
||||
);
|
||||
}
|
||||
if (nullOk) {
|
||||
if (nullOk) {
|
||||
return null;
|
||||
}
|
||||
return Container();
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import '../../flutter_dynamic_widget.dart';
|
||||
import '../base.dart';
|
||||
import './index.dart';
|
||||
|
||||
class MaterialBase extends WidgetLibrary {
|
||||
MaterialBase(this.data, this.widgetContext);
|
||||
@@ -10,7 +8,7 @@ class MaterialBase extends WidgetLibrary {
|
||||
GenerateWidget get widgetRender => (context, data) {
|
||||
if (data is Map) {
|
||||
final _base = MaterialBase(data, context);
|
||||
final _config = _base?.base;
|
||||
final _config = _base.base;
|
||||
if (_config is WidgetBase) {
|
||||
return _config;
|
||||
}
|
||||
@@ -40,14 +38,13 @@ class MaterialBase extends WidgetLibrary {
|
||||
|
||||
@override
|
||||
WidgetConfig get base {
|
||||
if (data == null) return null;
|
||||
final name = data['name'].toString();
|
||||
final _materialBase = library[name];
|
||||
if (_materialBase != null) return _materialBase;
|
||||
return DynamicWidget(
|
||||
data: data,
|
||||
widgetContext: widgetContext,
|
||||
)?.base;
|
||||
).base;
|
||||
}
|
||||
|
||||
static ActionCallback onAction = (context, val) {
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'package:url_launcher/url_launcher.dart';
|
||||
import 'string_gen.dart';
|
||||
|
||||
T getEnum<T>(String val, {T fallback, List<T> values}) {
|
||||
if (val == null) return fallback;
|
||||
final _value = val.replaceAll('#', '');
|
||||
return values.firstWhere(
|
||||
(element) => element.toString() == _value,
|
||||
@@ -21,7 +20,6 @@ Key getKey(dynamic value, [Key fallback]) {
|
||||
}
|
||||
|
||||
Paint getPaint(Map<String, dynamic> data, [Paint fallback]) {
|
||||
if (data == null) return fallback;
|
||||
if (data['params'] == null) return fallback;
|
||||
final params = data['params'];
|
||||
// TODO: get values here
|
||||
@@ -29,7 +27,6 @@ Paint getPaint(Map<String, dynamic> data, [Paint fallback]) {
|
||||
}
|
||||
|
||||
Decoration getDecoration(Map<String, dynamic> data, [Decoration fallback]) {
|
||||
if (data == null) return fallback;
|
||||
if (data['params'] == null) return fallback;
|
||||
final params = data['params'];
|
||||
// TODO: get values here
|
||||
@@ -37,7 +34,6 @@ Decoration getDecoration(Map<String, dynamic> data, [Decoration fallback]) {
|
||||
}
|
||||
|
||||
Duration getDuration(Map<String, dynamic> data, [Duration fallback]) {
|
||||
if (data == null) return fallback;
|
||||
if (data['params'] == null) return fallback;
|
||||
final params = data['params'];
|
||||
if (!params.toString().contains('zero')) {
|
||||
@@ -62,7 +58,6 @@ Duration getDuration(Map<String, dynamic> data, [Duration fallback]) {
|
||||
|
||||
BorderRadiusGeometry getBorderRadiusGeometry(Map<String, dynamic> data,
|
||||
[BorderRadiusGeometry fallback]) {
|
||||
if (data == null) return fallback;
|
||||
if (data['params'] == null) return fallback;
|
||||
final params = data['params'];
|
||||
// TODO: get values here
|
||||
@@ -70,7 +65,6 @@ BorderRadiusGeometry getBorderRadiusGeometry(Map<String, dynamic> data,
|
||||
}
|
||||
|
||||
Matrix4 getMatrix4(Map<String, dynamic> data, [Matrix4 fallback]) {
|
||||
if (data == null) return fallback;
|
||||
if (data['params'] == null) return fallback;
|
||||
final params = data['params'];
|
||||
// TODO: get values here
|
||||
@@ -79,7 +73,6 @@ Matrix4 getMatrix4(Map<String, dynamic> data, [Matrix4 fallback]) {
|
||||
|
||||
BorderStyle getBorderStyle(Map<String, dynamic> data,
|
||||
[BorderStyle fallback = BorderStyle.none]) {
|
||||
if (data == null) return fallback;
|
||||
if (data['params'] == null) return fallback;
|
||||
final params = data['params'];
|
||||
// TODO: get values here
|
||||
@@ -87,7 +80,6 @@ BorderStyle getBorderStyle(Map<String, dynamic> data,
|
||||
}
|
||||
|
||||
FocusNode getFocusNode(Map<String, dynamic> data, [FocusNode fallback]) {
|
||||
if (data == null) return fallback;
|
||||
if (data['params'] == null) return fallback;
|
||||
final params = data['params'];
|
||||
final debugLabel = getString(params['debugLabel']);
|
||||
@@ -104,7 +96,6 @@ FocusNode getFocusNode(Map<String, dynamic> data, [FocusNode fallback]) {
|
||||
|
||||
BorderSide getBorderSide(Map<String, dynamic> data,
|
||||
[BorderSide fallback = BorderSide.none]) {
|
||||
if (data == null) return fallback;
|
||||
if (data['params'] == null) return fallback;
|
||||
final params = data['params'];
|
||||
return null;
|
||||
@@ -133,7 +124,6 @@ List<Alignment> getAlignmentValues() {
|
||||
}
|
||||
|
||||
ShapeBorder getShapeBorder(Map<String, dynamic> data, [ShapeBorder fallback]) {
|
||||
if (data == null) return fallback;
|
||||
if (data['params'] == null) return fallback;
|
||||
final params = data['params'];
|
||||
final top = getBorderSide(params['top']);
|
||||
@@ -167,7 +157,6 @@ ShapeBorder getShapeBorder(Map<String, dynamic> data, [ShapeBorder fallback]) {
|
||||
}
|
||||
|
||||
Offset getOffset(Map<String, dynamic> data, [Offset fallback]) {
|
||||
if (data == null) return fallback;
|
||||
if (data['params'] == null) return fallback;
|
||||
final params = data['params'];
|
||||
final dx = getDouble(params['dx']);
|
||||
@@ -176,7 +165,6 @@ Offset getOffset(Map<String, dynamic> data, [Offset fallback]) {
|
||||
}
|
||||
|
||||
BoxShadow getBoxShadow(Map<String, dynamic> data, [BoxShadow fallback]) {
|
||||
if (data == null) return fallback;
|
||||
if (data['params'] == null) return fallback;
|
||||
final params = data['params'];
|
||||
final color = getColor(params['color']);
|
||||
@@ -226,16 +214,14 @@ Map<String, dynamic> setIconData(IconData value) {
|
||||
'id': StringGen.id,
|
||||
'params': {
|
||||
'0': value.codePoint,
|
||||
if (value?.fontFamily != null) 'fontFamily': value?.fontFamily,
|
||||
if (value?.fontPackage != null) 'fontPackage': value?.fontPackage,
|
||||
if (value?.matchTextDirection != null)
|
||||
'matchTextDirection': value?.matchTextDirection,
|
||||
if (value.fontFamily != null) 'fontFamily': value.fontFamily,
|
||||
if (value.fontPackage != null) 'fontPackage': value.fontPackage,
|
||||
'matchTextDirection': value.matchTextDirection,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
IconData getIconData(Map<String, dynamic> data, [IconData fallback]) {
|
||||
if (data == null) return fallback;
|
||||
final name = data['name'];
|
||||
if (name == 'IconData') {
|
||||
final params = data['params'];
|
||||
@@ -258,10 +244,10 @@ IconData getIconData(Map<String, dynamic> data, [IconData fallback]) {
|
||||
getBool(params['matchTextDirection'], matchTextDirection);
|
||||
}
|
||||
return IconData(
|
||||
codePoint ?? fallback?.codePoint,
|
||||
fontFamily: fontFamily ?? fallback?.fontFamily,
|
||||
fontPackage: fontPackage ?? fallback?.fontPackage,
|
||||
matchTextDirection: matchTextDirection ?? fallback?.matchTextDirection,
|
||||
codePoint ?? fallback.codePoint,
|
||||
fontFamily: fontFamily ?? fallback.fontFamily,
|
||||
fontPackage: fontPackage ?? fallback.fontPackage,
|
||||
matchTextDirection: matchTextDirection ?? fallback.matchTextDirection,
|
||||
);
|
||||
}
|
||||
return fallback;
|
||||
@@ -455,10 +441,10 @@ Map<String, dynamic> setEdgeInsets(EdgeInsets val) {
|
||||
'id': StringGen.id,
|
||||
'name': 'EdgeInsets.only',
|
||||
'params': {
|
||||
'top': val?.top ?? 0,
|
||||
'bottom': val?.bottom ?? 0,
|
||||
'left': val?.left ?? 0,
|
||||
'right': val?.right ?? 0,
|
||||
'top': val.top ?? 0,
|
||||
'bottom': val.bottom ?? 0,
|
||||
'left': val.left ?? 0,
|
||||
'right': val.right ?? 0,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -471,10 +457,10 @@ extension EdgeInsetUtils on EdgeInsets {
|
||||
double bottom,
|
||||
]) {
|
||||
return EdgeInsets.only(
|
||||
top: top ?? this?.top ?? 0,
|
||||
left: left ?? this?.left ?? 0,
|
||||
right: right ?? this?.right ?? 0,
|
||||
bottom: bottom ?? this?.bottom ?? 0,
|
||||
top: top ?? this.top ?? 0,
|
||||
left: left ?? this.left ?? 0,
|
||||
right: right ?? this.right ?? 0,
|
||||
bottom: bottom ?? this.bottom ?? 0,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import 'base_class.dart';
|
||||
import 'widget_index.dart';
|
||||
|
||||
@@ -941,13 +941,11 @@ class WidgetIndex {
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'version': version,
|
||||
'widgets': widgets?.map((x) => x?.toMap())?.toList(),
|
||||
'widgets': widgets.map((x) => x.toMap()).toList(),
|
||||
};
|
||||
}
|
||||
|
||||
static WidgetIndex fromMap(Map<String, dynamic> map) {
|
||||
if (map == null) return null;
|
||||
|
||||
return WidgetIndex(
|
||||
version: map['version'],
|
||||
widgets: List<FlutterWidget>.from(
|
||||
@@ -980,8 +978,6 @@ class FlutterWidget {
|
||||
}
|
||||
|
||||
static FlutterWidget fromMap(Map<String, dynamic> map) {
|
||||
if (map == null) return null;
|
||||
|
||||
return FlutterWidget(
|
||||
name: map['name'],
|
||||
description: map['description'],
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
|
||||
|
||||
import 'method_channel.dart';
|
||||
|
||||
@@ -10,17 +10,9 @@ void newWindow(
|
||||
}) {
|
||||
final screen = html.window.screen;
|
||||
double top = 0;
|
||||
if (dy != null) {
|
||||
top = dy;
|
||||
} else if (screen.height != null) {
|
||||
top = (screen.height - height) / 2;
|
||||
}
|
||||
top = dy;
|
||||
double left = 0;
|
||||
if (dx != null) {
|
||||
left = dx;
|
||||
} else if (screen.width != null) {
|
||||
left = (screen.width - width) / 2;
|
||||
}
|
||||
left = dx;
|
||||
final sb = StringBuffer();
|
||||
sb.write("height=");
|
||||
sb.write(height);
|
||||
|
||||
@@ -64,8 +64,6 @@ class NewWindow {
|
||||
}
|
||||
|
||||
static NewWindow fromMap(Map<String, dynamic> map) {
|
||||
if (map == null) return null;
|
||||
|
||||
return NewWindow(
|
||||
url: map['url'],
|
||||
width: map['width'],
|
||||
@@ -114,8 +112,8 @@ void createWindow(NewWindow window) {
|
||||
window.url,
|
||||
window.width,
|
||||
window.height,
|
||||
dx: window?.offsetX,
|
||||
dy: window?.offsetY,
|
||||
name: window?.name,
|
||||
dx: window.offsetX,
|
||||
dy: window.offsetY,
|
||||
name: window.name,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -84,10 +84,10 @@ class _MyAppState extends State<MyApp> {
|
||||
final height = size.height;
|
||||
final width = size.width;
|
||||
final sb = StringBuffer();
|
||||
final top = offset?.dy ??
|
||||
final top = offset.dy ??
|
||||
(screen.height != null ? (screen.height - height) / 2 : 0);
|
||||
final left =
|
||||
offset?.dx ?? (screen.width != null ? (screen.width - width) / 2 : 0);
|
||||
offset.dx ?? (screen.width != null ? (screen.width - width) / 2 : 0);
|
||||
sb.write("height=");
|
||||
sb.write(height);
|
||||
sb.write(",width=");
|
||||
|
||||
@@ -62,7 +62,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
),
|
||||
Text(
|
||||
'$_counter',
|
||||
style: Theme.of(context).textTheme.headline4,
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -32,7 +32,6 @@ class WasmLoader extends WasmImpl {
|
||||
|
||||
@override
|
||||
Future<bool> init() async {
|
||||
assert(_path != null);
|
||||
final _data = await rootBundle.load(_path);
|
||||
_wasm = await Instance.fromBufferAsync(_data.buffer);
|
||||
return isReady;
|
||||
|
||||
@@ -26,9 +26,7 @@ void _setTargetPlatformForDesktop() {
|
||||
} else if (Platform.isLinux || Platform.isWindows) {
|
||||
targetPlatform = TargetPlatform.android;
|
||||
}
|
||||
if (targetPlatform != null) {
|
||||
debugDefaultTargetPlatformOverride = targetPlatform;
|
||||
}
|
||||
debugDefaultTargetPlatformOverride = targetPlatform;
|
||||
}
|
||||
|
||||
class MyApp extends StatefulWidget {
|
||||
|
||||
@@ -12,9 +12,7 @@ class MyApp extends StatelessWidget {
|
||||
debugShowCheckedModeBanner: false,
|
||||
title: 'Flutter Demo',
|
||||
theme: ThemeData(
|
||||
primarySwatch: Colors.blue,
|
||||
accentColor: Colors.red,
|
||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||
visualDensity: VisualDensity.adaptivePlatformDensity, colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.blue).copyWith(secondary: Colors.red),
|
||||
),
|
||||
home: MyHomePage(title: 'Flutter Golden Layout'),
|
||||
);
|
||||
@@ -88,7 +86,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
),
|
||||
body: GoldenLayoutTheme(
|
||||
data: GoldenLayoutThemeData(
|
||||
tabSelectedBackgroundColor: Theme.of(context).accentColor,
|
||||
tabSelectedBackgroundColor: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
child: GoldenLayout(
|
||||
controller: _controller,
|
||||
@@ -103,7 +101,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
title: (context, selected, index) => Text(
|
||||
'Window $count',
|
||||
style: TextStyle(
|
||||
color: selected ? Theme.of(context).accentColor : Colors.white,
|
||||
color: selected ? Theme.of(context).colorScheme.secondary : Colors.white,
|
||||
),
|
||||
),
|
||||
child: Container(color: Colors.red[100 * count]));
|
||||
|
||||
@@ -34,55 +34,51 @@ class _GoldenLayoutState extends State<GoldenLayout> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_controller = widget?.controller ?? WindowController();
|
||||
if (widget?.collection != null) {
|
||||
_controller.base = widget.collection;
|
||||
}
|
||||
super.initState();
|
||||
_controller = widget.controller ?? WindowController();
|
||||
_controller.base = widget.collection;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(builder: (context, dimens) {
|
||||
if (_controller.fullScreen != null) {
|
||||
return RenderWindowGroup(
|
||||
onAddTab: widget.onAddTab,
|
||||
onCancel: (val) {
|
||||
_controller.addToBase(val);
|
||||
},
|
||||
isDragging: _isDragging,
|
||||
onDraggingChanged: (val) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isDragging = val;
|
||||
});
|
||||
}
|
||||
},
|
||||
popUpSize: widget.popupSize,
|
||||
minimize: true,
|
||||
group: _controller.fullScreen,
|
||||
onFullScreen: () {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_controller.exitFullScreen();
|
||||
});
|
||||
}
|
||||
},
|
||||
onClose: !_controller.fullScreen.canClose
|
||||
? null
|
||||
: () {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_controller.exitFullScreen(true);
|
||||
});
|
||||
}
|
||||
},
|
||||
update: () {
|
||||
if (mounted) setState(() {});
|
||||
},
|
||||
);
|
||||
}
|
||||
return _renderItem(
|
||||
return RenderWindowGroup(
|
||||
onAddTab: widget.onAddTab,
|
||||
onCancel: (val) {
|
||||
_controller.addToBase(val);
|
||||
},
|
||||
isDragging: _isDragging,
|
||||
onDraggingChanged: (val) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isDragging = val;
|
||||
});
|
||||
}
|
||||
},
|
||||
popUpSize: widget.popupSize,
|
||||
minimize: true,
|
||||
group: _controller.fullScreen,
|
||||
onFullScreen: () {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_controller.exitFullScreen();
|
||||
});
|
||||
}
|
||||
},
|
||||
onClose: !_controller.fullScreen.canClose
|
||||
? null
|
||||
: () {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_controller.exitFullScreen(true);
|
||||
});
|
||||
}
|
||||
},
|
||||
update: () {
|
||||
if (mounted) setState(() {});
|
||||
},
|
||||
);
|
||||
return _renderItem(
|
||||
_controller.base,
|
||||
index: 0,
|
||||
size: Size(dimens.maxWidth, dimens.maxHeight),
|
||||
|
||||
@@ -27,7 +27,7 @@ class _WindowAcceptRegionState extends State<WindowAcceptRegion> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox.fromSize(
|
||||
size: widget?.size,
|
||||
size: widget.size,
|
||||
child: LayoutBuilder(
|
||||
builder: (context, dimens) => Stack(
|
||||
fit: StackFit.expand,
|
||||
@@ -42,22 +42,22 @@ class _WindowAcceptRegionState extends State<WindowAcceptRegion> {
|
||||
),
|
||||
),
|
||||
Positioned.fill(
|
||||
left: widget?.left ?? 0,
|
||||
right: widget?.right ?? 0,
|
||||
top: widget?.top ?? 0,
|
||||
bottom: widget?.bottom ?? 0,
|
||||
left: widget.left ?? 0,
|
||||
right: widget.right ?? 0,
|
||||
top: widget.top ?? 0,
|
||||
bottom: widget.bottom ?? 0,
|
||||
child: Container(
|
||||
child: DragTarget<WindowTab>(
|
||||
builder: (context, accepted, rejected) => Container(),
|
||||
onAccept: (val) {
|
||||
onAcceptWithDetails: (val) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
accepting = false;
|
||||
});
|
||||
}
|
||||
if (widget.onAccept != null) widget.onAccept(val);
|
||||
widget.onAccept(val);
|
||||
},
|
||||
onWillAccept: (val) {
|
||||
onWillAcceptWithDetails: (val) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
accepting = true;
|
||||
|
||||
@@ -24,12 +24,8 @@ class WindowController extends ChangeNotifier {
|
||||
WindowCollection base = WindowColumn([]);
|
||||
|
||||
void addToBase(WindowTab tab) {
|
||||
if (base == null) {
|
||||
base = WindowColumn([WindowGroup(tab)]);
|
||||
} else {
|
||||
_addTab(base, tab);
|
||||
}
|
||||
notifyListeners();
|
||||
_addTab(base, tab);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
bool _addTab(WindowCollection item, WindowTab tab) {
|
||||
|
||||
@@ -36,7 +36,7 @@ class WindowColumn extends WindowCollection {
|
||||
|
||||
class WindowGroup extends WindowCollection {
|
||||
WindowGroup([WindowTab tab, bool closeable = true]) {
|
||||
if (tab != null) _tabs.add(tab);
|
||||
_tabs.add(tab);
|
||||
canClose = closeable;
|
||||
}
|
||||
bool canClose = true;
|
||||
@@ -56,14 +56,9 @@ class WindowGroup extends WindowCollection {
|
||||
}
|
||||
|
||||
void addTab(WindowTab tab, [int index]) {
|
||||
if (index != null) {
|
||||
_tabs.insert(index, tab);
|
||||
_activeTab = index;
|
||||
} else {
|
||||
_tabs.add(tab);
|
||||
_activeTab = _tabs.length - 1;
|
||||
}
|
||||
notifyListeners();
|
||||
_tabs.insert(index, tab);
|
||||
_activeTab = index;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void removeTab(WindowTab tab) {
|
||||
|
||||
@@ -54,11 +54,11 @@ class _RenderWindowGroupState extends State<RenderWindowGroup> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final _theme =
|
||||
GoldenLayoutTheme.of(context)?.theme ?? GoldenLayoutThemeData();
|
||||
GoldenLayoutTheme.of(context).theme ?? GoldenLayoutThemeData();
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
color: _theme?.backgroundColor,
|
||||
color: _theme.backgroundColor,
|
||||
height: 32,
|
||||
child: Row(
|
||||
children: [
|
||||
@@ -72,13 +72,12 @@ class _RenderWindowGroupState extends State<RenderWindowGroup> {
|
||||
for (var i = 0; i < widget.group.tabs.length; i++)
|
||||
Draggable<WindowTab>(
|
||||
data: widget.group.tabs[i],
|
||||
dragAnchor: DragAnchor.child,
|
||||
onDragStarted: () {
|
||||
_draggingTab = widget.group.tabs[i];
|
||||
widget.group.removeTab(_draggingTab);
|
||||
widget.update();
|
||||
if (widget.group.tabs.isEmpty) {
|
||||
widget.onClose?.call();
|
||||
widget.onClose.call();
|
||||
}
|
||||
widget.onDraggingChanged(true);
|
||||
},
|
||||
@@ -128,7 +127,7 @@ class _RenderWindowGroupState extends State<RenderWindowGroup> {
|
||||
});
|
||||
}
|
||||
},
|
||||
onWillAccept: (val) {
|
||||
onWillAcceptWithDetails: (val) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
accepting = i;
|
||||
@@ -136,7 +135,7 @@ class _RenderWindowGroupState extends State<RenderWindowGroup> {
|
||||
}
|
||||
return true;
|
||||
},
|
||||
onAccept: (val) {
|
||||
onAcceptWithDetails: (val) {
|
||||
widget.onModify(
|
||||
context, val, WindowPos.tab, accepting);
|
||||
if (mounted) {
|
||||
@@ -155,9 +154,9 @@ class _RenderWindowGroupState extends State<RenderWindowGroup> {
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: selected
|
||||
? _theme?.tabSelectedBackgroundColor ??
|
||||
? _theme.tabSelectedBackgroundColor ??
|
||||
Colors.grey.shade600
|
||||
: _theme?.backgroundColor,
|
||||
: _theme.backgroundColor,
|
||||
borderRadius: selected
|
||||
? BorderRadius.only(
|
||||
topLeft: Radius.circular(5),
|
||||
@@ -197,17 +196,17 @@ class _RenderWindowGroupState extends State<RenderWindowGroup> {
|
||||
child: Icon(
|
||||
Icons.close,
|
||||
size: 18,
|
||||
color: _theme?.tabIconColor ??
|
||||
color: _theme.tabIconColor ??
|
||||
Colors.white,
|
||||
),
|
||||
onTap: () {
|
||||
widget.group.tabs[i].onClose
|
||||
?.call();
|
||||
.call();
|
||||
widget.group.removeTab(
|
||||
widget.group.tabs[i]);
|
||||
widget.update();
|
||||
if (widget.group.tabs.isEmpty) {
|
||||
widget.onClose?.call();
|
||||
widget.onClose.call();
|
||||
}
|
||||
},
|
||||
),
|
||||
@@ -225,17 +224,16 @@ class _RenderWindowGroupState extends State<RenderWindowGroup> {
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
), dragAnchorStrategy: childDragAnchorStrategy,
|
||||
),
|
||||
if (widget.onAddTab != null)
|
||||
IconButton(
|
||||
iconSize: 20,
|
||||
icon: Icon(
|
||||
Icons.add,
|
||||
color: Colors.white,
|
||||
),
|
||||
onPressed: () =>
|
||||
widget.group.addTab(widget.onAddTab())),
|
||||
IconButton(
|
||||
iconSize: 20,
|
||||
icon: Icon(
|
||||
Icons.add,
|
||||
color: Colors.white,
|
||||
),
|
||||
onPressed: () =>
|
||||
widget.group.addTab(widget.onAddTab())),
|
||||
if (widget.isDragging)
|
||||
WindowAcceptRegion(
|
||||
size: Size(100, 32),
|
||||
@@ -249,18 +247,17 @@ class _RenderWindowGroupState extends State<RenderWindowGroup> {
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
color: _theme?.tabIconColor ?? Colors.white,
|
||||
color: _theme.tabIconColor ?? Colors.white,
|
||||
iconSize: 18,
|
||||
icon: Icon(widget.minimize ? Icons.minimize : Icons.fullscreen),
|
||||
onPressed: widget.onFullScreen,
|
||||
),
|
||||
if (widget.onClose != null)
|
||||
IconButton(
|
||||
color: _theme?.tabIconColor ?? Colors.white,
|
||||
iconSize: 18,
|
||||
icon: Icon(Icons.close),
|
||||
onPressed: widget.onClose,
|
||||
),
|
||||
IconButton(
|
||||
color: _theme.tabIconColor ?? Colors.white,
|
||||
iconSize: 18,
|
||||
icon: Icon(Icons.close),
|
||||
onPressed: widget.onClose,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -17,8 +17,7 @@ class MyApp extends StatelessWidget {
|
||||
debugShowCheckedModeBanner: false,
|
||||
title: 'Flutter Icon Resizer',
|
||||
theme: ThemeData.light().copyWith(
|
||||
primaryColor: Colors.blue,
|
||||
accentColor: Colors.red,
|
||||
primaryColor: Colors.blue, colorScheme: ColorScheme.fromSwatch().copyWith(secondary: Colors.red),
|
||||
),
|
||||
darkTheme: ThemeData.dark(),
|
||||
home: HomeScreen(),
|
||||
@@ -179,10 +178,8 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
if (kIsWeb) {
|
||||
Uri dataUrl;
|
||||
try {
|
||||
if (binaryData != null) {
|
||||
dataUrl = Uri.dataFromBytes(binaryData);
|
||||
}
|
||||
} catch (e) {
|
||||
dataUrl = Uri.dataFromBytes(binaryData);
|
||||
} catch (e) {
|
||||
if (!silentErrors) {
|
||||
throw Exception("Error Creating File Data: $e");
|
||||
}
|
||||
@@ -315,7 +312,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
SwitchListTile(
|
||||
title: Text(
|
||||
'Export $name Icons',
|
||||
style: Theme.of(context).textTheme.headline4,
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
value: toggle,
|
||||
onChanged: onChanged,
|
||||
@@ -338,27 +335,27 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
DataTable(
|
||||
columns: [
|
||||
DataColumn(label: Text('Size')),
|
||||
if (icons is List<IosIcon>) ...[
|
||||
DataColumn(label: Text('Prefix')),
|
||||
DataColumn(label: Text('Ext')),
|
||||
DataColumn(label: Text('Scale')),
|
||||
DataColumn(label: Text('Point5')),
|
||||
],
|
||||
if (icons is List<MacOSIcon>) ...[
|
||||
DataColumn(label: Text('Prefix')),
|
||||
DataColumn(label: Text('Ext')),
|
||||
DataColumn(label: Text('Scale')),
|
||||
],
|
||||
if (icons is List<WebIcon>) ...[
|
||||
DataColumn(label: Text('Prefix')),
|
||||
DataColumn(label: Text('Ext')),
|
||||
],
|
||||
if (icons is List<AndroidIcon>) ...[
|
||||
DataColumn(label: Text('Name')),
|
||||
DataColumn(label: Text('Folder')),
|
||||
DataColumn(label: Text('Suffix')),
|
||||
DataColumn(label: Text('Ext')),
|
||||
],
|
||||
...[
|
||||
DataColumn(label: Text('Prefix')),
|
||||
DataColumn(label: Text('Ext')),
|
||||
DataColumn(label: Text('Scale')),
|
||||
DataColumn(label: Text('Point5')),
|
||||
],
|
||||
...[
|
||||
DataColumn(label: Text('Prefix')),
|
||||
DataColumn(label: Text('Ext')),
|
||||
DataColumn(label: Text('Scale')),
|
||||
],
|
||||
...[
|
||||
DataColumn(label: Text('Prefix')),
|
||||
DataColumn(label: Text('Ext')),
|
||||
],
|
||||
...[
|
||||
DataColumn(label: Text('Name')),
|
||||
DataColumn(label: Text('Folder')),
|
||||
DataColumn(label: Text('Suffix')),
|
||||
DataColumn(label: Text('Ext')),
|
||||
],
|
||||
DataColumn(label: Text('Delete')),
|
||||
],
|
||||
rows: [
|
||||
@@ -396,258 +393,258 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
),
|
||||
),
|
||||
),
|
||||
if (icons is List<IosIcon>) ...[
|
||||
DataCell(
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration.collapsed(
|
||||
hintText: 'Prefix',
|
||||
),
|
||||
initialValue: icons[i].prefix,
|
||||
onChanged: (val) {
|
||||
try {
|
||||
if (mounted)
|
||||
setState(() {
|
||||
icons[i] = icons[i].copyWith(prefix: val);
|
||||
});
|
||||
} catch (e) {}
|
||||
},
|
||||
...[
|
||||
DataCell(
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration.collapsed(
|
||||
hintText: 'Prefix',
|
||||
),
|
||||
),
|
||||
),
|
||||
DataCell(
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration.collapsed(
|
||||
hintText: 'Ext',
|
||||
),
|
||||
initialValue: icons[i].ext,
|
||||
onChanged: (val) {
|
||||
try {
|
||||
if (mounted)
|
||||
setState(() {
|
||||
icons[i] = icons[i].copyWith(ext: val);
|
||||
});
|
||||
} catch (e) {}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
DataCell(
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration.collapsed(
|
||||
hintText: 'Scale',
|
||||
),
|
||||
initialValue: icons[i].scale.toString(),
|
||||
onChanged: (val) {
|
||||
try {
|
||||
if (mounted)
|
||||
setState(() {
|
||||
final _value = int.tryParse(val);
|
||||
icons[i] =
|
||||
icons[i].copyWith(scale: _value);
|
||||
});
|
||||
} catch (e) {}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
DataCell(
|
||||
Switch(
|
||||
value: icons[i].point5,
|
||||
initialValue: icons[i].prefix,
|
||||
onChanged: (val) {
|
||||
if (mounted)
|
||||
setState(() {
|
||||
icons[i] = icons[i].copyWith(point5: val);
|
||||
});
|
||||
try {
|
||||
if (mounted)
|
||||
setState(() {
|
||||
icons[i] = icons[i].copyWith(prefix: val);
|
||||
});
|
||||
} catch (e) {}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
if (icons is List<MacOSIcon>) ...[
|
||||
DataCell(
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration.collapsed(
|
||||
hintText: 'Prefix',
|
||||
),
|
||||
initialValue: icons[i].prefix,
|
||||
onChanged: (val) {
|
||||
try {
|
||||
if (mounted)
|
||||
setState(() {
|
||||
icons[i] = icons[i].copyWith(prefix: val);
|
||||
});
|
||||
} catch (e) {}
|
||||
},
|
||||
),
|
||||
DataCell(
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration.collapsed(
|
||||
hintText: 'Ext',
|
||||
),
|
||||
initialValue: icons[i].ext,
|
||||
onChanged: (val) {
|
||||
try {
|
||||
if (mounted)
|
||||
setState(() {
|
||||
icons[i] = icons[i].copyWith(ext: val);
|
||||
});
|
||||
} catch (e) {}
|
||||
},
|
||||
),
|
||||
),
|
||||
DataCell(
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration.collapsed(
|
||||
hintText: 'Ext',
|
||||
),
|
||||
initialValue: icons[i].ext,
|
||||
onChanged: (val) {
|
||||
try {
|
||||
if (mounted)
|
||||
setState(() {
|
||||
icons[i] = icons[i].copyWith(ext: val);
|
||||
});
|
||||
} catch (e) {}
|
||||
},
|
||||
),
|
||||
DataCell(
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration.collapsed(
|
||||
hintText: 'Scale',
|
||||
),
|
||||
initialValue: icons[i].scale.toString(),
|
||||
onChanged: (val) {
|
||||
try {
|
||||
if (mounted)
|
||||
setState(() {
|
||||
final _value = int.tryParse(val);
|
||||
icons[i] =
|
||||
icons[i].copyWith(scale: _value);
|
||||
});
|
||||
} catch (e) {}
|
||||
},
|
||||
),
|
||||
),
|
||||
DataCell(
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration.collapsed(
|
||||
hintText: 'Scale',
|
||||
),
|
||||
initialValue: icons[i].scale.toString(),
|
||||
onChanged: (val) {
|
||||
try {
|
||||
if (mounted)
|
||||
setState(() {
|
||||
final _value = int.tryParse(val);
|
||||
icons[i] =
|
||||
icons[i].copyWith(scale: _value);
|
||||
});
|
||||
} catch (e) {}
|
||||
},
|
||||
),
|
||||
DataCell(
|
||||
Switch(
|
||||
value: icons[i].point5,
|
||||
onChanged: (val) {
|
||||
if (mounted)
|
||||
setState(() {
|
||||
icons[i] = icons[i].copyWith(point5: val);
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
...[
|
||||
DataCell(
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration.collapsed(
|
||||
hintText: 'Prefix',
|
||||
),
|
||||
initialValue: icons[i].prefix,
|
||||
onChanged: (val) {
|
||||
try {
|
||||
if (mounted)
|
||||
setState(() {
|
||||
icons[i] = icons[i].copyWith(prefix: val);
|
||||
});
|
||||
} catch (e) {}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
if (icons is List<WebIcon>) ...[
|
||||
DataCell(
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration.collapsed(
|
||||
hintText: 'Prefix',
|
||||
),
|
||||
initialValue: icons[i].prefix,
|
||||
onChanged: (val) {
|
||||
try {
|
||||
if (mounted)
|
||||
setState(() {
|
||||
icons[i] = icons[i].copyWith(prefix: val);
|
||||
});
|
||||
} catch (e) {}
|
||||
},
|
||||
),
|
||||
DataCell(
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration.collapsed(
|
||||
hintText: 'Ext',
|
||||
),
|
||||
initialValue: icons[i].ext,
|
||||
onChanged: (val) {
|
||||
try {
|
||||
if (mounted)
|
||||
setState(() {
|
||||
icons[i] = icons[i].copyWith(ext: val);
|
||||
});
|
||||
} catch (e) {}
|
||||
},
|
||||
),
|
||||
),
|
||||
DataCell(
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration.collapsed(
|
||||
hintText: 'Ext',
|
||||
),
|
||||
initialValue: icons[i].ext,
|
||||
onChanged: (val) {
|
||||
try {
|
||||
if (mounted)
|
||||
setState(() {
|
||||
icons[i] = icons[i].copyWith(ext: val);
|
||||
});
|
||||
} catch (e) {}
|
||||
},
|
||||
),
|
||||
DataCell(
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration.collapsed(
|
||||
hintText: 'Scale',
|
||||
),
|
||||
initialValue: icons[i].scale.toString(),
|
||||
onChanged: (val) {
|
||||
try {
|
||||
if (mounted)
|
||||
setState(() {
|
||||
final _value = int.tryParse(val);
|
||||
icons[i] =
|
||||
icons[i].copyWith(scale: _value);
|
||||
});
|
||||
} catch (e) {}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
if (icons is List<AndroidIcon>) ...[
|
||||
DataCell(
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration.collapsed(
|
||||
hintText: 'Name',
|
||||
),
|
||||
initialValue: icons[i].name,
|
||||
onChanged: (val) {
|
||||
try {
|
||||
if (mounted)
|
||||
setState(() {
|
||||
icons[i] = icons[i].copyWith(name: val);
|
||||
});
|
||||
} catch (e) {}
|
||||
},
|
||||
),
|
||||
],
|
||||
...[
|
||||
DataCell(
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration.collapsed(
|
||||
hintText: 'Prefix',
|
||||
),
|
||||
initialValue: icons[i].prefix,
|
||||
onChanged: (val) {
|
||||
try {
|
||||
if (mounted)
|
||||
setState(() {
|
||||
icons[i] = icons[i].copyWith(prefix: val);
|
||||
});
|
||||
} catch (e) {}
|
||||
},
|
||||
),
|
||||
),
|
||||
DataCell(
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration.collapsed(
|
||||
hintText: 'Folder',
|
||||
),
|
||||
initialValue: icons[i].folder,
|
||||
onChanged: (val) {
|
||||
try {
|
||||
if (mounted)
|
||||
setState(() {
|
||||
icons[i] = icons[i].copyWith(folder: val);
|
||||
});
|
||||
} catch (e) {}
|
||||
},
|
||||
),
|
||||
DataCell(
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration.collapsed(
|
||||
hintText: 'Ext',
|
||||
),
|
||||
initialValue: icons[i].ext,
|
||||
onChanged: (val) {
|
||||
try {
|
||||
if (mounted)
|
||||
setState(() {
|
||||
icons[i] = icons[i].copyWith(ext: val);
|
||||
});
|
||||
} catch (e) {}
|
||||
},
|
||||
),
|
||||
),
|
||||
DataCell(
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration.collapsed(
|
||||
hintText: 'Suffix',
|
||||
),
|
||||
initialValue: icons[i].folderSuffix,
|
||||
onChanged: (val) {
|
||||
try {
|
||||
if (mounted)
|
||||
setState(() {
|
||||
icons[i] =
|
||||
icons[i].copyWith(folderSuffix: val);
|
||||
});
|
||||
} catch (e) {}
|
||||
},
|
||||
),
|
||||
],
|
||||
...[
|
||||
DataCell(
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration.collapsed(
|
||||
hintText: 'Name',
|
||||
),
|
||||
initialValue: icons[i].name,
|
||||
onChanged: (val) {
|
||||
try {
|
||||
if (mounted)
|
||||
setState(() {
|
||||
icons[i] = icons[i].copyWith(name: val);
|
||||
});
|
||||
} catch (e) {}
|
||||
},
|
||||
),
|
||||
),
|
||||
DataCell(
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration.collapsed(
|
||||
hintText: 'Ext',
|
||||
),
|
||||
initialValue: icons[i].ext,
|
||||
onChanged: (val) {
|
||||
try {
|
||||
if (mounted)
|
||||
setState(() {
|
||||
icons[i] = icons[i].copyWith(ext: val);
|
||||
});
|
||||
} catch (e) {}
|
||||
},
|
||||
),
|
||||
DataCell(
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration.collapsed(
|
||||
hintText: 'Folder',
|
||||
),
|
||||
initialValue: icons[i].folder,
|
||||
onChanged: (val) {
|
||||
try {
|
||||
if (mounted)
|
||||
setState(() {
|
||||
icons[i] = icons[i].copyWith(folder: val);
|
||||
});
|
||||
} catch (e) {}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
DataCell(
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration.collapsed(
|
||||
hintText: 'Suffix',
|
||||
),
|
||||
initialValue: icons[i].folderSuffix,
|
||||
onChanged: (val) {
|
||||
try {
|
||||
if (mounted)
|
||||
setState(() {
|
||||
icons[i] =
|
||||
icons[i].copyWith(folderSuffix: val);
|
||||
});
|
||||
} catch (e) {}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
DataCell(
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration.collapsed(
|
||||
hintText: 'Ext',
|
||||
),
|
||||
initialValue: icons[i].ext,
|
||||
onChanged: (val) {
|
||||
try {
|
||||
if (mounted)
|
||||
setState(() {
|
||||
icons[i] = icons[i].copyWith(ext: val);
|
||||
});
|
||||
} catch (e) {}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
DataCell(
|
||||
IconButton(
|
||||
icon: Icon(Icons.delete),
|
||||
@@ -668,39 +665,31 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
onPressed: () {
|
||||
if (mounted)
|
||||
setState(() {
|
||||
if (icons is List<IosIcon>) {
|
||||
icons.add(
|
||||
IosIcon(
|
||||
size: 1024,
|
||||
scale: 1,
|
||||
),
|
||||
);
|
||||
}
|
||||
if (icons is List<WebIcon>) {
|
||||
icons.add(
|
||||
WebIcon(
|
||||
size: 192,
|
||||
),
|
||||
);
|
||||
}
|
||||
if (icons is List<MacOSIcon>) {
|
||||
icons.add(
|
||||
MacOSIcon(
|
||||
size: 512,
|
||||
scale: 2,
|
||||
name: '1024',
|
||||
),
|
||||
);
|
||||
}
|
||||
if (icons is List<AndroidIcon>) {
|
||||
icons.add(
|
||||
AndroidIcon(
|
||||
size: 192,
|
||||
folderSuffix: "xxxhdpi",
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
icons.add(
|
||||
IosIcon(
|
||||
size: 1024,
|
||||
scale: 1,
|
||||
),
|
||||
);
|
||||
icons.add(
|
||||
WebIcon(
|
||||
size: 192,
|
||||
),
|
||||
);
|
||||
icons.add(
|
||||
MacOSIcon(
|
||||
size: 512,
|
||||
scale: 2,
|
||||
name: '1024',
|
||||
),
|
||||
);
|
||||
icons.add(
|
||||
AndroidIcon(
|
||||
size: 192,
|
||||
folderSuffix: "xxxhdpi",
|
||||
),
|
||||
);
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
@@ -711,9 +700,6 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
}
|
||||
|
||||
Widget _buildFilePreview() {
|
||||
if (_files == null) {
|
||||
return Center(child: CircularProgressIndicator());
|
||||
}
|
||||
return ListView.separated(
|
||||
separatorBuilder: (context, index) => Container(
|
||||
height: 1.0,
|
||||
@@ -729,7 +715,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
children: <Widget>[
|
||||
Text(
|
||||
_key,
|
||||
style: Theme.of(context).textTheme.headline4,
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
|
||||
@@ -21,9 +21,7 @@ void _setTargetPlatformForDesktop() {
|
||||
} else if (Platform.isLinux || Platform.isWindows) {
|
||||
targetPlatform = TargetPlatform.android;
|
||||
}
|
||||
if (targetPlatform != null) {
|
||||
debugDefaultTargetPlatformOverride = targetPlatform;
|
||||
}
|
||||
debugDefaultTargetPlatformOverride = targetPlatform;
|
||||
}
|
||||
|
||||
class MyApp extends StatefulWidget {
|
||||
|
||||
@@ -77,7 +77,7 @@ class _MobilePopUpState extends State<MobilePopUp> {
|
||||
void init() {
|
||||
if (mounted)
|
||||
setState(() {
|
||||
leadingColor = widget?.leadingColor;
|
||||
leadingColor = widget.leadingColor;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -88,10 +88,10 @@ class _MobilePopUpState extends State<MobilePopUp> {
|
||||
_size.height < widget.breakpoint.height;
|
||||
final _full = _mobile || fullscreen;
|
||||
final _content = _PopUpContent(
|
||||
title: widget?.title,
|
||||
title: widget.title,
|
||||
showDoneButton: widget.showDoneButton,
|
||||
child: widget?.child,
|
||||
routes: widget?.routes,
|
||||
child: widget.child,
|
||||
routes: widget.routes,
|
||||
leadingColor: leadingColor,
|
||||
fullscreen: !widget.showFullScreen ? null : fullscreen,
|
||||
toggleFullscreen: (value) {
|
||||
@@ -155,14 +155,13 @@ class _PopUpContent extends StatelessWidget {
|
||||
)
|
||||
: null,
|
||||
actions: <Widget>[
|
||||
if (fullscreen != null)
|
||||
IconButton(
|
||||
icon:
|
||||
Icon(fullscreen ? Icons.fullscreen_exit : Icons.fullscreen),
|
||||
onPressed: () => toggleFullscreen(!fullscreen),
|
||||
)
|
||||
IconButton(
|
||||
icon:
|
||||
Icon(fullscreen ? Icons.fullscreen_exit : Icons.fullscreen),
|
||||
onPressed: () => toggleFullscreen(!fullscreen),
|
||||
)
|
||||
],
|
||||
title: title == null ? null : Text(title),
|
||||
title: Text(title),
|
||||
),
|
||||
body: child,
|
||||
),
|
||||
|
||||
@@ -23,7 +23,7 @@ Future<T> showMobilePopup<T>({
|
||||
Animation<double> secondaryAnimation) {
|
||||
final Widget pageChild = Builder(builder: builder);
|
||||
return Builder(builder: (BuildContext context) {
|
||||
return theme != null ? Theme(data: theme, child: pageChild) : pageChild;
|
||||
return Theme(data: theme, child: pageChild);
|
||||
});
|
||||
},
|
||||
barrierDismissible: barrierDismissible,
|
||||
|
||||
@@ -151,9 +151,6 @@ class FancyTitle extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (logo == null) {
|
||||
return logo;
|
||||
}
|
||||
return Row(
|
||||
children: <Widget>[
|
||||
logo,
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:auto_size_text/auto_size_text.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
class TabChild {
|
||||
final String title;
|
||||
@@ -72,15 +69,13 @@ class MobileSidebar extends StatelessWidget {
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
drawer: _showDrawer
|
||||
? drawerBuilder != null
|
||||
? drawerBuilder(context, _titles, onTabChanged)
|
||||
: _buildDrawer(context, _titles)
|
||||
? drawerBuilder(context, _titles, onTabChanged)
|
||||
: null,
|
||||
appBar: PreferredSize(
|
||||
preferredSize: Size.fromHeight(kToolbarHeight),
|
||||
child: Material(
|
||||
color: theme.appBarTheme.color,
|
||||
elevation: theme.appBarTheme?.elevation ?? 4.0,
|
||||
elevation: theme.appBarTheme.elevation ?? 4.0,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
@@ -187,8 +182,8 @@ class MobileSidebar extends StatelessWidget {
|
||||
if (showSearchButton) ...[
|
||||
_searchBuilder(context, _showDrawer),
|
||||
],
|
||||
if (ctaBuilder != null) ctaBuilder(context),
|
||||
if (accountBuilder != null) accountBuilder(context),
|
||||
ctaBuilder(context),
|
||||
accountBuilder(context),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -216,7 +211,7 @@ class MobileSidebar extends StatelessWidget {
|
||||
child: Center(
|
||||
child: AutoSizeText(
|
||||
tab,
|
||||
style: theme.textTheme.body2.copyWith(
|
||||
style: theme.textTheme.bodyLarge.copyWith(
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
@@ -227,7 +222,7 @@ class MobileSidebar extends StatelessWidget {
|
||||
height: kBarHeight,
|
||||
width: tabWidth * 2,
|
||||
color: tab == _titles[currentIndex]
|
||||
? theme.accentColor
|
||||
? theme.colorScheme.secondary
|
||||
: Colors.transparent,
|
||||
),
|
||||
],
|
||||
@@ -239,10 +234,8 @@ class MobileSidebar extends StatelessWidget {
|
||||
final kBarHeight = 3.0;
|
||||
|
||||
Widget _menuIconBuilder(BuildContext context) {
|
||||
if (menuButtonBuilder != null) {
|
||||
return menuButtonBuilder(context);
|
||||
}
|
||||
return IconButton(
|
||||
return menuButtonBuilder(context);
|
||||
return IconButton(
|
||||
icon: Icon(Icons.menu),
|
||||
onPressed: () => _scaffoldKey.currentState.openDrawer(),
|
||||
);
|
||||
@@ -250,22 +243,16 @@ class MobileSidebar extends StatelessWidget {
|
||||
|
||||
Widget _searchBuilder(BuildContext context, bool showDrawer) {
|
||||
if (showDrawer) {
|
||||
if (searchIconBuilder != null) {
|
||||
return searchIconBuilder(context);
|
||||
}
|
||||
return IconButton(
|
||||
return searchIconBuilder(context);
|
||||
return IconButton(
|
||||
icon: Icon(Icons.search),
|
||||
onPressed: () {
|
||||
if (isSearchChanged != null) {
|
||||
isSearchChanged(!isSearching);
|
||||
}
|
||||
},
|
||||
isSearchChanged(!isSearching);
|
||||
},
|
||||
);
|
||||
}
|
||||
if (searchBarBuilder != null) {
|
||||
return searchBarBuilder(context, searchChanged);
|
||||
}
|
||||
const kSearchBarWidth = 225.0;
|
||||
return searchBarBuilder(context, searchChanged);
|
||||
const kSearchBarWidth = 225.0;
|
||||
|
||||
return Container(
|
||||
width: kSearchBarWidth,
|
||||
@@ -289,10 +276,8 @@ class MobileSidebar extends StatelessWidget {
|
||||
onTap: isSearching
|
||||
? null
|
||||
: () {
|
||||
if (isSearchChanged != null) {
|
||||
isSearchChanged(!isSearching);
|
||||
}
|
||||
},
|
||||
isSearchChanged(!isSearching);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -345,10 +330,10 @@ class MobileSidebar extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
_divider,
|
||||
if (ctaBuilder != null) ...[
|
||||
ctaBuilder(context),
|
||||
_divider,
|
||||
],
|
||||
...[
|
||||
ctaBuilder(context),
|
||||
_divider,
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -10,7 +10,7 @@ class MyApp extends StatelessWidget {
|
||||
debugShowCheckedModeBanner: false,
|
||||
title: 'NavigationRail Demo',
|
||||
theme: _theme(ThemeData.light().copyWith(
|
||||
accentColor: Colors.red,
|
||||
colorScheme: ColorScheme.fromSwatch().copyWith(secondary: Colors.red),
|
||||
)),
|
||||
darkTheme: ThemeData.dark(),
|
||||
home: Directionality(
|
||||
@@ -26,7 +26,7 @@ class MyApp extends StatelessWidget {
|
||||
appBarTheme: base.appBarTheme.copyWith(elevation: 0.0),
|
||||
floatingActionButtonTheme: base.floatingActionButtonTheme.copyWith(
|
||||
elevation: 2.0,
|
||||
backgroundColor: base.accentColor,
|
||||
backgroundColor: base.colorScheme.secondary,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -96,19 +96,19 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
),
|
||||
tabs: <BottomNavigationBarItem>[
|
||||
BottomNavigationBarItem(
|
||||
title: Text("Folders"),
|
||||
label: Text("Folders"),
|
||||
icon: Icon(Icons.folder),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
title: Text("History"),
|
||||
label: Text("History"),
|
||||
icon: Icon(Icons.history),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
title: Text("Gallery"),
|
||||
label: Text("Gallery"),
|
||||
icon: Icon(Icons.photo_library),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
title: Text("Camera"),
|
||||
label: Text("Camera"),
|
||||
icon: Icon(Icons.camera),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -144,10 +144,10 @@ class NavRail extends StatelessWidget {
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
minWidth: isDense ? _denseRailSize : _railSize,
|
||||
selectedIconTheme: IconThemeData(
|
||||
color: Theme.of(context).accentColor,
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
selectedLabelTextStyle: TextStyle(
|
||||
color: Theme.of(context).accentColor,
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
unselectedIconTheme: IconThemeData(
|
||||
color: Colors.grey,
|
||||
@@ -157,7 +157,7 @@ class NavRail extends StatelessWidget {
|
||||
onDestinationSelected: (val) => onTap(val),
|
||||
destinations: tabs
|
||||
.map((e) => NavigationRailDestination(
|
||||
label: e.title,
|
||||
label: e.label,
|
||||
icon: e.icon,
|
||||
))
|
||||
.toList(),
|
||||
@@ -169,15 +169,15 @@ class NavRail extends StatelessWidget {
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
if (drawerHeaderBuilder != null) ...[
|
||||
drawerHeaderBuilder(context),
|
||||
],
|
||||
...[
|
||||
drawerHeaderBuilder(context),
|
||||
],
|
||||
if (showTabs) ...[
|
||||
Expanded(child: buildRail(context, true)),
|
||||
],
|
||||
if (drawerFooterBuilder != null) ...[
|
||||
drawerFooterBuilder(context),
|
||||
],
|
||||
...[
|
||||
drawerFooterBuilder(context),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -114,15 +114,13 @@ class MyApp extends StatelessWidget {
|
||||
""";
|
||||
|
||||
String buildCustomColors(List<CustomColor> colors) {
|
||||
if (colors != null) {
|
||||
final sb = StringBuffer();
|
||||
for (var color in colors) {
|
||||
String _name = ReCase(color.name).camelCase;
|
||||
int _value = color.color;
|
||||
sb.writeln(' static Color get $_name => const Color($_value);');
|
||||
}
|
||||
return sb.toString();
|
||||
final sb = StringBuffer();
|
||||
for (var color in colors) {
|
||||
String _name = ReCase(color.name).camelCase;
|
||||
int _value = color.color;
|
||||
sb.writeln(' static Color get $_name => const Color($_value);');
|
||||
}
|
||||
return sb.toString();
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -134,52 +132,42 @@ import 'package:flutter/material.dart';
|
||||
|
||||
bool isDark(BuildContext context) => Theme.of(context).brightness == Brightness.dark;
|
||||
|
||||
ThemeMode get themeMode => ${(project?.themeMode ?? ThemeMode.system).toString()};
|
||||
ThemeMode get themeMode => ${(project.themeMode ?? ThemeMode.system).toString()};
|
||||
|
||||
""");
|
||||
|
||||
sb.writeln(_writeProjectTheme(project?.lightTheme, 'LightTheme', true));
|
||||
sb.writeln(_writeProjectTheme(project?.darkTheme, 'DarkTheme', false));
|
||||
sb.writeln(_writeProjectTheme(project.lightTheme, 'LightTheme', true));
|
||||
sb.writeln(_writeProjectTheme(project.darkTheme, 'DarkTheme', false));
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
String _writeProjectTheme(ProjectTheme theme, String name, bool isLight) {
|
||||
if (theme == null) {
|
||||
return """
|
||||
class $name {
|
||||
$name._();
|
||||
|
||||
static ThemeData get data => ThemeData.${isLight ? 'light' : 'dark'}();
|
||||
|
||||
}
|
||||
""";
|
||||
}
|
||||
ThemeData _base = isLight ? ThemeData.light() : ThemeData.dark();
|
||||
return """
|
||||
class $name {
|
||||
$name._();
|
||||
|
||||
static ThemeData get data => ThemeData(
|
||||
brightness: ${theme?.lightBrightness ?? isLight ? 'Brightness.light' : 'Brightness.dark'},
|
||||
brightness: ${theme.lightBrightness ?? isLight ? 'Brightness.light' : 'Brightness.dark'},
|
||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||
textTheme: ThemeData.${isLight ? 'light' : 'dark'}().textTheme
|
||||
).copyWith(
|
||||
primaryColor: const Color(${_getColor(theme?.primaryColor, _base.primaryColor)}),
|
||||
accentColor: const Color(${_getColor(theme?.accentColor, _base.accentColor)}),
|
||||
primaryColor: const Color(${_getColor(theme.primaryColor, _base.primaryColor)}),
|
||||
accentColor: const Color(${_getColor(theme.accentColor, _base.colorScheme.secondary)}),
|
||||
floatingActionButtonTheme:
|
||||
ThemeData.${isLight ? 'light' : 'dark'}().floatingActionButtonTheme.copyWith(
|
||||
backgroundColor: const Color(${_getColor(theme?.floatingActionButtonBackgroundColor, _base.floatingActionButtonTheme.backgroundColor)}),
|
||||
foregroundColor: const Color(${_getColor(theme?.floatingActionButtonForegroundColor, _base.floatingActionButtonTheme.foregroundColor)}),
|
||||
backgroundColor: const Color(${_getColor(theme.floatingActionButtonBackgroundColor, _base.floatingActionButtonTheme.backgroundColor)}),
|
||||
foregroundColor: const Color(${_getColor(theme.floatingActionButtonForegroundColor, _base.floatingActionButtonTheme.foregroundColor)}),
|
||||
),
|
||||
scaffoldBackgroundColor: const Color(${_getColor(theme?.scaffoldBackgroundColor, _base.scaffoldBackgroundColor)}),
|
||||
scaffoldBackgroundColor: const Color(${_getColor(theme.scaffoldBackgroundColor, _base.scaffoldBackgroundColor)}),
|
||||
appBarTheme: ThemeData.${isLight ? 'light' : 'dark'}().appBarTheme,
|
||||
);
|
||||
|
||||
${buildCustomColors(theme?.customColors)}
|
||||
${buildCustomColors(theme.customColors)}
|
||||
}
|
||||
""";
|
||||
}
|
||||
|
||||
int _getColor(int value, Color fallback) {
|
||||
return value ?? fallback?.value ?? Colors.blue.value;
|
||||
return value ?? fallback.value ?? Colors.blue.value;
|
||||
}
|
||||
|
||||
@@ -101,10 +101,8 @@ Future _writeFilesDir(
|
||||
if (!_dir.existsSync()) {
|
||||
_dir.createSync(recursive: true);
|
||||
}
|
||||
if (file?.children != null) {
|
||||
await _writeFilesDir(file.children, path, base);
|
||||
}
|
||||
}
|
||||
await _writeFilesDir(file.children, path, base);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -166,9 +166,6 @@ class _$FlutterProjectCopyWithImpl<$Res>
|
||||
|
||||
@override
|
||||
$ProjectThemeCopyWith<$Res> get lightTheme {
|
||||
if (_value.lightTheme == null) {
|
||||
return null;
|
||||
}
|
||||
return $ProjectThemeCopyWith<$Res>(_value.lightTheme, (value) {
|
||||
return _then(_value.copyWith(lightTheme: value));
|
||||
});
|
||||
@@ -176,9 +173,6 @@ class _$FlutterProjectCopyWithImpl<$Res>
|
||||
|
||||
@override
|
||||
$ProjectThemeCopyWith<$Res> get darkTheme {
|
||||
if (_value.darkTheme == null) {
|
||||
return null;
|
||||
}
|
||||
return $ProjectThemeCopyWith<$Res>(_value.darkTheme, (value) {
|
||||
return _then(_value.copyWith(darkTheme: value));
|
||||
});
|
||||
@@ -298,16 +292,7 @@ class _$_FlutterProject
|
||||
this.themeMode,
|
||||
this.canvasZoom = 0,
|
||||
this.canvasOffsetDx = 0,
|
||||
this.canvasOffsetDy = 0})
|
||||
: assert(name != null),
|
||||
assert(org != null),
|
||||
assert(description != null),
|
||||
assert(useSwift != null),
|
||||
assert(useKotlin != null),
|
||||
assert(targets != null),
|
||||
assert(canvasZoom != null),
|
||||
assert(canvasOffsetDx != null),
|
||||
assert(canvasOffsetDy != null);
|
||||
this.canvasOffsetDy = 0});
|
||||
|
||||
factory _$_FlutterProject.fromJson(Map<String, dynamic> json) =>
|
||||
_$_$_FlutterProjectFromJson(json);
|
||||
|
||||
@@ -750,9 +750,6 @@ class _$_CustomGradient
|
||||
double endY,
|
||||
TileMode tileMode),
|
||||
}) {
|
||||
assert($default != null);
|
||||
assert(radial != null);
|
||||
assert(linear != null);
|
||||
return $default(name, colors);
|
||||
}
|
||||
|
||||
@@ -781,11 +778,8 @@ class _$_CustomGradient
|
||||
TileMode tileMode),
|
||||
@required Result orElse(),
|
||||
}) {
|
||||
assert(orElse != null);
|
||||
if ($default != null) {
|
||||
return $default(name, colors);
|
||||
}
|
||||
return orElse();
|
||||
return $default(name, colors);
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -795,9 +789,6 @@ class _$_CustomGradient
|
||||
@required Result radial(CustomRadialGradient value),
|
||||
@required Result linear(CustomLinearGradient value),
|
||||
}) {
|
||||
assert($default != null);
|
||||
assert(radial != null);
|
||||
assert(linear != null);
|
||||
return $default(this);
|
||||
}
|
||||
|
||||
@@ -809,11 +800,8 @@ class _$_CustomGradient
|
||||
Result linear(CustomLinearGradient value),
|
||||
@required Result orElse(),
|
||||
}) {
|
||||
assert(orElse != null);
|
||||
if ($default != null) {
|
||||
return $default(this);
|
||||
}
|
||||
return orElse();
|
||||
return $default(this);
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1006,9 +994,6 @@ class _$CustomRadialGradient
|
||||
double endY,
|
||||
TileMode tileMode),
|
||||
}) {
|
||||
assert($default != null);
|
||||
assert(radial != null);
|
||||
assert(linear != null);
|
||||
return radial(name, stops, colors, radius, alignX, alignY, focalX, focalY);
|
||||
}
|
||||
|
||||
@@ -1037,12 +1022,9 @@ class _$CustomRadialGradient
|
||||
TileMode tileMode),
|
||||
@required Result orElse(),
|
||||
}) {
|
||||
assert(orElse != null);
|
||||
if (radial != null) {
|
||||
return radial(
|
||||
name, stops, colors, radius, alignX, alignY, focalX, focalY);
|
||||
}
|
||||
return orElse();
|
||||
return radial(
|
||||
name, stops, colors, radius, alignX, alignY, focalX, focalY);
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1052,9 +1034,6 @@ class _$CustomRadialGradient
|
||||
@required Result radial(CustomRadialGradient value),
|
||||
@required Result linear(CustomLinearGradient value),
|
||||
}) {
|
||||
assert($default != null);
|
||||
assert(radial != null);
|
||||
assert(linear != null);
|
||||
return radial(this);
|
||||
}
|
||||
|
||||
@@ -1066,11 +1045,8 @@ class _$CustomRadialGradient
|
||||
Result linear(CustomLinearGradient value),
|
||||
@required Result orElse(),
|
||||
}) {
|
||||
assert(orElse != null);
|
||||
if (radial != null) {
|
||||
return radial(this);
|
||||
}
|
||||
return orElse();
|
||||
return radial(this);
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1288,9 +1264,6 @@ class _$CustomLinearGradient
|
||||
double endY,
|
||||
TileMode tileMode),
|
||||
}) {
|
||||
assert($default != null);
|
||||
assert(radial != null);
|
||||
assert(linear != null);
|
||||
return linear(
|
||||
name, stops, colors, radius, startX, startY, endX, endY, tileMode);
|
||||
}
|
||||
@@ -1320,12 +1293,9 @@ class _$CustomLinearGradient
|
||||
TileMode tileMode),
|
||||
@required Result orElse(),
|
||||
}) {
|
||||
assert(orElse != null);
|
||||
if (linear != null) {
|
||||
return linear(
|
||||
name, stops, colors, radius, startX, startY, endX, endY, tileMode);
|
||||
}
|
||||
return orElse();
|
||||
return linear(
|
||||
name, stops, colors, radius, startX, startY, endX, endY, tileMode);
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1335,9 +1305,6 @@ class _$CustomLinearGradient
|
||||
@required Result radial(CustomRadialGradient value),
|
||||
@required Result linear(CustomLinearGradient value),
|
||||
}) {
|
||||
assert($default != null);
|
||||
assert(radial != null);
|
||||
assert(linear != null);
|
||||
return linear(this);
|
||||
}
|
||||
|
||||
@@ -1349,11 +1316,8 @@ class _$CustomLinearGradient
|
||||
Result linear(CustomLinearGradient value),
|
||||
@required Result orElse(),
|
||||
}) {
|
||||
assert(orElse != null);
|
||||
if (linear != null) {
|
||||
return linear(this);
|
||||
}
|
||||
return orElse();
|
||||
return linear(this);
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -196,10 +196,7 @@ class _$ProjectScreen with DiagnosticableTreeMixin implements ProjectScreen {
|
||||
this.dx,
|
||||
this.dy,
|
||||
this.width,
|
||||
this.height})
|
||||
: assert(className != null),
|
||||
assert(isStateful != null),
|
||||
assert(route != null);
|
||||
this.height});
|
||||
|
||||
factory _$ProjectScreen.fromJson(Map<String, dynamic> json) =>
|
||||
_$_$ProjectScreenFromJson(json);
|
||||
|
||||
@@ -106,12 +106,8 @@ class ProjectFile extends ProjectFileBase {
|
||||
|
||||
Future<FileData> getFileData() async {
|
||||
List<int> _data;
|
||||
if (content.value != null) {
|
||||
_data = content.value;
|
||||
} else if (readAsBytes != null) {
|
||||
_data = await readAsBytes;
|
||||
}
|
||||
return FileData(
|
||||
_data = content.value;
|
||||
return FileData(
|
||||
_data,
|
||||
_data.length,
|
||||
filename,
|
||||
|
||||
@@ -74,7 +74,7 @@ class LayoutExample extends StatelessWidget {
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
child: Icon(Icons.add),
|
||||
backgroundColor: Theme.of(context).accentColor,
|
||||
backgroundColor: Theme.of(context).colorScheme.secondary,
|
||||
onPressed: () {},
|
||||
),
|
||||
);
|
||||
|
||||
@@ -53,7 +53,7 @@ class _ListExampleState extends State<ListExample> {
|
||||
title: Text("App Bar"),
|
||||
),
|
||||
],
|
||||
itemCount: _items?.length ?? 0,
|
||||
itemCount: _items.length ?? 0,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final i = _items[index];
|
||||
return ListTile(
|
||||
|
||||
@@ -22,16 +22,14 @@ void _setTargetPlatformForDesktop() {
|
||||
} else if (Platform.isLinux || Platform.isWindows) {
|
||||
targetPlatform = TargetPlatform.android;
|
||||
}
|
||||
if (targetPlatform != null) {
|
||||
debugDefaultTargetPlatformOverride = targetPlatform;
|
||||
}
|
||||
debugDefaultTargetPlatformOverride = targetPlatform;
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
theme: ThemeData.light().copyWith(accentColor: Colors.red),
|
||||
theme: ThemeData.light().copyWith(colorScheme: ColorScheme.fromSwatch().copyWith(secondary: Colors.red)),
|
||||
debugShowCheckedModeBanner: false,
|
||||
home: HomePage(),
|
||||
);
|
||||
|
||||
@@ -51,16 +51,15 @@ class DetailsView extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
if (_details?.title != null)
|
||||
Expanded(
|
||||
child: Center(child: _details.title),
|
||||
),
|
||||
Expanded(
|
||||
child: Center(child: _details.title),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: _details?.actions,
|
||||
actions: _details.actions,
|
||||
),
|
||||
body: _details.child,
|
||||
bottomNavigationBar: _details?.bottomAppBar,
|
||||
bottomNavigationBar: _details.bottomAppBar,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,9 +85,9 @@ class _ThreeColumnNavigationState extends State<ThreeColumnNavigation> {
|
||||
Container(
|
||||
width: 300,
|
||||
child: Scaffold(
|
||||
backgroundColor: widget?.backgroundColor,
|
||||
backgroundColor: widget.backgroundColor,
|
||||
appBar: AppBar(
|
||||
title: widget?.title,
|
||||
title: widget.title,
|
||||
leading: IconButton(
|
||||
icon: Icon(widget.expandedIconData),
|
||||
onPressed: () {
|
||||
@@ -111,7 +111,7 @@ class _ThreeColumnNavigationState extends State<ThreeColumnNavigation> {
|
||||
}
|
||||
},
|
||||
),
|
||||
bottomNavigationBar: widget?.bottomAppBar,
|
||||
bottomNavigationBar: widget.bottomAppBar,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
@@ -164,7 +164,7 @@ class _ThreeColumnNavigationState extends State<ThreeColumnNavigation> {
|
||||
},
|
||||
),
|
||||
bottomNavigationBar:
|
||||
widget.sections[_sectionIndex]?.bottomAppBar,
|
||||
widget.sections[_sectionIndex].bottomAppBar,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
@@ -221,7 +221,7 @@ class _ThreeColumnNavigationState extends State<ThreeColumnNavigation> {
|
||||
},
|
||||
),
|
||||
appBar: AppBar(
|
||||
title: widget.sections[_sectionIndex]?.label,
|
||||
title: widget.sections[_sectionIndex].label,
|
||||
),
|
||||
body: SectionList(
|
||||
controller: controller,
|
||||
@@ -250,7 +250,7 @@ class _ThreeColumnNavigationState extends State<ThreeColumnNavigation> {
|
||||
}
|
||||
},
|
||||
),
|
||||
bottomNavigationBar: widget.sections[_sectionIndex]?.bottomAppBar,
|
||||
bottomNavigationBar: widget.sections[_sectionIndex].bottomAppBar,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -46,16 +46,16 @@ class ResponsiveScaffold extends StatelessWidget {
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: <Widget>[
|
||||
if (drawer != null) ...[
|
||||
SizedBox(
|
||||
width: _drawerWidth,
|
||||
child: Drawer(
|
||||
child: SafeArea(
|
||||
child: drawer,
|
||||
),
|
||||
...[
|
||||
SizedBox(
|
||||
width: _drawerWidth,
|
||||
child: Drawer(
|
||||
child: SafeArea(
|
||||
child: drawer,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
Expanded(
|
||||
child: Scaffold(
|
||||
key: scaffoldKey,
|
||||
@@ -64,9 +64,9 @@ class ResponsiveScaffold extends StatelessWidget {
|
||||
automaticallyImplyLeading: false,
|
||||
title: title,
|
||||
actions: <Widget>[
|
||||
if (trailing != null) ...[
|
||||
trailing,
|
||||
],
|
||||
...[
|
||||
trailing,
|
||||
],
|
||||
],
|
||||
),
|
||||
body: Row(
|
||||
@@ -74,30 +74,30 @@ class ResponsiveScaffold extends StatelessWidget {
|
||||
Expanded(
|
||||
child: body ?? Container(),
|
||||
),
|
||||
if (endDrawer != null) ...[
|
||||
Container(
|
||||
width: _drawerWidth,
|
||||
child: Drawer(
|
||||
elevation: 3.0,
|
||||
child: SafeArea(
|
||||
child: endDrawer,
|
||||
),
|
||||
...[
|
||||
Container(
|
||||
width: _drawerWidth,
|
||||
child: Drawer(
|
||||
elevation: 3.0,
|
||||
child: SafeArea(
|
||||
child: endDrawer,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (floatingActionButton != null) ...[
|
||||
Positioned(
|
||||
top: 100.0,
|
||||
left: _drawerWidth - 30,
|
||||
child: floatingActionButton,
|
||||
)
|
||||
],
|
||||
...[
|
||||
Positioned(
|
||||
top: 100.0,
|
||||
left: _drawerWidth - 30,
|
||||
child: floatingActionButton,
|
||||
)
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -105,9 +105,7 @@ class ResponsiveScaffold extends StatelessWidget {
|
||||
if (constraints.maxWidth >= kTabletBreakpoint) {
|
||||
return Scaffold(
|
||||
key: scaffoldKey,
|
||||
drawer: drawer == null
|
||||
? null
|
||||
: Drawer(
|
||||
drawer: Drawer(
|
||||
child: SafeArea(
|
||||
child: drawer,
|
||||
),
|
||||
@@ -118,9 +116,9 @@ class ResponsiveScaffold extends StatelessWidget {
|
||||
title: title,
|
||||
leading: _MenuButton(iconData: menuIcon),
|
||||
actions: <Widget>[
|
||||
if (trailing != null) ...[
|
||||
trailing,
|
||||
],
|
||||
...[
|
||||
trailing,
|
||||
],
|
||||
],
|
||||
),
|
||||
body: SafeArea(
|
||||
@@ -133,26 +131,26 @@ class ResponsiveScaffold extends StatelessWidget {
|
||||
Expanded(
|
||||
child: body ?? Container(),
|
||||
),
|
||||
if (endDrawer != null) ...[
|
||||
Container(
|
||||
width: _drawerWidth,
|
||||
child: Drawer(
|
||||
elevation: 3.0,
|
||||
child: SafeArea(
|
||||
child: endDrawer,
|
||||
),
|
||||
...[
|
||||
Container(
|
||||
width: _drawerWidth,
|
||||
child: Drawer(
|
||||
elevation: 3.0,
|
||||
child: SafeArea(
|
||||
child: endDrawer,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
if (floatingActionButton != null) ...[
|
||||
Positioned(
|
||||
top: 10.0,
|
||||
left: 10.0,
|
||||
child: floatingActionButton,
|
||||
)
|
||||
],
|
||||
...[
|
||||
Positioned(
|
||||
top: 10.0,
|
||||
left: 10.0,
|
||||
child: floatingActionButton,
|
||||
)
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -160,16 +158,12 @@ class ResponsiveScaffold extends StatelessWidget {
|
||||
}
|
||||
return Scaffold(
|
||||
key: scaffoldKey,
|
||||
drawer: drawer == null
|
||||
? null
|
||||
: Drawer(
|
||||
drawer: Drawer(
|
||||
child: SafeArea(
|
||||
child: drawer,
|
||||
),
|
||||
),
|
||||
endDrawer: endDrawer == null
|
||||
? null
|
||||
: Drawer(
|
||||
endDrawer: Drawer(
|
||||
child: SafeArea(
|
||||
child: endDrawer,
|
||||
),
|
||||
@@ -180,12 +174,12 @@ class ResponsiveScaffold extends StatelessWidget {
|
||||
leading: _MenuButton(iconData: menuIcon),
|
||||
title: title,
|
||||
actions: <Widget>[
|
||||
if (trailing != null) ...[
|
||||
trailing,
|
||||
],
|
||||
if (endDrawer != null) ...[
|
||||
_OptionsButton(iconData: endIcon),
|
||||
]
|
||||
...[
|
||||
trailing,
|
||||
],
|
||||
...[
|
||||
_OptionsButton(iconData: endIcon),
|
||||
]
|
||||
],
|
||||
),
|
||||
body: body,
|
||||
|
||||
@@ -214,7 +214,7 @@ class ResponsiveListScaffold extends StatelessWidget {
|
||||
persistentFooterButtons: persistentFooterButtons,
|
||||
floatingActionButtonAnimator: floatingActionButtonAnimator,
|
||||
resizeToAvoidBottomInset: resizeToAvoidBottomInset,
|
||||
resizeToAvoidBottomPadding: resizeToAvoidBottomPadding,
|
||||
resizeToAvoidBottomInset: resizeToAvoidBottomPadding,
|
||||
primary: primary,
|
||||
// extendBody: extendBody,
|
||||
backgroundColor: backgroundColor,
|
||||
|
||||
@@ -69,11 +69,10 @@ class MobileView extends StatelessWidget {
|
||||
..addAll(slivers ?? [])
|
||||
..add(Builder(
|
||||
builder: (BuildContext context) {
|
||||
if (childDelagate?.estimatedChildCount == null && nullItems != null)
|
||||
if (childDelagate.estimatedChildCount == null)
|
||||
return SliverFillRemaining(child: nullItems);
|
||||
if (childDelagate?.estimatedChildCount != null &&
|
||||
childDelagate.estimatedChildCount == 0 &&
|
||||
emptyItems != null)
|
||||
if (childDelagate.estimatedChildCount != null &&
|
||||
childDelagate.estimatedChildCount == 0)
|
||||
return SliverFillRemaining(child: emptyItems);
|
||||
return SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
@@ -101,7 +100,7 @@ class MobileView extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
},
|
||||
childCount: childDelagate?.estimatedChildCount ?? 0,
|
||||
childCount: childDelagate.estimatedChildCount ?? 0,
|
||||
addAutomaticKeepAlives: false,
|
||||
addRepaintBoundaries: false,
|
||||
addSemanticIndexes: false,
|
||||
|
||||
@@ -171,40 +171,38 @@ class _TabletViewState extends State<TabletView> {
|
||||
body: Flex(
|
||||
direction: Axis.horizontal,
|
||||
children: <Widget>[
|
||||
widget?.sideMenu ?? Container(),
|
||||
widget.sideMenu ?? Container(),
|
||||
Flexible(
|
||||
flex: widget.flexListView,
|
||||
child: Scaffold(
|
||||
key: widget?.scaffoldkey,
|
||||
floatingActionButton: widget?.floatingActionButton,
|
||||
key: widget.scaffoldkey,
|
||||
floatingActionButton: widget.floatingActionButton,
|
||||
floatingActionButtonLocation:
|
||||
widget?.floatingActionButtonLocation,
|
||||
bottomNavigationBar: widget?.bottomNavigationBar,
|
||||
bottomSheet: widget?.bottomSheet,
|
||||
persistentFooterButtons: widget?.persistentFooterButtons,
|
||||
widget.floatingActionButtonLocation,
|
||||
bottomNavigationBar: widget.bottomNavigationBar,
|
||||
bottomSheet: widget.bottomSheet,
|
||||
persistentFooterButtons: widget.persistentFooterButtons,
|
||||
floatingActionButtonAnimator:
|
||||
widget?.floatingActionButtonAnimator,
|
||||
resizeToAvoidBottomInset: widget?.resizeToAvoidBottomInset,
|
||||
resizeToAvoidBottomPadding: widget?.resizeToAvoidBottomPadding,
|
||||
primary: widget?.primary,
|
||||
widget.floatingActionButtonAnimator,
|
||||
resizeToAvoidBottomInset: widget.resizeToAvoidBottomInset,
|
||||
resizeToAvoidBottomInset: widget.resizeToAvoidBottomPadding,
|
||||
primary: widget.primary,
|
||||
// extendBody: extendBody,
|
||||
backgroundColor: widget?.backgroundColor,
|
||||
drawer: widget?.drawer,
|
||||
endDrawer: widget?.endDrawer,
|
||||
appBar: widget?.appBar,
|
||||
backgroundColor: widget.backgroundColor,
|
||||
drawer: widget.drawer,
|
||||
endDrawer: widget.endDrawer,
|
||||
appBar: widget.appBar,
|
||||
body: CustomScrollView(
|
||||
slivers: <Widget>[]
|
||||
..addAll(widget.slivers ?? [])
|
||||
..add(Builder(
|
||||
builder: (BuildContext context) {
|
||||
SliverChildDelegate _childDelagate =
|
||||
widget?.childDelagate;
|
||||
if (_childDelagate?.estimatedChildCount == null &&
|
||||
widget?.nullItems != null)
|
||||
widget.childDelagate;
|
||||
if (_childDelagate.estimatedChildCount == null)
|
||||
return SliverFillRemaining(child: widget.nullItems);
|
||||
if (_childDelagate?.estimatedChildCount != null &&
|
||||
_childDelagate.estimatedChildCount == 0 &&
|
||||
widget?.emptyItems != null)
|
||||
if (_childDelagate.estimatedChildCount != null &&
|
||||
_childDelagate.estimatedChildCount == 0)
|
||||
return SliverFillRemaining(child: widget.emptyItems);
|
||||
return SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
@@ -224,7 +222,7 @@ class _TabletViewState extends State<TabletView> {
|
||||
? Theme.of(context)
|
||||
.chipTheme
|
||||
.disabledColor
|
||||
: widget?.backgroundColor,
|
||||
: widget.backgroundColor,
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: _childDelagate.build(context, index),
|
||||
@@ -233,7 +231,7 @@ class _TabletViewState extends State<TabletView> {
|
||||
),
|
||||
);
|
||||
},
|
||||
childCount: _childDelagate?.estimatedChildCount ?? 0,
|
||||
childCount: _childDelagate.estimatedChildCount ?? 0,
|
||||
addAutomaticKeepAlives: false,
|
||||
addRepaintBoundaries: false,
|
||||
addSemanticIndexes: false,
|
||||
@@ -246,12 +244,11 @@ class _TabletViewState extends State<TabletView> {
|
||||
Flexible(
|
||||
flex: widget.flexDetailView,
|
||||
child: new _DetailView(
|
||||
detailScaffoldKey: widget?.detailScaffoldKey,
|
||||
details: _index == null ||
|
||||
_index > widget.childDelagate.estimatedChildCount - 1
|
||||
detailScaffoldKey: widget.detailScaffoldKey,
|
||||
details: _index > widget.childDelagate.estimatedChildCount - 1
|
||||
? null
|
||||
: widget.detailBuilder(context, _index, true),
|
||||
itemNotSelected: widget?.itemNotSelected,
|
||||
itemNotSelected: widget.itemNotSelected,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -18,21 +18,21 @@ class MyApp extends StatelessWidget {
|
||||
screen: Screen1(),
|
||||
tab: BottomNavigationBarItem(
|
||||
icon: Icon(Icons.home),
|
||||
title: Text('Home'),
|
||||
label: Text('Home'),
|
||||
),
|
||||
),
|
||||
ScreenTab(
|
||||
screen: Screen2(),
|
||||
tab: BottomNavigationBarItem(
|
||||
icon: Icon(Icons.event),
|
||||
title: Text('Calendar'),
|
||||
label: Text('Calendar'),
|
||||
),
|
||||
),
|
||||
ScreenTab(
|
||||
screen: Screen3(),
|
||||
tab: BottomNavigationBarItem(
|
||||
icon: Icon(Icons.search),
|
||||
title: Text('Search'),
|
||||
label: Text('Search'),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -61,7 +61,7 @@ class _ScaffoldTabBarState extends State<ScaffoldTabBar> {
|
||||
_screens = widget.children;
|
||||
_currentIndex = 0;
|
||||
for (var screen in _screens) {
|
||||
_keys.add(GlobalKey<NavigatorState>(debugLabel: screen?.debugLabel));
|
||||
_keys.add(GlobalKey<NavigatorState>(debugLabel: screen.debugLabel));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,23 +98,23 @@ class _ScaffoldTabBarState extends State<ScaffoldTabBar> {
|
||||
));
|
||||
}
|
||||
return Scaffold(
|
||||
backgroundColor: widget?.backgroundColor,
|
||||
key: widget?.scaffoldKey,
|
||||
drawer: widget?.drawer,
|
||||
endDrawer: widget?.endDrawer,
|
||||
persistentFooterButtons: widget?.persistentFooterButtons,
|
||||
floatingActionButton: widget?.floatingActionButton,
|
||||
floatingActionButtonAnimator: widget?.floatingActionButtonAnimator,
|
||||
floatingActionButtonLocation: widget?.floatingActionButtonLocation,
|
||||
backgroundColor: widget.backgroundColor,
|
||||
key: widget.scaffoldKey,
|
||||
drawer: widget.drawer,
|
||||
endDrawer: widget.endDrawer,
|
||||
persistentFooterButtons: widget.persistentFooterButtons,
|
||||
floatingActionButton: widget.floatingActionButton,
|
||||
floatingActionButtonAnimator: widget.floatingActionButtonAnimator,
|
||||
floatingActionButtonLocation: widget.floatingActionButtonLocation,
|
||||
body: IndexedStack(
|
||||
index: _currentIndex,
|
||||
children: _children,
|
||||
),
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
type: widget?.bottomNavigationBarType,
|
||||
type: widget.bottomNavigationBarType,
|
||||
currentIndex: _currentIndex,
|
||||
onTap: (val) => _onTap(val, context),
|
||||
backgroundColor: widget?.bottomNavigationBarBackgroundColor ??
|
||||
backgroundColor: widget.bottomNavigationBarBackgroundColor ??
|
||||
Theme.of(context).scaffoldBackgroundColor,
|
||||
items: _screens.map((s) => s.tab).toList(),
|
||||
),
|
||||
|
||||
@@ -52,7 +52,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
),
|
||||
Text(
|
||||
'${snapshot.data}',
|
||||
style: Theme.of(context).textTheme.headline4,
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user