Skip to content

Commit

Permalink
Merge pull request #52 from sarmadka/main
Browse files Browse the repository at this point in the history
Added placeholder prop to TextInput and new Stack transition.
  • Loading branch information
sarmadka authored Sep 17, 2024
2 parents d6278aa + aebb3a3 commit 9a74c18
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 14 deletions.
2 changes: 2 additions & 0 deletions Doc/widgets.ar.md
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,8 @@ Text(tag: String, text: String);

* `النص` (`text`): `نـص` (`String`). النص المدخل من قبل المستخدم.

* `قيمة_وصفية` (`placeholder`): `نـص` (`String`). قيمة تظهر قبل أن يقوم المستخدم بالإدخال لتوضيح ما يجب إدخاله.

#### الأحداث

##### عند_الغيير (onChanged)
Expand Down
3 changes: 3 additions & 0 deletions Doc/widgets.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ A text entry box.

* `text`: `String`. The entered text.

* `placeholder`: `String`. A value that appears before the user enters anything, to clarify what
to enter.

#### Events

##### onChanged
Expand Down
2 changes: 1 addition & 1 deletion Examples/canvas.alusus
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func main {
canvasRes.drawLine(100, 0, 0, 100);
def points: Array [Int]({ 25, 25, 75, 25, 75, 75, 25, 75 });
canvasRes.drawPolygon(4, points.buf, false);
dynImg.initFromCanvas(canvasRes);
await(dynImg.initFromCanvas(canvasRes));

// Animation loop.
def x: Int = -80;
Expand Down
2 changes: 1 addition & 1 deletion Examples/مرسم.أسس
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
مورد_مرسم.ارسم_خطا(100, 0, 0, 100)؛
عرف نقاط: مـصفوفة[صحيح]({ 25, 25, 75, 25, 75, 75, 25, 75 })؛
مورد_مرسم.ارسم_مضلعا(4, نقاط.صوان, 0)؛
صورة_ديناميكية.هيئ_من_مرسم(مورد_مرسم)؛
انتظر(صورة_ديناميكية.هيئ_من_مرسم(مورد_مرسم)

// حلقة التحريك
عرف س: صحيح = -80؛
Expand Down
33 changes: 21 additions & 12 deletions WebPlatform/Components/Stack.alusus
Original file line number Diff line number Diff line change
Expand Up @@ -167,28 +167,37 @@
}

func createFadeStackTransition (duration: Float, exiting: Bool): StackTransition {
def start: Float;
def end: Float;
return createFadeWithScaleStackTransition(duration, 1.0, exiting);
}

func createFadeWithScaleStackTransition (duration: Float, minScale: Float, exiting: Bool): StackTransition {
def startOpacity: Float;
def startScale: Float;
def endOpacity: Float;
def endScale: Float;
if exiting {
start = 1.0;
end = 0.0;
startOpacity = 1.0;
endOpacity = 0.0;
startScale = 1.0;
endScale = minScale;
} else {
start = 0.0;
end = 1.0;
startOpacity = 0.0;
endOpacity = 1.0;
startScale = minScale;
endScale = 1.0;
}
return StackTransition().{
totalDuration = duration * 1000000;
topViewStyle.{
left = "0";
opacity = end;
opacity = endOpacity;
transform = Transform.scale(endScale, endScale);
animation = Animation(duration, Array[Style]({
Style().{ opacity = start },
Style().{ opacity = end }
Style().{ opacity = startOpacity; transform = Transform.scale(startScale, startScale) },
Style().{ opacity = endOpacity; transform = Transform.scale(endScale, endScale) }
}));
};
}
}
}

// TODO: Add more transitions.
}

3 changes: 3 additions & 0 deletions WebPlatform/Widgets/TextInput.alusus
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
//-----------------------
// Properties and Signals

generateProperty[placeholder, Placeholder, String];

def _text: String;
handler this.setText (t: String) {
this._text = t;
Expand Down Expand Up @@ -107,6 +109,7 @@
if this.id.getLength() > 0 {
this.updateCommon();
setElementAttribute(this.id, "value", this._text);
setElementAttribute(this.id, "placeholder", this.placeholder);
}
}

Expand Down
2 changes: 2 additions & 0 deletions مـنصة_ويب.أسس
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@
عرف مـدخل_نص: لقب TextInput؛
@دمج صنف مـدخل_نص {
عرب_خصلة[النص، _النص، text، Text]؛
عرب_خصلة[قيمة_وصفية، _قيمة_وصفية، placeholder، Placeholder]؛
عرف عند_الغيير: لقب onChanged؛
عرف عند_كبس_مفتاح: لقب onKeyPress؛
عرف عند_انتهاء_الكبسة: لقب onKeyUp؛
Expand Down Expand Up @@ -676,6 +677,7 @@

عرف أنشئ_انتقال_انزلاق_مكداس: لقب createSlideStackTransition؛
عرف أنشئ_انتقال_تلاشي_مكداس: لقب createFadeStackTransition؛
عرف أنشئ_انتقال_تلاشي_مع_تحجيم_مكداس: لقب createFadeWithScaleStackTransition؛

عرف مـكداس_توجيه: لقب RoutingStack؛
@دمج صنف مـكداس_توجيه {
Expand Down

0 comments on commit 9a74c18

Please sign in to comment.