This commit is contained in:
Paola Villarreal 2014-05-13 12:22:13 -05:00
Родитель d787f86531
Коммит 06b108bfde
4 изменённых файлов: 37 добавлений и 33 удалений

Просмотреть файл

@ -9,10 +9,10 @@ using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Dialog;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Foundation;
using UIKit;
using System.Drawing;
using MonoTouch.MapKit;
using MapKit;
namespace BubbleCell {

Просмотреть файл

@ -8,11 +8,10 @@
//
using System;
using System.Collections.Generic;
using MonoTouch.UIKit;
using UIKit;
using MonoTouch.Dialog;
using MonoTouch.CoreGraphics;
using MonoTouch.Foundation;
using System.Drawing;
using CoreGraphics;
using Foundation;
namespace BubbleCell
{
@ -40,7 +39,7 @@ namespace BubbleCell
public BubbleCell (bool isLeft) : base (UITableViewCellStyle.Default, isLeft ? KeyLeft : KeyRight)
{
var rect = new RectangleF (0, 0, 1, 1);
var rect = new CGRect (0, 0, 1, 1);
this.isLeft = isLeft;
view = new UIView (rect);
imageView = new UIImageView (isLeft ? left : right);
@ -60,17 +59,17 @@ namespace BubbleCell
base.LayoutSubviews ();
var frame = ContentView.Frame;
var size = GetSizeForText (this, label.Text) + BubblePadding;
imageView.Frame = new RectangleF (new PointF (isLeft ? 10 : frame.Width-size.Width-10, frame.Y), size);
imageView.Frame = new CGRect (new CGPoint (isLeft ? 10 : frame.Width-size.Width-10, frame.Y), size);
view.SetNeedsDisplay ();
frame = imageView.Frame;
label.Frame = new RectangleF (new PointF (frame.X + (isLeft ? 12 : 8), frame.Y + 6), size-BubblePadding);
label.Frame = new CGRect (new CGPoint (frame.X + (isLeft ? 12 : 8), frame.Y + 6), size-BubblePadding);
}
static internal SizeF BubblePadding = new SizeF (22, 16);
static internal CGSize BubblePadding = new CGSize (22, 16);
static internal SizeF GetSizeForText (UIView tv, string text)
static internal CGSize GetSizeForText (UIView tv, string text)
{
return tv.StringSize (text, font, new SizeF (tv.Bounds.Width*.7f-10-22, 99999));
return tv.StringSize (text, font, new CGSize (tv.Bounds.Width*.7f-10-22, 99999));
}
public void Update (string text)
@ -98,7 +97,7 @@ namespace BubbleCell
return cell;
}
public float GetHeight (UITableView tableView, NSIndexPath indexPath)
public nfloat GetHeight (UITableView tableView, NSIndexPath indexPath)
{
return BubbleCell.GetSizeForText (tableView, Caption).Height + BubbleCell.BubblePadding.Height;
}

Просмотреть файл

@ -16,13 +16,14 @@
<DebugType>full</DebugType>
<Optimize>False</Optimize>
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<DefineConstants>DEBUG;XAMCORE_2_0;ARCH_64</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>False</ConsolePause>
<MtouchDebug>True</MtouchDebug>
<MtouchProfiling>True</MtouchProfiling>
<MtouchLink>None</MtouchLink>
<MtouchExtraArgs>--registrar:static --nofastsim --override-abi x86_64</MtouchExtraArgs>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
<DebugType>none</DebugType>
@ -59,8 +60,12 @@
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="monotouch" />
<Reference Include="MonoTouch.Dialog-1" />
<Reference Include="Xamarin.iOS">
<HintPath>\Developer\MonoTouch\usr\lib\mono\Xamarin.iOS\Xamarin.iOS.dll</HintPath>
</Reference>
<Reference Include="MonoTouch.Dialog-1">
<HintPath>\Developer\MonoTouch\usr\lib\mono\Xamarin.iOS\MonoTouch.Dialog-1.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="Info.plist" />
@ -101,4 +106,4 @@
<ItemGroup>
<ITunesArtwork Include="Resources\iTunesArtwork.png" />
</ItemGroup>
</Project>
</Project>

Просмотреть файл

@ -11,9 +11,9 @@ using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Dialog;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using System.Drawing;
using Foundation;
using UIKit;
using CoreGraphics;
namespace BubbleCell
{
@ -29,7 +29,7 @@ namespace BubbleCell
const float messageFontSize = 16;
const float maxContentHeight = 84;
const int entryHeight = 40;
float previousContentHeight;
nfloat previousContentHeight;
NSObject showObserver, hideObserver;
@ -50,7 +50,7 @@ namespace BubbleCell
//
// Add the bubble chat interface
//
discussionHost = new UIView (new RectangleF (bounds.X, bounds.Y, bounds.Width, bounds.Height-entryHeight)) {
discussionHost = new UIView (new CGRect (bounds.X, bounds.Y, bounds.Width, bounds.Height-entryHeight)) {
AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth,
AutosizesSubviews = true,
UserInteractionEnabled = true
@ -64,7 +64,7 @@ namespace BubbleCell
//
// Add styled entry
//
chatBar = new UIImageView (new RectangleF (0, bounds.Height-entryHeight, bounds.Width, entryHeight)) {
chatBar = new UIImageView (new CGRect (0, bounds.Height-entryHeight, bounds.Width, entryHeight)) {
ClearsContextBeforeDrawing = false,
AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleWidth,
Image = UIImage.FromFile ("ChatBar.png").StretchableImage (18, 20),
@ -72,8 +72,8 @@ namespace BubbleCell
};
View.AddSubview (chatBar);
entry = new UITextView (new RectangleF (10, 9, 234, 22)) {
ContentSize = new SizeF (234, 22),
entry = new UITextView (new CGRect (10, 9, 234, 22)) {
ContentSize = new CGSize (234, 22),
AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight,
ScrollEnabled = true,
ScrollIndicatorInsets = new UIEdgeInsets (5, 0, 4, -2),
@ -96,14 +96,14 @@ namespace BubbleCell
//
sendButton = UIButton.FromType (UIButtonType.Custom);
sendButton.ClearsContextBeforeDrawing = false;
sendButton.Frame = new RectangleF (chatBar.Frame.Width - 70, 8, 64, 26);
sendButton.Frame = new CGRect (chatBar.Frame.Width - 70, 8, 64, 26);
sendButton.AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleLeftMargin;
var sendBackground = UIImage.FromFile ("SendButton.png");
sendButton.SetBackgroundImage (sendBackground, UIControlState.Normal);
sendButton.SetBackgroundImage (sendBackground, UIControlState.Disabled);
sendButton.TitleLabel.Font = UIFont.BoldSystemFontOfSize (16);
sendButton.TitleLabel.ShadowOffset = new SizeF (0, -1);
sendButton.TitleLabel.ShadowOffset = new CGSize (0, -1);
sendButton.SetTitle ("Send", UIControlState.Normal);
sendButton.SetTitleShadowColor (new UIColor (0.325f, 0.463f, 0.675f, 1), UIControlState.Normal);
sendButton.AddTarget (SendMessage, UIControlEvent.TouchUpInside);
@ -169,10 +169,10 @@ namespace BubbleCell
SetChatBarHeight (contentHeight + 18);
if (previousContentHeight > maxContentHeight)
entry.ScrollEnabled = false;
entry.ContentOffset = new PointF (0, 6);
entry.ContentOffset = new CGPoint (0, 6);
} else if (previousContentHeight <= maxContentHeight){
entry.ScrollEnabled = true;
entry.ContentOffset = new PointF (0, contentHeight-68);
entry.ContentOffset = new CGPoint (0, contentHeight-68);
if (previousContentHeight < maxContentHeight){
ExpandChatBarHeight ();
}
@ -196,7 +196,7 @@ namespace BubbleCell
}
// Resizes the chat bar to the specified height
void SetChatBarHeight (float height)
void SetChatBarHeight (nfloat height)
{
var chatFrame = discussion.View.Frame;
chatFrame.Height = View.Frame.Height-height;
@ -205,7 +205,7 @@ namespace BubbleCell
UIView.BeginAnimations ("");
UIView.SetAnimationDuration (.3);
discussion.View.Frame = chatFrame;
chatBar.Frame = new RectangleF (chatBar.Frame.X, chatFrame.Height, chatFrame.Width, height);
chatBar.Frame = new CGRect (chatBar.Frame.X, chatFrame.Height, chatFrame.Width, height);
UIView.CommitAnimations ();
}
@ -225,7 +225,7 @@ namespace BubbleCell
void AdjustEntry ()
{
// This fixes a rendering glitch
entry.ContentOffset = new PointF (0, 6);
entry.ContentOffset = new CGPoint (0, 6);
}
//