Skip to content

Commit

Permalink
🎉 feat: 2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
SaltyAom committed Jul 4, 2023
1 parent f970c39 commit 6e86481
Show file tree
Hide file tree
Showing 35 changed files with 1,612 additions and 625 deletions.
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
# [2.4.0] - 2023/07/4
Feature:
- Migrate update to Material 3 (Flutter 3.10)
- New Widget for Material 3:
- ActionChip
- SwitchListTile
- Add factory method for Material 3:
- IconButton
- outlined
- tonal
- filled
- Button
- outlined
- tonal
- filled
- New TextFormField property:
- contextMenuBuilder
- magnifierConfiguration
- spellCheckConfiguration
- New parent builder:
- badge

Bug Fix:
- Memory leak in `useTransition`

Fix:
- Deprecated text factory of h1-h6, subtitle, headline, overline, button

# [2.3.3] - 2022/08/31
Feature:
- Support Flutter 3.3
Expand Down
5 changes: 4 additions & 1 deletion example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -171,10 +171,12 @@
/* Begin PBXShellScriptBuildPhase section */
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
Expand All @@ -185,6 +187,7 @@
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down
4 changes: 4 additions & 0 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,9 @@
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>FLTEnableImpeller</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>
48 changes: 48 additions & 0 deletions example/lib/benchmark/animation.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:niku/namespace.dart' as n;

class AnimationPressure extends HookWidget {
const AnimationPressure({Key? key}) : super(key: key);

static const duration = Duration(milliseconds: 133);
static const total = 1;

@override
build(context) {
final start = useState(false);

useEffect(() {
Timer.periodic(duration, (timer) {
start.value = !start.value;
});

return null;
}, []);

return Scaffold(
body: n.GridView.count()
..count = 12 // CrossAxisCount
..ratio = 1
..children = List.generate(
288,
(index) => n.Box()
..key = Key(index.toString())
..useTransition<Color>(
value: start.value ? Colors.red : Colors.blue,
duration: duration,
builder: (child, value) => child..bg = value,
)
..useTransition<double>(
value: start.value ? 0 : 4,
duration: duration,
builder: (child, value) => child..rotate = value,
),
)
..mainAxisSpacing = 4
..crossAxisSpacing = 4,
);
}
}
1 change: 1 addition & 0 deletions example/lib/benchmark/benchmark.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export '1000List.dart';
export 'animated.dart';
export 'widget_creation.dart';
export 'animation.dart';
4 changes: 1 addition & 3 deletions example/lib/counter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ class Counter extends HookWidget {

return Scaffold(
body: n.Column([
n.Text(count.value.toString())
..center
..h4,
n.Text(count.value.toString())..center,
n.Column([
n.Button(n.Text("Increment"))
..onPressed = () {
Expand Down
4 changes: 4 additions & 0 deletions example/lib/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export 'japan.dart';
export 'music.dart';
export 'progress.dart';
export 'stylesheet.dart';
export 'material3.dart';

export 'benchmark/1000List.dart';
export 'benchmark/widget_creation.dart';
Expand All @@ -16,3 +17,6 @@ export 'benchmark/animated.dart';
export 'version/2.1/g11.dart';
export 'version/2.2/aegle.dart';
export 'version/2.3/tempestissimo.dart';
export 'version/2.4/yorugao.dart';

export 'benchmark/benchmark.dart';
6 changes: 1 addition & 5 deletions example/lib/general.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ class General extends HookWidget {
).niku
..theme = ThemeData(highlightColor: Colors.transparent),
body: n.Column([
n.Text("Awesome Niku")
..h4
..mb = 24,
n.Text("Awesome Niku")..mb = 24,
n.TextFormField()
..labelText = "Value"
..usePrefixStyle((v) => v..color = Colors.white)
Expand Down Expand Up @@ -151,7 +149,6 @@ class NetworkImageExample extends StatelessWidget {
]
..mx = 20,
n.Text("Network Image")
..h6
..useDarkMode(
context,
(v, isDarkTheme) =>
Expand Down Expand Up @@ -198,7 +195,6 @@ class Freezed extends HookWidget {
..mb = 16
..deps = [freezed.value],
n.Text("${option.value}")
..h6
..bold
..useScreen(
context,
Expand Down
6 changes: 4 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ class MyApp extends StatelessWidget {
const MyApp();

build(context) {
// return Material3App();

return MaterialApp(
title: "Niku",
debugShowCheckedModeBanner: false,
theme: ThemeData(
primaryColor: Colors.blue,
primarySwatch: Colors.blue,
useMaterial3: true,
// splashFactory: InkSparkle.splashFactory,
),
darkTheme: ThemeData.dark(),
home: Tempestissimo(),
home: Yorugao(),
);
}
}
51 changes: 45 additions & 6 deletions example/lib/material3.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ class Material3App extends StatelessWidget {
theme: ThemeData(
useMaterial3: true,
colorSchemeSeed: Colors.green,
splashFactory: InkSparkle.splashFactory,
// splashFactory: InkSparkle.splashFactory,
),
darkTheme: ThemeData(
useMaterial3: true,
colorSchemeSeed: Colors.green,
brightness: Brightness.dark,
splashFactory: InkSparkle.splashFactory,
// splashFactory: InkSparkle.splashFactory,
),
home: const Material3Page(),
);
Expand Down Expand Up @@ -100,19 +100,22 @@ class M3HomePage extends StatelessWidget {
}
}

class M3Widgets extends StatelessWidget {
class M3Widgets extends HookWidget {
const M3Widgets({Key? key}) : super(key: key);

@override
build(context) {
final sliderValue = useState(50.0);
final switchValue = useState(false);

pop() {
Navigator.of(context).pop();
}

showAlert() {
n.showDialog(
context: context,
builder: (context) => n.Alert.adaptive(
builder: (context) => n.Alert(
title: "Alert".n,
content: "This is an alert".n,
actions: [
Expand All @@ -127,10 +130,46 @@ class M3Widgets extends StatelessWidget {
}

return n.Column([
n.Button("Show Alert".n)..onPressed = showAlert,
n.Slider(sliderValue.value)
..max = 100
..onChanged = (value) {
sliderValue.value = value;
},
n.Switch()
..value = switchValue.value
..onChanged = (value) {
switchValue.value = value;
},
n.Button.tonal("Show Alert".n)..onPressed = showAlert,
n.Row([
n.Button.tonal("Show date picker".n)
..onPressed = () {
showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime(2007),
lastDate: DateTime(2025),
);
},
n.Button.tonal("Show time picker".n)
..onPressed = () {
showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
);
}
])
..center
..gap = 16
..mt = 8,
n.TextFormField.label("Form")
..isFilled
..textInputAction = TextInputAction.done
])
..center
..wFull;
..wFull
..gap = 8
..px = 16;
}
}

Expand Down
5 changes: 1 addition & 4 deletions example/lib/music.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@ class Styles {
..splashColor = Colors.transparent;

static final icon = subIcon.copied
..apply = subIcon
..iconSize = 48
..color = Colors.grey.shade100;

static final sideIcon = subIcon.copied
..apply = subIcon
..iconSize = 24;
static final sideIcon = subIcon.copied..iconSize = 24;
}

class Music extends HookWidget {
Expand Down
3 changes: 1 addition & 2 deletions example/lib/version/2.2/aegle.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:example/progress.dart';
import 'package:niku/niku.dart';
import 'package:niku/namespace.dart' as n;

Expand Down Expand Up @@ -27,7 +26,7 @@ class AegleSeeker extends HookWidget {
],
),
body: n.Column([
n.Text("AegleSeeker")..h4,
n.Text("AegleSeeker")..displayMedium,
n.Button(Text("Toggle"))
..onPressed = () {
toggle.value = !toggle.value;
Expand Down
5 changes: 4 additions & 1 deletion example/lib/version/2.3/tempestissimo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class Tempestissimo extends HookWidget {
final page = useState(0);

return Scaffold(
appBar: AppBar(
title: "Hi".n,
),
bottomNavigationBar: NavigationBar(
onDestinationSelected: (int index) {
page.value = index;
Expand Down Expand Up @@ -96,7 +99,7 @@ class Tempestissimo extends HookWidget {
..wMax = 450,
"Rich Text: ".n.rich
..useSpan((w) => w
..text = "Span"
..text = "Span "
..color = Colors.black
..children = [
"with ".n.span,
Expand Down
48 changes: 48 additions & 0 deletions example/lib/version/2.4/yorugao.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:niku/niku.dart';
import 'package:niku/namespace.dart' as n;

class Yorugao extends HookWidget {
const Yorugao({Key? key}) : super(key: key);

@override
build(context) {
final listTile = useState(false);

return Scaffold(
body: n.Column([
n.Row([
n.Button.tonal("Tonal Button".n)..onPressed = () {},
n.Button.filled("Filled Button".n)..onPressed = () {},
])
..center
..gap = 8,
n.Row([
n.IconButton.outlined(Icons.nightlight)..onPressed = () {},
n.IconButton.tonal(Icons.nightlight)..onPressed = () {},
n.IconButton.filled(Icons.nightlight)..onPressed = () {},
])
..center
..gap = 8,
n.ActionChip.icon(Icons.question_answer, "Hello".n)
..onPressed = () {}
..fontSize = 16
..n.badge = "",
n.SwitchListTile(listTile.value)
..title = "Switch List Tile".n
..useThumbIcon(
base: Icon(Icons.sunny),
selected: Icon(Icons.nightlight),
)
..onChanged = (value) {
listTile.value = value;
},
])
..gap = 8
..center
..fullSize
..safeArea,
);
}
}
Loading

0 comments on commit 6e86481

Please sign in to comment.