Skip to content

Commit

Permalink
Mob programming
Browse files Browse the repository at this point in the history
  • Loading branch information
Pante committed May 23, 2024
1 parent f0c2b05 commit 7361dfe
Show file tree
Hide file tree
Showing 14 changed files with 249 additions and 290 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.flutter.plugins;

import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import io.flutter.Log;

import io.flutter.embedding.engine.FlutterEngine;

/**
* Generated file. Do not edit.
* This file is generated by the Flutter tool based on the
* plugins that support the Android platform.
*/
@Keep
public final class GeneratedPluginRegistrant {
private static final String TAG = "GeneratedPluginRegistrant";
public static void registerWith(@NonNull FlutterEngine flutterEngine) {
try {
flutterEngine.getPlugins().add(new io.flutter.plugins.pathprovider.PathProviderPlugin());
} catch (Exception e) {
Log.e(TAG, "Error registering plugin path_provider_android, io.flutter.plugins.pathprovider.PathProviderPlugin", e);
}
}
}
2 changes: 2 additions & 0 deletions forui/example/android/local.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sdk.dir=C:\\Users\\Matthias\\AppData\\Local\\Android\\sdk
flutter.sdk=C:\\Users\\Matthias\\Documents\\flutter
14 changes: 14 additions & 0 deletions forui/example/ios/Flutter/Generated.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// This is a generated file; do not edit or check into version control.
FLUTTER_ROOT=C:\Users\Matthias\Documents\flutter
FLUTTER_APPLICATION_PATH=C:\Users\Matthias\Documents\NetBeansProjects\forui\forui\example
COCOAPODS_PARALLEL_CODE_SIGN=true
FLUTTER_TARGET=lib\main.dart
FLUTTER_BUILD_DIR=build
FLUTTER_BUILD_NAME=1.0.0
FLUTTER_BUILD_NUMBER=1
EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386
EXCLUDED_ARCHS[sdk=iphoneos*]=armv7
DART_OBFUSCATION=false
TRACK_WIDGET_CREATION=true
TREE_SHAKE_ICONS=false
PACKAGE_CONFIG=.dart_tool/package_config.json
13 changes: 13 additions & 0 deletions forui/example/ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=C:\Users\Matthias\Documents\flutter"
export "FLUTTER_APPLICATION_PATH=C:\Users\Matthias\Documents\NetBeansProjects\forui\forui\example"
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
export "FLUTTER_TARGET=lib\main.dart"
export "FLUTTER_BUILD_DIR=build"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=true"
export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=.dart_tool/package_config.json"
19 changes: 19 additions & 0 deletions forui/example/ios/Runner/GeneratedPluginRegistrant.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// Generated file. Do not edit.
//

// clang-format off

#ifndef GeneratedPluginRegistrant_h
#define GeneratedPluginRegistrant_h

#import <Flutter/Flutter.h>

NS_ASSUME_NONNULL_BEGIN

@interface GeneratedPluginRegistrant : NSObject
+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry;
@end

NS_ASSUME_NONNULL_END
#endif /* GeneratedPluginRegistrant_h */
21 changes: 21 additions & 0 deletions forui/example/ios/Runner/GeneratedPluginRegistrant.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// Generated file. Do not edit.
//

// clang-format off

#import "GeneratedPluginRegistrant.h"

#if __has_include(<path_provider_foundation/PathProviderPlugin.h>)
#import <path_provider_foundation/PathProviderPlugin.h>
#else
@import path_provider_foundation;
#endif

@implementation GeneratedPluginRegistrant

+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry {
[PathProviderPlugin registerWithRegistrar:[registry registrarForPlugin:@"PathProviderPlugin"]];
}

@end
4 changes: 2 additions & 2 deletions forui/lib/forui.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export 'src/widgets/box/box.dart';
export 'src/widgets/button/tappable.dart';
export 'src/widgets/button/button.dart';
export 'src/widgets/button/link_button.dart';
export 'src/widgets/button/button_style.dart';
export 'src/widgets/button/button_styles.dart';
export 'src/widgets/button/button_content_style.dart';
export 'src/widgets/button/button_type_style.dart';
export 'src/widgets/button/button_style.dart';
export 'src/widgets/card/card.dart';
2 changes: 1 addition & 1 deletion forui/lib/src/theme/widget_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class FWidgetData {
final FBoxStyle box;

/// The button style.
final FButtonStyle button;
final FButtonStyles button;

/// The card style.
final FCardStyle card;
Expand Down
74 changes: 29 additions & 45 deletions forui/lib/src/widgets/button/button.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import 'package:flutter/material.dart';

import 'package:forui/forui.dart';
import 'package:forui/src/widgets/button/button_content.dart';

/// A [FButtonType] represents the possible states that a [FButton] can be in.
enum FButtonType {
import 'button_content.dart';


sealed class FButtonDesign {}

/// A [FButtonVariant] represents the possible states that a [FButton] can be in.
enum FButtonVariant implements FButtonDesign {
/// a primary button
primary,

Expand All @@ -20,8 +24,6 @@ enum FButtonType {

/// Represents a button widget.
class FButton extends StatelessWidget {
/// The type of button.
final FButtonType type;

/// Called when the FButton is tapped or otherwise activated.
final VoidCallback? onPressed;
Expand All @@ -30,63 +32,45 @@ class FButton extends StatelessWidget {
final Widget child;

/// The style.
final FButtonStyle? style;
final FButtonDesign style;

/// Creates a [FButton] widget.
FButton({
required this.type,
required this.style,
required this.onPressed,
String? text,
String? icon,
this.style,
super.key,
}) : child = FButtonContent(text: text, icon: icon, style: style?.content);
}) : child = FButtonContent(text: text, icon: icon, style: style, disabled: onPressed == null);

/// Creates a [FButton].
const FButton.raw({required this.type, required this.onPressed, required this.child, this.style, super.key});
const FButton.raw({required this.onPressed, required this.child, required this.style, super.key});

@override
Widget build(BuildContext context) {
final style = this.style ?? FTheme.of(context).widgets.button;

switch (type) {
case FButtonType.primary:
return _Button(onPressed: onPressed, style: style, type: style.primary, child: child);
case FButtonType.secondary:
return _Button(onPressed: onPressed, style: style, type: style.secondary, child: child);
case FButtonType.destructive:
return _Button(onPressed: onPressed, style: style, type: style.destructive, child: child);
case FButtonType.outlined:
return _Button(onPressed: onPressed, style: style, type: style.outlined, child: child);
}
}
}

class _Button extends StatelessWidget {
final FButtonStyle style;
final FButtonTypeStyle type;
final Widget child;
final VoidCallback? onPressed;

const _Button({
required this.style,
required this.type,
required this.onPressed,
required this.child,
super.key,
});

@override
Widget build(BuildContext context) => FTappable(
final buttonStyles = FTheme.of(context).widgets.button;

// TODO: Move into a method in the Style
final style = switch (this.style) {
final FButtonStyle style => style,
FButtonVariant.primary => buttonStyles.primary,
FButtonVariant.secondary => buttonStyles.secondary,
FButtonVariant.destructive => buttonStyles.destructive,
FButtonVariant.outlined => buttonStyles.outlined,
};

return FTappable(
onPressed: onPressed,
child: Container(
child: DecoratedBox(
decoration: BoxDecoration(
border: Border.all(color: type.border),
border: Border.all(color: onPressed == null ? style.border : style.disabled),
borderRadius: style.borderRadius,
color: type.background,
color: style.background,
),
padding: style.padding,
child: child,
),
);
}


}
33 changes: 18 additions & 15 deletions forui/lib/src/widgets/button/button_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class FButtonContent extends StatelessWidget {
final Widget? child;

/// The style.
final FButtonContentStyle? style;
final FButtonStyle? style;

/// Creates a [FButtonContent].
const FButtonContent({
Expand All @@ -26,19 +26,22 @@ final class FButtonContent extends StatelessWidget {

@override
Widget build(BuildContext context) {
final style = this.style ?? FTheme.of(context).widgets.button.content;

return Row(mainAxisAlignment: MainAxisAlignment.center, children: [
// [SvgTheme] provides a default color that overrides material's ButtonStyle foregroundColor
// This is a workaround, the color of the icon is set here instead of the ButtonStyle.
//if (icon != null) ...[icon(height: 20, color: style.color), const SizedBox(width: 10)],
if (text != null)
Flexible(
child: Text(text!,
//TODO: How do I make this specific to Button Type
style: style.text)),

if (child != null) child!
]);
final style = this.style ?? FTheme.of(context).widgets.button.primary.content;

return Padding(
padding: style.padding,
child: Row(mainAxisAlignment: MainAxisAlignment.center, children: [
// [SvgTheme] provides a default color that overrides material's ButtonStyle foregroundColor
// This is a workaround, the color of the icon is set here instead of the ButtonStyle.
//if (icon != null) ...[icon(height: 20, color: style.color), const SizedBox(width: 10)],
if (text != null)
Flexible(
child: Text(text!,
//TODO: How do I make this specific to Button Type
style: style.text)),

if (child != null) child!
]),
);
}
}
17 changes: 14 additions & 3 deletions forui/lib/src/widgets/button/button_content_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,31 @@ class FButtonContentStyle {
/// The title.
final TextStyle text;

/// The padding.
final EdgeInsets padding;

/// Creates a [FButtonContentStyle].
const FButtonContentStyle({
required this.text,
required this.padding,
});

/// Creates a [FButtonContentStyle] that inherits its properties from [style] and [font].
FButtonContentStyle.inherit({required FStyleData style, required FFontData font})
: text = ScaledTextStyle(
FButtonContentStyle.inherit({required FStyleData style, required FFontData font, required Color color})
:
padding = const EdgeInsets.symmetric(
horizontal: 5,
vertical: 17,
),
text = ScaledTextStyle(
TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
//TODO: How do I make this specific to Button Type
color: style.primaryForeground,
color: color,
),
font,
);


}
Loading

0 comments on commit 7361dfe

Please sign in to comment.