Skip to content

Commit

Permalink
Bug Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
iampawan committed Apr 19, 2021
1 parent 04d2cc4 commit 1bc8601
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
- New Preview Widget - VxPreview
- New Drawers - VxDrawer
- Added cursor and other props to VxTextField
- Bug Fixes for VxTextField
- Breaking - Desktop support added for VxPlatform
- Minor Bug Fixes
- Examples updated

Expand Down
9 changes: 8 additions & 1 deletion example/lib/widgets/platform_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:velocity_x/velocity_x.dart';

class PlatformBar
extends VxPlatform<AppBar, CupertinoNavigationBar, BottomAppBar> {
extends VxPlatform<AppBar, CupertinoNavigationBar, BottomAppBar, AppBar> {
@override
AppBar createAndroidWidget(BuildContext context) {
return AppBar(
Expand Down Expand Up @@ -35,4 +35,11 @@ class PlatformBar
),
);
}

@override
AppBar createDesktopWidget(BuildContext context) {
return AppBar(
title: "Hello World".text.make(),
);
}
}
22 changes: 16 additions & 6 deletions lib/src/flutter/platforms.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:flutter/material.dart';

/// Sample
///
/// class PlatformAppBar extends VxPlatform<AppBar, CupertinoNavigationBar, AppBar> {
/// class PlatformAppBar extends VxPlatform<AppBar, CupertinoNavigationBar, AppBar, AppBar> {
/// final Widget title;
/// final Widget leading;
/// PlatformAppBar({
Expand All @@ -14,26 +14,31 @@ import 'package:flutter/material.dart';
///
/// @override
/// CupertinoNavigationBar createIosWidget(BuildContext context) =>
/// new CupertinoNavigationBar(
/// CupertinoNavigationBar(
/// leading: leading,
/// middle: title,
/// );
///
/// @override
/// AppBar createAndroidWidget(BuildContext context) => new AppBar(
/// AppBar createAndroidWidget(BuildContext context) => AppBar(
/// leading: leading,
/// title: title,
/// );
/// @override
/// AppBar createWebWidget(BuildContext context) => new AppBar(
/// AppBar createWebWidget(BuildContext context) => AppBar(
/// leading: leading,
/// title: title,
/// );
/// @override
/// AppBar createDesktopWidget(BuildContext context) => AppBar(
/// leading: leading,
/// title: title,
/// );
///}
///
abstract class VxPlatform<A extends Widget, I extends Widget, W extends Widget>
extends StatelessWidget {
abstract class VxPlatform<A extends Widget, I extends Widget, W extends Widget,
D extends Widget> extends StatelessWidget {
@override
Widget build(BuildContext context) {
if (kIsWeb) {
Expand All @@ -42,6 +47,10 @@ abstract class VxPlatform<A extends Widget, I extends Widget, W extends Widget>
return createAndroidWidget(context);
} else if (defaultTargetPlatform == TargetPlatform.iOS) {
return createIosWidget(context);
} else if (defaultTargetPlatform == TargetPlatform.macOS ||
defaultTargetPlatform == TargetPlatform.linux ||
defaultTargetPlatform == TargetPlatform.windows) {
return createDesktopWidget(context);
}
// platform not supported returns an empty widget
return const Offstage();
Expand All @@ -50,4 +59,5 @@ abstract class VxPlatform<A extends Widget, I extends Widget, W extends Widget>
A createAndroidWidget(BuildContext context);
I createIosWidget(BuildContext context);
W createWebWidget(BuildContext context);
D createDesktopWidget(BuildContext context);
}
4 changes: 2 additions & 2 deletions lib/src/flutter/textfield.dart
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,15 @@ class _VxTextFieldState extends State<VxTextField> {

/// After the completion of editing
void onEditingComplete() {
// FocusScope.of(context).unfocus();
FocusScope.of(context).unfocus();
if (widget.onEditingComplete != null) {
widget.onEditingComplete!();
}
}

/// After submitting the textfield
void onSubmitted(String value) {
// FocusScope.of(context).unfocus();
FocusScope.of(context).unfocus();
if (widget.onSubmitted != null) {
widget.onSubmitted!(value);
}
Expand Down

0 comments on commit 1bc8601

Please sign in to comment.