refactor: Widget file structure and MVC user bottom sheet
This commit is contained in:
parent
2e8c11fd76
commit
c1e2ef25a2
27 changed files with 268 additions and 264 deletions
14
lib/views/widgets/layouts/loading_view.dart
Normal file
14
lib/views/widgets/layouts/loading_view.dart
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import 'package:adaptive_page_layout/adaptive_page_layout.dart';
|
||||
import 'package:fluffychat/views/widgets/matrix.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LoadingView extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (Matrix.of(context).loginState != null) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) =>
|
||||
AdaptivePageLayout.of(context).pushNamedAndRemoveAllOthers('/'));
|
||||
}
|
||||
return Scaffold(body: Center(child: CircularProgressIndicator()));
|
||||
}
|
||||
}
|
||||
36
lib/views/widgets/layouts/lock_screen.dart
Normal file
36
lib/views/widgets/layouts/lock_screen.dart
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import 'package:fluffychat/config/setting_keys.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_app_lock/flutter_app_lock.dart';
|
||||
import 'package:flutter_screen_lock/functions.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
|
||||
class LockScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final applock = FlutterSecureStorage().read(key: SettingKeys.appLockKey);
|
||||
return FutureBuilder<String>(
|
||||
future: applock,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasError) {
|
||||
return Scaffold(body: Center(child: Text(snapshot.error.toString())));
|
||||
}
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (snapshot.data?.isNotEmpty ?? false) {
|
||||
screenLock(
|
||||
context: context,
|
||||
correctString: snapshot.data,
|
||||
didConfirmed: (_) => AppLock.of(context).didUnlock(),
|
||||
canCancel: false,
|
||||
);
|
||||
} else {
|
||||
AppLock.of(context).didUnlock();
|
||||
AppLock.of(context).disable();
|
||||
}
|
||||
});
|
||||
}
|
||||
return Scaffold(body: Center(child: CircularProgressIndicator()));
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
38
lib/views/widgets/layouts/max_width_body.dart
Normal file
38
lib/views/widgets/layouts/max_width_body.dart
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MaxWidthBody extends StatelessWidget {
|
||||
final Widget child;
|
||||
final double maxWidth;
|
||||
final bool withScrolling;
|
||||
|
||||
const MaxWidthBody({
|
||||
this.child,
|
||||
this.maxWidth = 600,
|
||||
this.withScrolling = false,
|
||||
Key key,
|
||||
}) : super(key: key);
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final padding = EdgeInsets.symmetric(
|
||||
horizontal: max(0, (constraints.maxWidth - maxWidth) / 2),
|
||||
);
|
||||
return withScrolling
|
||||
? SingleChildScrollView(
|
||||
physics: ScrollPhysics(),
|
||||
child: Padding(
|
||||
padding: padding,
|
||||
child: child,
|
||||
),
|
||||
)
|
||||
: Padding(
|
||||
padding: padding,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
43
lib/views/widgets/layouts/one_page_card.dart
Normal file
43
lib/views/widgets/layouts/one_page_card.dart
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class OnePageCard extends StatelessWidget {
|
||||
final Widget child;
|
||||
|
||||
const OnePageCard({Key key, this.child}) : super(key: key);
|
||||
|
||||
static const int alpha = 64;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MediaQuery.of(context).size.width <= 600
|
||||
? child
|
||||
: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).backgroundColor,
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topRight,
|
||||
end: Alignment.bottomLeft,
|
||||
stops: [
|
||||
0.1,
|
||||
0.4,
|
||||
0.6,
|
||||
0.9,
|
||||
],
|
||||
colors: [
|
||||
Theme.of(context).secondaryHeaderColor.withAlpha(alpha),
|
||||
Theme.of(context).primaryColor.withAlpha(alpha),
|
||||
Theme.of(context).accentColor.withAlpha(alpha),
|
||||
Theme.of(context).backgroundColor.withAlpha(alpha),
|
||||
],
|
||||
),
|
||||
),
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal:
|
||||
max((MediaQuery.of(context).size.width - 600) / 2, 12),
|
||||
vertical: max((MediaQuery.of(context).size.height - 800) / 2, 12),
|
||||
),
|
||||
child: SafeArea(child: Card(child: child)),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue