浏览代码

update demo

/add_hero_sample
guanghuispark 3 年前
当前提交
e702d769
共有 7 个文件被更改,包括 454 次插入275 次删除
  1. 430
      AwesomeUIWidgets/Assets/Scenes/ItemPickerRoom.unity
  2. 16
      AwesomeUIWidgets/Assets/Scripts/ChatPage.cs
  3. 2
      AwesomeUIWidgets/Assets/Scripts/ChatPanelDemo.cs
  4. 57
      AwesomeUIWidgets/Assets/Scripts/DateAndTimePicker.cs
  5. 2
      AwesomeUIWidgets/Assets/Scripts/Widgets/chat_list.cs
  6. 219
      AwesomeUIWidgets/Assets/Scripts/Widgets/ModalPage.cs
  7. 3
      AwesomeUIWidgets/Assets/Scripts/Widgets/ModalPage.cs.meta

430
AwesomeUIWidgets/Assets/Scenes/ItemPickerRoom.unity


type: 3}
m_PrefabInstance: {fileID: 1244095385}
m_PrefabAsset: {fileID: 0}
--- !u!28 &544363727
Texture2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
serializedVersion: 3
m_Width: 0
m_Height: 0
m_CompleteImageSize: 0
m_TextureFormat: 0
m_MipCount: 1
m_IsReadable: 1
m_IgnoreMasterTextureLimit: 0
m_IsPreProcessed: 0
m_StreamingMipmaps: 0
m_StreamingMipmapsPriority: 0
m_AlphaIsTransparency: 0
m_ImageCount: 0
m_TextureDimension: 2
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 1
m_MipBias: 0
m_WrapU: 0
m_WrapV: 0
m_WrapW: 0
m_LightmapFormat: 0
m_ColorSpace: 0
image data: 0
_typelessdata:
m_StreamData:
offset: 0
size: 0
path:
m_OriginalWidth: 0
m_OriginalHeight: 0
m_OriginalAssetGuid: 00000000000000000000000000000000
--- !u!1 &594228147
GameObject:
m_ObjectHideFlags: 0

m_RemovedComponents:
- {fileID: 0}
m_SourcePrefab: {fileID: 100100000, guid: feb1c8e8731ab144db5ae64311c1aca2, type: 3}
--- !u!28 &606780298
Texture2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
serializedVersion: 3
m_Width: 0
m_Height: 0
m_CompleteImageSize: 0
m_TextureFormat: 0
m_MipCount: 1
m_IsReadable: 1
m_IgnoreMasterTextureLimit: 0
m_IsPreProcessed: 0
m_StreamingMipmaps: 0
m_StreamingMipmapsPriority: 0
m_AlphaIsTransparency: 0
m_ImageCount: 0
m_TextureDimension: 2
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 1
m_MipBias: 0
m_WrapU: 0
m_WrapV: 0
m_WrapW: 0
m_LightmapFormat: 0
m_ColorSpace: 0
image data: 0
_typelessdata:
m_StreamData:
offset: 0
size: 0
path:
m_OriginalWidth: 0
m_OriginalHeight: 0
m_OriginalAssetGuid: 00000000000000000000000000000000
--- !u!1 &610691281
GameObject:
m_ObjectHideFlags: 0

m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 665285921}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &734635071
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 734635072}
m_Layer: 0
m_Name: HeroSample
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &734635072
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 734635071}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -5.249773, y: 1.67, z: -6.3247466}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1823135202}
- {fileID: 1782648278}
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!28 &763194717
--- !u!28 &725679248
Texture2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}

m_OriginalWidth: 0
m_OriginalHeight: 0
m_OriginalAssetGuid: 00000000000000000000000000000000
--- !u!1 &734635071
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 734635072}
m_Layer: 0
m_Name: HeroSample
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &734635072
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 734635071}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -5.249773, y: 1.67, z: -6.3247466}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1823135202}
- {fileID: 1782648278}
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &854782982
PrefabInstance:
m_ObjectHideFlags: 0

m_Father: {fileID: 1796503313}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!28 &1082279027
Texture2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
serializedVersion: 3
m_Width: 0
m_Height: 0
m_CompleteImageSize: 0
m_TextureFormat: 0
m_MipCount: 1
m_IsReadable: 1
m_IgnoreMasterTextureLimit: 0
m_IsPreProcessed: 0
m_StreamingMipmaps: 0
m_StreamingMipmapsPriority: 0
m_AlphaIsTransparency: 0
m_ImageCount: 0
m_TextureDimension: 2
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 1
m_MipBias: 0
m_WrapU: 0
m_WrapV: 0
m_WrapW: 0
m_LightmapFormat: 0
m_ColorSpace: 0
image data: 0
_typelessdata:
m_StreamData:
offset: 0
size: 0
path:
m_OriginalWidth: 0
m_OriginalHeight: 0
m_OriginalAssetGuid: 00000000000000000000000000000000
--- !u!1 &1090877298
GameObject:
m_ObjectHideFlags: 0

m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!4 &1475640689
Transform:
m_ObjectHideFlags: 0

m_GameObject: {fileID: 1475640688}
m_LocalRotation: {x: -0, y: 0.0030212402, z: -0, w: 0.99999547}
m_LocalPosition: {x: 130.00003, y: 370, z: 7.000017}
m_LocalScale: {x: 522.91724, y: 7.8, z: 6.6185}
m_LocalPosition: {x: 130.00003, y: 413, z: 7.000017}
m_LocalScale: {x: 489.90546, y: 7.8, z: 6.6185}
m_Children: []
m_Father: {fileID: 8481369894466841862}
m_RootOrder: 3

m_Father: {fileID: 1227377083}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!28 &1518545889
Texture2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
serializedVersion: 3
m_Width: 0
m_Height: 0
m_CompleteImageSize: 0
m_TextureFormat: 0
m_MipCount: 1
m_IsReadable: 1
m_IgnoreMasterTextureLimit: 0
m_IsPreProcessed: 0
m_StreamingMipmaps: 0
m_StreamingMipmapsPriority: 0
m_AlphaIsTransparency: 0
m_ImageCount: 0
m_TextureDimension: 2
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 1
m_MipBias: 0
m_WrapU: 0
m_WrapV: 0
m_WrapW: 0
m_LightmapFormat: 0
m_ColorSpace: 0
image data: 0
_typelessdata:
m_StreamData:
offset: 0
size: 0
path:
m_OriginalWidth: 0
m_OriginalHeight: 0
m_OriginalAssetGuid: 00000000000000000000000000000000
--- !u!1 &1533300970
GameObject:
m_ObjectHideFlags: 0

m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Texture: {fileID: 1774590301}
m_Texture: {fileID: 725679248}
m_UVRect:
serializedVersion: 2
x: 0

objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 20b83b6c7039f5d47beac9ffafe09d6e, type: 3}
--- !u!28 &1613909088
Texture2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
serializedVersion: 3
m_Width: 0
m_Height: 0
m_CompleteImageSize: 0
m_TextureFormat: 0
m_MipCount: 1
m_IsReadable: 1
m_IgnoreMasterTextureLimit: 0
m_IsPreProcessed: 0
m_StreamingMipmaps: 0
m_StreamingMipmapsPriority: 0
m_AlphaIsTransparency: 0
m_ImageCount: 0
m_TextureDimension: 2
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 1
m_MipBias: 0
m_WrapU: 0
m_WrapV: 0
m_WrapW: 0
m_LightmapFormat: 0
m_ColorSpace: 0
image data: 0
_typelessdata:
m_StreamData:
offset: 0
size: 0
path:
m_OriginalWidth: 0
m_OriginalHeight: 0
m_OriginalAssetGuid: 00000000000000000000000000000000
--- !u!1 &1617165399
GameObject:
m_ObjectHideFlags: 0

m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Texture: {fileID: 544363727}
m_Texture: {fileID: 0}
m_UVRect:
serializedVersion: 2
x: 0

m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Texture: {fileID: 1613909088}
m_Texture: {fileID: 1082279027}
m_UVRect:
serializedVersion: 2
x: 0

m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1756476043}
m_CullTransparentMesh: 0
--- !u!28 &1774590301
Texture2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
serializedVersion: 3
m_Width: 0
m_Height: 0
m_CompleteImageSize: 0
m_TextureFormat: 0
m_MipCount: 1
m_IsReadable: 1
m_IgnoreMasterTextureLimit: 0
m_IsPreProcessed: 0
m_StreamingMipmaps: 0
m_StreamingMipmapsPriority: 0
m_AlphaIsTransparency: 0
m_ImageCount: 0
m_TextureDimension: 2
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 1
m_MipBias: 0
m_WrapU: 0
m_WrapV: 0
m_WrapW: 0
m_LightmapFormat: 0
m_ColorSpace: 0
image data: 0
_typelessdata:
m_StreamData:
offset: 0
size: 0
path:
m_OriginalWidth: 0
m_OriginalHeight: 0
m_OriginalAssetGuid: 00000000000000000000000000000000
--- !u!1 &1782648277
GameObject:
m_ObjectHideFlags: 0

m_Script: {fileID: 11500000, guid: 0366b7a501914ae1855dce19103c98f5, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!28 &1838882529
Texture2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
serializedVersion: 3
m_Width: 0
m_Height: 0
m_CompleteImageSize: 0
m_TextureFormat: 0
m_MipCount: 1
m_IsReadable: 1
m_IgnoreMasterTextureLimit: 0
m_IsPreProcessed: 0
m_StreamingMipmaps: 0
m_StreamingMipmapsPriority: 0
m_AlphaIsTransparency: 0
m_ImageCount: 0
m_TextureDimension: 2
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 1
m_MipBias: 0
m_WrapU: 0
m_WrapV: 0
m_WrapW: 0
m_LightmapFormat: 0
m_ColorSpace: 0
image data: 0
_typelessdata:
m_StreamData:
offset: 0
size: 0
path:
m_OriginalWidth: 0
m_OriginalHeight: 0
m_OriginalAssetGuid: 00000000000000000000000000000000
--- !u!1 &1841365878
GameObject:
m_ObjectHideFlags: 0

m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!4 &1887772893
Transform:
m_ObjectHideFlags: 0

m_GameObject: {fileID: 1887772892}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 131, y: -117, z: 8}
m_LocalScale: {x: 511.103, y: 12.072596, z: 6.6185}
m_LocalPosition: {x: 131, y: -180, z: 8}
m_LocalScale: {x: 478.59174, y: 12.072596, z: 6.6185}
m_Children: []
m_Father: {fileID: 8481369894466841862}
m_RootOrder: 4

m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!4 &2016732638
Transform:
m_ObjectHideFlags: 0

m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!4 &2137220277
Transform:
m_ObjectHideFlags: 0

m_GameObject: {fileID: 2137220276}
m_LocalRotation: {x: 0.006262094, y: -0.0000002682209, z: -0.0026238584, w: 0.999977}
m_LocalPosition: {x: 383, y: 118, z: 1}
m_LocalScale: {x: 11.811192, y: 497.73526, z: 6.6185}
m_LocalPosition: {x: 375, y: 116, z: 1}
m_LocalScale: {x: 11.811192, y: 578.4616, z: 6.6185}
m_Children: []
m_Father: {fileID: 8481369894466841862}
m_RootOrder: 2

OtherPanels:
- {fileID: 734635071}
- {fileID: 1939310059}
- {fileID: 2016732637}
- {fileID: 1355646877}
- {fileID: 8481369894466841863}
mainCamera: {fileID: 1078121413}

m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Texture: {fileID: 763194717}
m_Texture: {fileID: 1518545889}
m_UVRect:
serializedVersion: 2
x: 0

m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8481369894466841863}
m_LocalRotation: {x: -0, y: -0.832602, z: -0, w: 0.5538717}
m_LocalPosition: {x: -12.993, y: 2.2718, z: -6.0341}
m_LocalScale: {x: 0.01091355, y: 0.01091355, z: 0.014551399}
m_LocalRotation: {x: 0.018120706, y: 0.9744255, z: -0.08525123, w: 0.20712051}
m_LocalPosition: {x: 2.86, y: 1.58, z: -7.56}
m_LocalScale: {x: 0.008132543, y: 0.008132543, z: 0.0054216958}
m_Children:
- {fileID: 8481369896194050402}
- {fileID: 8481369895454136273}

m_Father: {fileID: 0}
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: -112.73401, z: 0}
m_LocalEulerAnglesHint: {x: 10, y: 156, z: 0}
--- !u!1 &8481369894466841863
GameObject:
m_ObjectHideFlags: 0

m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8481369895454136274}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -118, y: 121.1, z: 9}
m_LocalScale: {x: 11.811192, y: 489.37936, z: 6.6185}
m_LocalPosition: {x: -109, y: 113, z: 9}
m_LocalScale: {x: 11.811192, y: 594.5899, z: 6.6185}
m_Children: []
m_Father: {fileID: 8481369894466841862}
m_RootOrder: 1

m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!33 &8481369895454136278
MeshFilter:
m_ObjectHideFlags: 0

m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Texture: {fileID: 606780298}
m_Texture: {fileID: 1838882529}
m_UVRect:
serializedVersion: 2
x: 0

m_GameObject: {fileID: 8481369896194050403}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 4.6}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalScale: {x: 0.58586, y: 0.58586, z: 0.58586}
m_Children:
- {fileID: 8481369895487139653}
m_Father: {fileID: 8481369894466841862}

m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 133, y: 116.8}
m_SizeDelta: {x: 500, y: 500}
m_SizeDelta: {x: 800, y: 1000}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &8481369896194050403
GameObject:

16
AwesomeUIWidgets/Assets/Scripts/ChatPage.cs


}
private Future _handleEndReached()
{
List<ChatComponents.TextMessage> messages = new List<ChatComponents.TextMessage>();
List<string> ids = new List<string>() { };
for (int i = 1; i < 10; i++)
{
ids.Add(i.ToString());
}
foreach (var id in ids)
{
messages.Add(new ChatComponents.TextMessage(
_user,
id: "b4878b96-efbc-479a-8291-474ef323a"+ _page + id,
text: id + "......"
) );
}
_messages.AddRange(messages);
_messages.AddRange(_messages);
_page = _page + 1;
}
});

2
AwesomeUIWidgets/Assets/Scripts/ChatPanelDemo.cs


{
base.onEnable();
AddFont("Material Icons", new List<string> {"MaterialIcons-Regular.ttf"}, new List<int> {0});
Application.targetFrameRate = 60;
Application.targetFrameRate = 300;
}
protected override void main()

57
AwesomeUIWidgets/Assets/Scripts/DateAndTimePicker.cs


public class DateAndTimePickerWidgetState : State<DateAndTimePickerWidget>
{
public bool isLottieVisable = true;
private Widget picker = null;
Widget _buildMenu(List<Widget> children) {
return new Container(
decoration: new BoxDecoration(

Widget _buildBottomPicker(Widget picker) {
return new Container(
height: 140f,
height: 280f,
color: Colors.white,
color: Color.fromARGB(100,0,0,0),
child: new DefaultTextStyle(
style: new TextStyle(
color: Colors.red,

Widget _buildDateAndTimePicker(BuildContext context) {
return new GestureDetector(
onTap: () => {
CupertinoRouteUtils.showCupertinoModalPopup(
context: context,
builder: (BuildContext _context) => {
return this._buildBottomPicker(
new CupertinoTheme(
setState(() =>
{
isLottieVisable = false;
});
ModalPage.popup(
context,
_buildBottomPicker(
new CupertinoTheme(
fontSize: 10,
fontSize: 16,
child :new CupertinoDatePicker(
backgroundColor: Color.fromARGB(180, 0, 123, 255),
child: new CupertinoDatePicker(
backgroundColor: Colors.transparent,
onDateTimeChanged: (DateTime newDateTime) => {
onDateTimeChanged: (DateTime newDateTime) =>
{
this.setState(() =>
{
LightManager.time = newDateTime;

)
));
}
);
},
)
),
onPop: () =>
{
setState(() =>
{
isLottieVisable = true;
});
Debug.Log("onPop");
});
},
style: new TextStyle(color: Colors.white, fontSize:12)
style: new TextStyle(color: Colors.white, fontSize:23)
)
);
}

color : Color.fromARGB(0, 0, 123, 255),
child : this._buildDateAndTimePicker(context)
child : new Stack(
children:new List<Widget>()
{
new Visibility(
child: new LottieApp(),
visible: isLottieVisable),
this._buildDateAndTimePicker(context),
})
);
}
}

2
AwesomeUIWidgets/Assets/Scripts/Widgets/chat_list.cs


{
if (oldList != null && oldList.Count != 0 && !oldList.Contains(message1.id))
{
_listKey.currentState?.insertItem(oldList.Count -1);
_listKey.currentState?.insertItem(oldList.Count);
}
}
}

219
AwesomeUIWidgets/Assets/Scripts/Widgets/ModalPage.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace UIWidgetsSample
{
public static class ModalPage
{
public static void popup(
BuildContext context,
Widget child,
Widget overlay = null,
VoidCallback onPop = null,
bool justFade = false
)
{
PopupRoute route;
if (justFade)
{
route = new _FadePopupRoute(
cxt => child,
overlay == null
? (WidgetBuilder) null
: ctx => overlay,
"Dismiss"
);
}
else
{
route = new _ModalPopupRoute(
cxt => child,
overlay == null
? (WidgetBuilder) null
: ctx => overlay,
"Dismiss"
);
}
Navigator.push<object>(context, route).then_(_ => onPop?.Invoke());
}
public static void dismiss(BuildContext context)
{
// if (Navigator.canPop(context))
{
Navigator.pop(context);
}
}
}
internal class _ModalPopupRoute : PopupRoute
{
public _ModalPopupRoute(
WidgetBuilder builder = null,
WidgetBuilder overlayBuilder = null,
string barrierLabel = "",
RouteSettings settings = null
) : base(settings)
{
this.builder = builder;
this.barrierLabel = barrierLabel;
this.overlayBuilder = overlayBuilder;
}
private readonly WidgetBuilder builder;
private readonly WidgetBuilder overlayBuilder;
public string barrierLabel { get; }
public override Color barrierColor => new Color(0x6604040F);
public override bool barrierDismissible => true;
public override TimeSpan transitionDuration => TimeSpan.FromMilliseconds(335);
private AnimationController _animationController;
private Animation<float> _animation;
private Tween<Offset> _offsetTween;
private Tween<float> _opacityTween;
public override Animation<float> createAnimation()
{
D.assert(_animation == null);
_animation = new CurvedAnimation(
base.createAnimation(),
Curves.linearToEaseOut,
Curves.linearToEaseOut.flipped
);
_offsetTween = new OffsetTween(
new Offset(0, 1),
new Offset(0, 0)
);
_opacityTween = new FloatTween(0, 1);
return _animation;
}
public override Widget buildPage(BuildContext context, Animation<float> animation,
Animation<float> secondaryAnimation)
{
return builder(context);
}
public override Widget buildTransitions(BuildContext context, Animation<float> animation,
Animation<float> secondaryAnimation, Widget child)
{
Widget result = new Align(
alignment: Alignment.bottomCenter,
child: new FractionalTranslation(
translation: _offsetTween.evaluate(_animation),
child: child
)
);
if (overlayBuilder != null)
{
result = new Stack(
children: new List<Widget>
{
Positioned.fill(
new Opacity(
opacity: _opacityTween.evaluate(_animation),
child: overlayBuilder(context)
)
),
result
});
}
return result;
}
}
internal class _FadePopupRoute : PopupRoute
{
public _FadePopupRoute(
WidgetBuilder builder = null,
WidgetBuilder overlayBuilder = null,
string barrierLabel = "",
RouteSettings settings = null
) : base(settings)
{
this.builder = builder;
this.barrierLabel = barrierLabel;
this.overlayBuilder = overlayBuilder;
}
private readonly WidgetBuilder builder;
private readonly WidgetBuilder overlayBuilder;
public string barrierLabel { get; }
public override Color barrierColor => new Color(0x6604040F);
public override bool barrierDismissible => true;
public override TimeSpan transitionDuration => TimeSpan.FromMilliseconds(335);
private AnimationController _animationController;
private Animation<float> _animation;
private Tween<float> _opacityTween;
public override Animation<float> createAnimation()
{
D.assert(_animation == null);
_animation = new CurvedAnimation(
base.createAnimation(),
Curves.linearToEaseOut,
Curves.linearToEaseOut.flipped
);
_opacityTween = new FloatTween(0, 1);
return _animation;
}
public override Widget buildPage(BuildContext context, Animation<float> animation,
Animation<float> secondaryAnimation)
{
return builder(context);
}
public override Widget buildTransitions(BuildContext context, Animation<float> animation,
Animation<float> secondaryAnimation, Widget child)
{
Widget result = new Align(
alignment: Alignment.bottomCenter,
child: new Opacity(
opacity: _opacityTween.evaluate(_animation),
child: child
)
);
if (overlayBuilder != null)
{
result = new Stack(
children: new List<Widget>
{
Positioned.fill(
new Opacity(
opacity: _opacityTween.evaluate(_animation),
child: overlayBuilder(context)
)
),
result
});
}
return result;
}
}
}

3
AwesomeUIWidgets/Assets/Scripts/Widgets/ModalPage.cs.meta


fileFormatVersion: 2
guid: b9198d8d6d624e3e80f7e2c2d55145e0
timeCreated: 1627638464
正在加载...
取消
保存